Java 类javax.vecmath.Vector4d 实例源码
项目:rct-java
文件:Cross_lib_provider.java
private Vector4d transform_now(String source, String target, Vector4d point) throws InterruptedException, TransformerException {
long when = System.currentTimeMillis();
Thread.sleep(30);
if (receiver.canTransform(target, source, when)) {
Transform trafo = receiver.lookupTransform(target, source, when);
System.out.println("[" + trafo.getFrameChild() + "] --> " + "[" + trafo.getFrameParent() + "]");
Vector4d point4d = new Vector4d(point.x, point.y, point.z, 1.0);
trafo.getTransform().transform(point4d);
return point4d;
} else {
System.out.println("Error: Cannot transfrom " + source + " --> " + target);
return new Vector4d();
}
}
项目:rct-java
文件:Cross_lib_provider.java
private void test() throws InterruptedException, TransformerException, TransformerFactory.TransformerFactoryException {
receiver = TransformerFactory.getInstance().createTransformReceiver();
System.out.println("Gathering available transformations ...");
Thread.sleep(1000);
// The different systems and the base
String[] targets = {"java_static", "java_dynamic", "python_static", "python_dynamic"};
String base = "base";
Vector4d point = new Vector4d(1.0, 1.0, 1.0, 1.0);
System.out.println("Point to transform: " + point + "\n");
for (String target : targets) {
// Forward transfrom
Vector4d transformed_point = transform_now(base, target, point);
System.out.println("[" + point + "] --> " + "[" + transformed_point + "]");
// Backward transfrom
Vector4d re_transformed_point = transform_now(target, base, transformed_point);
System.out.println("[" + transformed_point + "] --> " + "[" + re_transformed_point + "]");
System.out.println("");
}
System.exit(0);
}
项目:chordatlas
文件:ReadTrace.java
private float[] locTrans(int[] fs, Matrix4d viewMatrix) {
Vector4d loc =new Vector4d(
Math.floor( ( fs[0] ) + 0.5),
Math.floor( ( fs[1] ) + 0.5),
Math.floor( ( fs[2] ) + 0.5),
1);
viewMatrix.transform(loc);
return new float[] { (float) loc.x, (float) loc.y , (float) loc.z};
}
项目:UT4Converter
文件:BinUtils.java
public static Vector4d readVector4d(ByteBuffer bf) {
Vector4d v = new Vector4d();
v.x = bf.getFloat();
v.y = bf.getFloat();
v.z = bf.getFloat();
v.w = bf.getFloat();
return v;
}
项目:UT4Converter
文件:BinUtils.java
public static void writeVector4d(FileOutputStream bos, Vector4d v) throws IOException {
writeFloat(bos, (float) v.x);
writeFloat(bos, (float) v.y);
writeFloat(bos, (float) v.z);
writeFloat(bos, (float) v.x);
}
项目:Hard-Science
文件:RawQuad.java
/** returns a copy of this quad with the given transformation applied */
public RawQuad transform(Matrix4d matrix)
{
RawQuad result = this.clone();
// transform vertices
for(int i = 0; i < result.vertexCount; i++)
{
Vertex vertex = result.getVertex(i);
Vector4d temp = new Vector4d(vertex.x, vertex.y, vertex.z, 1.0);
matrix.transform(temp);
if(Math.abs(temp.w - 1.0) > 1e-5) temp.scale(1.0 / temp.w);
result.setVertex(i, vertex.withXYZ(temp.x, temp.y, temp.z));
}
// transform nominal face
// our matrix transform has block center as its origin,
// so need to translate face vectors to/from block center
// origin before/applying matrix.
if(this.face != null)
{
Vec3i curNorm = this.face.getDirectionVec();
Vector4d newFaceVec = new Vector4d(curNorm.getX() + 0.5, curNorm.getY() + 0.5, curNorm.getZ() + 0.5, 1.0);
matrix.transform(newFaceVec);
newFaceVec.x -= 0.5;
newFaceVec.y -= 0.5;
newFaceVec.z -= 0.5;
result.setFace(QuadHelper.computeFaceForNormal(newFaceVec));
}
return result;
}
项目:jvircam
文件:Projection.java
public Point3d transform(Vector4d vec) {
Vector4d res = new Vector4d();
P.transform(vec, res);
Point3d p = new Point3d(res.x, res.y, res.z);
if (Math.abs(p.z) < EPS) { // point at infinity
p.z = 0;
} else if (p.z > 0) {
p.scale(1.0 / p.z);
}// else point is behind of camera
return p;
}
项目:jvircam
文件:Projection.java
public Point2d vanishingPoint(Vector3d vec) {
Point3d p = this.transform(new Vector4d(vec.x, vec.y, vec.z, 0.0));
if (p.z > 0) {
return new Point2d(p.x, p.y);
}
return null;
}
项目:cmoct-sourcecode
文件:SlicePlaneRenderer.java
private double planeDist(Point3d pt, Vector4d plane)
{
return pt.x * plane.x + pt.y * plane.y + pt.z * plane.z + plane.w;
}
项目:UT4Converter
文件:LandscapeComponent.java
public void setWeightmapScaleBias(Vector4d weightmapScaleBias) {
this.weightmapScaleBias = weightmapScaleBias;
}
项目:UT4Converter
文件:LandscapeComponent.java
public void setHeightmapScaleBias(Vector4d heightmapScaleBias) {
this.heightmapScaleBias = heightmapScaleBias;
}
项目:Hard-Science
文件:QuadHelper.java
public static EnumFacing computeFaceForNormal(Vector4d normal)
{
return computeFaceForNormal(new Vec3d(normal.x, normal.y, normal.z));
}
项目:jvircam
文件:Projection.java
public Point3d transform(Vector3d p) {
return this.transform(new Vector4d(p.x, p.y, p.z, 1.0));
}