本文整理汇总了Java中javax.vecmath.Tuple3f类的典型用法代码示例。如果您正苦于以下问题:Java Tuple3f类的具体用法?Java Tuple3f怎么用?Java Tuple3f使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Tuple3f类属于javax.vecmath包,在下文中一共展示了Tuple3f类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createVertexBuffer
import javax.vecmath.Tuple3f; //导入依赖的package包/类
static short createVertexBuffer(ByteBuffer buffer, BGFXVertexDecl decl, Object[]... vertices) {
for (Object[] objects : vertices) {
for (Object object : objects) {
if (object instanceof Tuple2f)
buffer.putFloat(((Tuple2f) object).getX()).putFloat(((Tuple2f) object).getY());
else if (object instanceof Tuple3f)
buffer.putFloat(((Tuple3f) object).getX()).putFloat(((Tuple3f) object).getY()).putFloat(((Tuple3f) object).getZ());
else if (object instanceof Tuple4f)
buffer.putFloat(((Tuple4f) object).getX()).putFloat(((Tuple4f) object).getY()).putFloat(((Tuple4f) object).getZ()).putFloat(((Tuple4f) object).getW());
else if (object instanceof Integer)
buffer.putInt(((int) object));
else
throw new IllegalArgumentException("Unknown type of vertex: " + object.getClass().getName() + ", valid type are:" +
"javax.vecmath.Tuple2f/3f/4f & java.lang.Integer");
}
}
if (buffer.remaining() != 0) {
throw new RuntimeException("ByteBuffer size and number of arguments do not match");
}
buffer.flip();
return createVertexBuffer(buffer, decl);
}
示例2: format
import javax.vecmath.Tuple3f; //导入依赖的package包/类
private String format(float floatT, String strT, Tuple3f ptT) {
if (!Float.isNaN(floatT)) {
return TextFormat.format(floatT, width, precision, alignLeft, zeroPad);
} else if (strT != null) {
return TextFormat.format(strT, width, precision, alignLeft, zeroPad);
} else if (ptT != null) {
if (width == 0 && precision == Integer.MAX_VALUE) {
width = 6;
precision = 2;
}
return TextFormat.format(ptT.x, width, precision, false, false)
+ TextFormat.format(ptT.y, width, precision, false, false)
+ TextFormat.format(ptT.z, width, precision, false, false);
} else {
return text;
}
}
示例3: getNormalMap
import javax.vecmath.Tuple3f; //导入依赖的package包/类
protected int[] getNormalMap(Tuple3f[] normals, int nNormals,
BitSet bsValid, List<String> vNormals) {
Map<String, Integer> htNormals = new Hashtable<String, Integer>();
int[] normalMap = new int[nNormals];
for (int i = 0; i < nNormals; i++) {
String s;
if (bsValid != null && !bsValid.get(i) || Float.isNaN(normals[i].x)){
if (bsValid != null)
bsValid.clear(i);
continue;
}
s = (round(normals[i].x) + " " + round(normals[i].y) + " "
+ round(normals[i].z) + "\n");
if (htNormals.containsKey(s)) {
normalMap[i] = htNormals.get(s).intValue();
} else {
normalMap[i] = vNormals.size();
vNormals.add(s);
htNormals.put(s, Integer.valueOf(normalMap[i]));
}
}
return normalMap;
}
示例4: clear
import javax.vecmath.Tuple3f; //导入依赖的package包/类
public void clear(int bufferMask, Tuple3f color) {
if ((bufferMask & COLOR_BUFFER) != 0) {
int r = (int)(color.x*255f);
int g = (int)(color.y*255f);
int b = (int)(color.z*255f);
int c = (r << 16) | (g << 8) | b;
for (int i=0; i<zbuffer.length; i++) {
pixels[i] = c;
}
}
if ((bufferMask & DEPTH_BUFFER) != 0) {
for (int i=0; i<zbuffer.length; i++) {
zbuffer[i] = Float.MAX_VALUE;
}
}
}
示例5: FacialPoint
import javax.vecmath.Tuple3f; //导入依赖的package包/类
public FacialPoint(FacialPointType type, Tuple3f coords) {
this.pos = new Vector3f(coords);
this.type = type;
this.name = FpTexter.getInstance().getFPname(type);
this.info = FpTexter.getInstance().getFPinfo(type);
}
示例6: getIntersectionBetweenLineAndPlane
import javax.vecmath.Tuple3f; //导入依赖的package包/类
public static Point3d getIntersectionBetweenLineAndPlane(PlaneEquation eq, Tuple3f one, Tuple3f two) {
double Xa = one.x;
double Ya = one.y;
double Za = one.z;
double k;
//A,B,C,D from Ax+By+Cz+d=0
double A = eq.getA();
double B = eq.getB();
double C = eq.getC();
double D = eq.getD();
//case when plane and polygon have the common tangent
//ignore this?
if (isPointWithinPlane(eq, one) && isPointWithinPlane(eq, two)) {
return null;
}
try {
//for parallel it'will be an exception
k = -(A * Xa + B * Ya + C * Za + D) / (A * (two.x - one.x)
+ B * (two.y - one.y)
+ C * (two.z - one.z));
} catch (Exception e) {
return null;
}
if (Math.abs(k) > 1 || k < 0) {
return null;
}
double x0 = k * (two.x - one.x) + Xa;
double y0 = k * (two.y - one.y) + Ya;
double z0 = k * (two.z - one.z) + Za;
Point3d resPoint = new Point3d(x0, y0, z0);
return resPoint;
}
示例7: isPointWithinPlane
import javax.vecmath.Tuple3f; //导入依赖的package包/类
public static boolean isPointWithinPlane(PlaneEquation eq, Tuple3f point) {
double value = (eq.getA() * point.x
+ eq.getB() * point.y
+ eq.getC() * point.z
+ eq.getD());
return (Math.abs(value) / eq.getMAX() < THRESHOLD2);
}
示例8: approx0
import javax.vecmath.Tuple3f; //导入依赖的package包/类
private static Tuple3f approx0(Tuple3f pt) {
if (pt != null) {
if (Math.abs(pt.x) < 0.0001f)
pt.x = 0;
if (Math.abs(pt.y) < 0.0001f)
pt.y = 0;
if (Math.abs(pt.z) < 0.0001f)
pt.z = 0;
}
return pt;
}
示例9: approx
import javax.vecmath.Tuple3f; //导入依赖的package包/类
private static Tuple3f approx(Tuple3f pt) {
if (pt != null) {
pt.x = approx(pt.x);
pt.y = approx(pt.y);
pt.z = approx(pt.z);
}
return pt;
}
示例10: escape
import javax.vecmath.Tuple3f; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static String escape(Object x) {
if (x instanceof String)
return escape((String) x);
if (x instanceof List<?>)
return escape((ArrayList<ScriptVariable>) x);
if (x instanceof BitSet)
return escape((BitSet) x, true);
if (x instanceof Matrix3f)
return ((Matrix3f) x).toString();
if (x instanceof Matrix4f)
return ((Matrix4f) x).toString();
if (x instanceof Tuple3f)
return escape((Tuple3f) x);
if (x instanceof Point4f) {
Point4f xyzw = (Point4f) x;
return "{" + xyzw.x + " " + xyzw.y + " " + xyzw.z + " " + xyzw.w + "}";
}
if (x instanceof AxisAngle4f) {
AxisAngle4f a = (AxisAngle4f) x;
return "{" + a.x + " " + a.y + " " + a.z + " " + (float) (a.angle * 180d/Math.PI) + "}";
}
if (x instanceof String[])
return escape((String[]) x, true);
if (x instanceof int[]
|| x instanceof int[][]
|| x instanceof float[]
|| x instanceof float[][]
|| x instanceof float[][][])
return toJSON(null, x);
if (x instanceof Point3f[])
return escapeArray(x);
if (x instanceof Map)
return escape((Map<String, Object>) x);
return (x == null ? "null" : x.toString());
}
示例11: MeshSurface
import javax.vecmath.Tuple3f; //导入依赖的package包/类
public MeshSurface(int[][] polygonIndexes, Tuple3f[] vertices, int nVertices,
Tuple3f[] normals, int nNormals) {
this.polygonIndexes = polygonIndexes;
if (vertices instanceof Point3f[])
this.vertices = (Point3f[]) vertices;
else
this.altVertices = vertices;
this.vertexCount = (nVertices == 0 ? vertices.length : nVertices);
this.normals = normals;
this.normalCount = (nNormals == 0 && normals != null ? normals.length : nNormals);
}
示例12: set
import javax.vecmath.Tuple3f; //导入依赖的package包/类
/**
* q = (cos(theta/2), sin(theta/2) * n)
*
* @param pt
* @param theta
*/
public void set(Tuple3f pt, float theta) {
if (pt.x == 0 && pt.y == 0 && pt.z == 0) {
q0 = 1;
return;
}
double fact = (Math.sin(theta / 2 * Math.PI / 180) / Math.sqrt(pt.x
* pt.x + pt.y * pt.y + pt.z * pt.z));
q0 = (float) (Math.cos(theta / 2 * Math.PI / 180));
q1 = (float) (pt.x * fact);
q2 = (float) (pt.y * fact);
q3 = (float) (pt.z * fact);
}
示例13: getQuaternionFrame
import javax.vecmath.Tuple3f; //导入依赖的package包/类
public static final Quaternion getQuaternionFrame(Point3f center, Tuple3f x, Tuple3f xy) {
Vector3f vA = new Vector3f(x);
vA.sub(center);
Vector3f vB = new Vector3f(xy);
vB.sub(center);
return getQuaternionFrame(vA, vB, null, false);
}
示例14: outputList
import javax.vecmath.Tuple3f; //导入依赖的package包/类
/**
* create the v or vn list
*
* @param pts
* @param nPts
* @param m
* @param prefix
* @param bsValid TODO
*/
private void outputList(Tuple3f[] pts, int nPts, Matrix4f m, String prefix, BitSet bsValid) {
for (int i = 0; i < nPts; i++) {
if (bsValid != null && !bsValid.get(i))
continue;
ptTemp.set(pts[i]);
if (m != null)
m.transform(ptTemp);
output(prefix + ptTemp.x + " " + ptTemp.y + " " + ptTemp.z + "\n");
}
}
示例15: checkPoint
import javax.vecmath.Tuple3f; //导入依赖的package包/类
private void checkPoint(Tuple3f pt) {
if (pt.x < ptMin.x)
ptMin.x = pt.x;
if (pt.y < ptMin.y)
ptMin.y = pt.y;
if (pt.z < ptMin.z)
ptMin.z = pt.z;
if (pt.x > ptMax.x)
ptMax.x = pt.x;
if (pt.y > ptMax.y)
ptMax.y = pt.y;
if (pt.z > ptMax.z)
ptMax.z = pt.z;
}