Point3f pos = new Point3f( Float.intBitsToFloat( newData[i * stride + posIdx] ) - 0.5f, Float .intBitsToFloat( newData[i * stride + posIdx + 1] ) - 0.5f, Float.intBitsToFloat( newData[i * stride + posIdx + 2] ) - 0.5f ); newData[i * stride + posIdx] = Float.floatToIntBits( pos.getX() + 0.5f ); newData[i * stride + posIdx + 1] = Float.floatToIntBits( pos.getY() + 0.5f ); newData[i * stride + posIdx + 2] = Float.floatToIntBits( pos.getZ() + 0.5f );
public VMDMotion set(VMDMotion m) { boneIndex = m.boneIndex; frameNo = m.frameNo; location.set(m.location); rotation.set(m.rotation); System.arraycopy(m.interpolation, 0, interpolation, 0, 64); vmdFile = m.vmdFile; return m; }
private boolean isQuadOneDimensional(Point3f[] vertices) { for (int i = 0; i < vertices.length; i++) { Point3f vertex = vertices[i]; for (int n = i + 1; n < vertices.length; n++) { float epsilon = 1e-4F; if (vertex.epsilonEquals(vertices[n], epsilon)) { return true; } } } return false; }
/** * Transform the Point3f point by this transform and place result back in * point. * * @param point */ public final void transform(Point3f point) { float x = (float) (mat00 * point.getX() + mat01 * point.getY() + mat02 * point.getZ() + mat03); float y = (float) (mat10 * point.getX() + mat11 * point.getY() + mat12 * point.getZ() + mat13); point.setZ((float) (mat20 * point.getX() + mat21 * point.getY() + mat22 * point.getZ() + mat23)); point.setX(x); point.setY(y); }
public Point3f[] getPoints3f() { Point3f[] points = new Point3f[flatPoints.length / 3]; for (int i = 0; i < points.length; i++) { points[i] = new Point3f(flatPoints[3 * i], flatPoints[3 * i + 1], flatPoints[3 * i + 2]); } return points; }
public Point3f[] getPointMap() { int numberOfPoints = localizationPointMap.length/3; Point3f[] points = new Point3f[numberOfPoints]; for(int i = 0; i < numberOfPoints; i++) { Point3f point = new Point3f(); point.setX(localizationPointMap[3 * i]); point.setY(localizationPointMap[3 * i + 1]); point.setZ(localizationPointMap[3 * i + 2]); points[i] = point; } return points; }
private synchronized void adjust() { //Generate random position in graph space tempISOM = new ISOMVertexData(); tempXYD = new Point3f(); // creates a new XYZ data location tempXYD.set((float)(10 + Math.random() * getSize().getRadius()), (float)(10 + Math.random() * getSize().getRadius()), (float)(10 + Math.random() * getSize().getRadius())); //Get closest vertex to random position V winner = elementAccessor.getVertex(this, tempXYD); while(true) { try { for(V v : getGraph().getVertices()) { ISOMVertexData ivd = getISOMVertexData(v); ivd.distance = 0; ivd.visited = false; } break; } catch(ConcurrentModificationException cme) {} } adjustVertex(winner); }
/** * Utility method to translate a given mesh using a given translation. * @param input the mesh to translate. Not modified. * @param offsetX translation along the x-axis to apply to the mesh. * @param offsetY translation along the y-axis to apply to the mesh. * @param offsetZ translation along the z-axis to apply to the mesh. * @return the translated mesh. */ public static MeshDataHolder translate(MeshDataHolder input, float offsetX, float offsetY, float offsetZ) { Point3f[] inputVertices = input.getVertices(); TexCoord2f[] texturePoints = input.getTexturePoints(); int[] triangleIndices = input.getTriangleIndices(); Vector3f[] normals = input.getVertexNormals(); Point3f[] outputVertices = new Point3f[inputVertices.length]; for (int i = 0; i < inputVertices.length; i++) { outputVertices[i] = new Point3f(offsetX, offsetY, offsetZ); outputVertices[i].add(inputVertices[i]); } return new MeshDataHolder(outputVertices, texturePoints, triangleIndices, normals); }
/** * Add a 3D line to this builder. * @param x0 x-coordinate of the line start. * @param y0 y-coordinate of the line start. * @param z0 z-coordinate of the line start. * @param xf x-coordinate of the line end. * @param yf y-coordinate of the line end. * @param zf z-coordinate of the line end. * @param lineWidth width of the line. * @param startColor color at the line start. Color accuracy depends on the color palette in use. * @param endColor color at the line end. Color accuracy depends on the color palette in use. */ public void addLine(float x0, float y0, float z0, float xf, float yf, float zf, float lineWidth, Color startColor, Color endColor) { MeshDataHolder lineMeshData = MeshDataGenerator.Line(x0, y0, z0, xf, yf, zf, lineWidth); float expectedDistance = 2.0f * lineWidth * lineWidth; Point3f[] vertices = lineMeshData.getVertices(); TexCoord2f[] texturePoints = lineMeshData.getTexturePoints(); Point3f start = new Point3f(x0, y0, z0); for (int i = 0; i < vertices.length; i++) { if (MathTools.epsilonEquals(vertices[i].distanceSquared(start), expectedDistance, 1.0e-5)) texturePoints[i].set(colorPalette.getTextureLocation(startColor)); else texturePoints[i].set(colorPalette.getTextureLocation(endColor)); } meshBuilder.addMesh(lineMeshData); }
/** * Returns the y coordinate of the vertex from the Coordinates object. * In most cases you will be better off calling getLocation(Vertex v) * @see edu.uci.ics.jung.visualization.layout.Layout#getX(edu.uci.ics.jung.graph.Vertex) */ public double getY(V v) { assert getCoordinates(v) != null : "Cannot getY for an unmapped vertex "+v; return getCoordinates(v).getY(); }
/** * Returns the x coordinate of the vertex from the Coordinates object. * in most cases you will be better off calling getLocation(Vertex v); * @see edu.uci.ics.jung.visualization.layout.Layout#getX(edu.uci.ics.jung.graph.Vertex) */ public double getX(V v) { assert getCoordinates(v) != null : "Cannot getX for an unmapped vertex "+v; return getCoordinates(v).getX(); }
/** * Constructor. * @param index the node index * @param x the x coordinate * @param y the y coordinate * @param z the z coordinate */ public Node(int index, float x, float y, float z) { this.index = index; this.location = new Point3f(x,y,z); }
/** * Transform the Point3f pointIn by this transform and place result in * pointOut. * * @param point */ public final void transform(Point3f pointIn, Point3f pointOut) { if (pointIn != pointOut) { pointOut.setX((float) (mat00 * pointIn.getX() + mat01 * pointIn.getY() + mat02 * pointIn.getZ() + mat03)); pointOut.setY((float) (mat10 * pointIn.getX() + mat11 * pointIn.getY() + mat12 * pointIn.getZ() + mat13)); pointOut.setZ((float) (mat20 * pointIn.getX() + mat21 * pointIn.getY() + mat22 * pointIn.getZ() + mat23)); } else { transform(pointIn); } }
public Point3f[] getPointCloud() { int numberOfPoints = flatPoints.length/3; Point3f[] points = new Point3f[numberOfPoints]; for(int i = 0; i < numberOfPoints; i++) { Point3f point = new Point3f(); point.setX(flatPoints[3 * i]); point.setY(flatPoints[3 * i + 1]); point.setZ(flatPoints[3 * i + 2]); points[i] = point; } return points; }
public static Point3f generateRandomPoint3f(Random random, Point3f min, Point3f max) { float x = generateRandomFloatInRange(random, min.getX(), max.getX()); float y = generateRandomFloatInRange(random, min.getY(), max.getY()); float z = generateRandomFloatInRange(random, min.getZ(), max.getZ()); return new Point3f(x, y, z); }
private static Point3f[] makePoint3fArrayFromPoint3dArray(Point3d[] pPoints) { Point3f[] points3f = new Point3f[pPoints.length]; int i = 0; for (Point3d point3d : pPoints) { points3f[i++] = new Point3f(point3d); } return points3f; } }
/** * Multiply a 3x3 matrix by a 3x1 vector. Since result is stored in vector, the matrix must be 3x3. * @param matrix * @param point */ public static void mult(DenseMatrix64F matrix, Point3f point) { if (matrix.numCols != 3 || matrix.numRows != 3) { throw new RuntimeException("Improperly sized matrices."); } double x = point.getX(); double y = point.getY(); double z = point.getZ(); point.setX((float) (matrix.get(0, 0) * x + matrix.get(0, 1) * y + matrix.get(0, 2) * z)); point.setY((float) (matrix.get(1, 0) * x + matrix.get(1, 1) * y + matrix.get(1, 2) * z)); point.setZ((float) (matrix.get(2, 0) * x + matrix.get(2, 1) * y + matrix.get(2, 2) * z)); }