@Override public ArrayList<Point3D> getVertices() { ArrayList<Point3D> part1 = new ArrayList<Point3D>(); ArrayList<Point3D> part2 = new ArrayList<Point3D>(); ArrayList<Point3D> result = new ArrayList<Point3D>(); part1.add(this.getBlockLocations().get(0)); part1.add(this.getBlockLocations().get(1)); part1.add(this.getBlockLocations().get(2)); part1.add(this.getBlockLocations().get(3)); part2.add(this.getBlockLocations().get(4)); vertices.clear(); setVertices(part1); setVertices(part2); for (Point3D point : vertices) { result.add(point); } vertices.clear(); for (Point3D point : result) { vertices.add(point.add(location)); } return result; }
public double getAngle(Atom a1, Atom a2) { Point3D vertex = new Point3D(coords[0], coords[1], coords[2]); Point3D pA1 = new Point3D(a1.coords[0], a1.coords[1], a1.coords[2]); Point3D pA2 = new Point3D(a2.coords[0], a2.coords[1], a2.coords[2]); return vertex.angle(pA1, pA2); }
AxisLineOld(double radius, double height, Rotate rotate, Point3D offset) { super(radius, height); this.rotate = rotate; this.offset = new Translate(offset.getX(), offset.getY(), offset.getZ()); ; this.getTransforms().addAll(this.rotate, this.offset); }
public Point3D unTransform(Point3D p) { try { javafx.geometry.Point3D ta = a.inverseTransform(p.x, p.y, p.z); return new Point3D((float) ta.getX(), (float) ta.getY(), (float) ta.getZ()); } catch (NonInvertibleTransformException ex) { System.out.println("p not invertible " + p); } return p; }
public static final Point3D absoluteSum(final Collection<Point3D> c) { double x = 0d; double y = 0d; double z = 0d; for (Point3D p : c) { x += Math.abs(p.getX()); y += Math.abs(p.getY()); z += Math.abs(p.getZ()); } return new Point3D(x, y, z); }
private static Point3D getMeshNormal(MeshView mesh) { TriangleMesh tm = (TriangleMesh) mesh.getMesh(); float[] fPoints = new float[tm.getPoints().size()]; tm.getPoints().toArray(fPoints); Point3D BA = new Point3D(fPoints[3] - fPoints[0], fPoints[4] - fPoints[1], fPoints[5] - fPoints[2]); Point3D CA = new Point3D(fPoints[6] - fPoints[0], fPoints[7] - fPoints[1], fPoints[8] - fPoints[2]); Point3D normal = BA.crossProduct(CA); Affine a = new Affine(mesh.getTransforms().get(0)); return a.transform(normal.normalize()); }
/** * Returns a String containing all Box3D values for saving to a data file. The String is processed * by the Box3D(String) constructor to recreate a Box3D object when reading a saved data file. * * @return String capturing all Box field values */ public String outString() { String ms = null; if (m != null) { if (m.getDiffuseColor() != null) { ms = m.getDiffuseColor().toString(); } if (m.getSpecularColor() != null) { ms = ms.concat(", " + m.getSpecularColor().toString()); } } return "Box: " + p.getX() + ", " + p.getY() + ", " + p.getZ() + ", " + width + ", " + height + ", " + depth + ", " + xr + ", " + yr + ", " + zr + ", " + dm + ", " + cf + ", " + ms; }
/** * Creates a new Arrow3D object scaled by the value t * * @param t double scalar value to multiply Arrow line components * @return Arrow3D scaled by t */ public Arrow3D multiply(double t) { double x2 = t * (p2.getX() - p1.getX()) + p1.getX(); double y2 = t * (p2.getY() - p1.getY()) + p1.getY(); double z2 = t * (p2.getZ() - p1.getZ()) + p1.getZ(); Point3D newp = new Point3D(x2, y2, z2); Arrow3D newa = new Arrow3D(p1, newp); newa.setMaterial(m); newa.setArrowRadius(arrowRadius); return newa; }
private void selectFocus() { Point3D p = new Point3D(0, 0, 0); Nucleotide n = selectionModel .getItems()[ selectionModel .getSelectedIndices() .get(selectionModel.getSelectedIndices().size() - 1)]; p = p.add(utils.fx3d.computeCenter(n.getNucleotideCoordinates())); p = p.add(utils.fx3d.computeCenter(n.getBaseCoordinates())); p = p.multiply(1 / ((double) 2)); // fx3d.transiteFromTOo(tertiaryRoom.getCamera(), p); tertiaryRoom.setCameraCenter(p); }
private AxisGrid createBasicAxisGrid( Point3D planeVectorXYZ, Point2D tickSeperationXY, Point2D axisLengthXY, double thickness) { AxisGrid tempGrid = new AxisGrid( planeVectorXYZ, tickSeperationXY, axisLengthXY, thickness, tickSeperationXYZ.getX()); return tempGrid; }
/** * Returns a String for printing all Box3D values * * @return String for printing all Box3D field values */ public String toString() { String ms = null; if (m != null) { if (m.getDiffuseColor() != null) { ms = ", m= " + m.getDiffuseColor().toString(); } if (m.getSpecularColor() != null) { ms = ms.concat(", " + m.getSpecularColor().toString()); } } else { ms = ", m= " + m; } return "Box3D: p= " + p.toString() + ", width = " + width + ", height= " + height + ", depth= " + depth + ", xr= " + xr + ", yr= " + yr + ", zr= " + zr + ", dm= " + dm + ", cf= " + cf + ", " + ms; }
/** * Rotates the Cell towards the Viewer when it is close to the center. Also mirrors the cells * after they passed the center to keep the Cells correctly visible for the viewer. */ public void applyViewRotation() { if (index < 3) { double angle = index > -3 ? Math.PI / 2 * -index / 3 + Math.PI / 2 : Math.PI; Point3D axis = new Point3D((ul.getX() + ur.getX()) / 2, 0, (ul.getZ() + ur.getZ()) / 2); ul = rotateY(ul, axis, angle); ur = rotateY(ur, axis, angle); ll = rotateY(ll, axis, angle); lr = rotateY(lr, axis, angle); if (reflection != null) { ulReflection = rotateY(ulReflection, axis, angle); urReflection = rotateY(urReflection, axis, angle); } } }
/** * Returns a String for printing all Arrow3D values * * @return String for printing all Arrow3D field values */ public String toString() { String ms = null; if (m != null) { if (m.getDiffuseColor() != null) { ms = ", m= " + m.getDiffuseColor().toString(); } if (m.getSpecularColor() != null) { ms = ms.concat(", " + m.getSpecularColor().toString()); } } else { ms = ", m= " + m; } return "Arrow3D: p1= " + p1.toString() + ", p2= " + p2.toString() + " arrowRadius= " + arrowRadius + ms; }
static int distance(Point3D first, Point3D second) { return (int) (Math.sqrt( Math.pow(second.getX() - first.getX(), 2) + Math.pow(second.getY() - first.getY(), 2)) + Math.pow(second.getZ() - first.getZ(), 2)); }
/** * Returns a String containing all Arrow3D values for saving to a data file. The String is * processed by the Arrow3D(String) constructor to recreate a Arrow3D object when reading a saved * data file. * * @return String capturing all Arrow3D field values */ public String outString() { String ms = null; if (m != null) { if (m.getDiffuseColor() != null) { ms = m.getDiffuseColor().toString(); } if (m.getSpecularColor() != null) { ms = ms.concat(", " + m.getSpecularColor().toString()); } } return "Arrow: " + p1.getX() + ", " + p1.getY() + ", " + p1.getZ() + ", " + p2.getX() + ", " + p2.getY() + ", " + p2.getZ() + ", " + arrowRadius + ", " + ms; }
public static final Point3D minus(final Point3D p, final Point3D q) { return Point3DBuilder.create() .x(p.getX() - q.getX()) .y(p.getY() - q.getY()) .z(p.getZ() - q.getZ()) .build(); }
/** * Provides the Arrow3D line mid-point (in user coordinate space) * * @return midpoint Point3D location of the Arrow midpoint */ public Point3D midpoint() { double x, y, z; x = (p1.getX() + p2.getX()) / 2.0; y = (p1.getY() + p2.getY()) / 2.0; z = (p1.getZ() + p2.getZ()) / 2.0; return new Point3D(x, y, z); }
public static final double pointSegmentDistance( final Point3D p, final Point3D q1, final Point3D q2) { if (p.equals(q1) || p.equals(q2)) return 0; if (q1.equals(q2)) return p.distance(q1); // line segment: g = q1 + t * (q2 - q1), 0 <= t <= 1 final Point3D q = minus(q2, q1); // projection on line: P(p,g) = q1 + t * q final double t = scalarProduct(minus(p, q1), q) / scalarProduct(q, q); if (t < 0) return p.distance(q1); else if (t > 1) return p.distance(q2); else return p.distance(plus(q1, multiply(t, q))); }
public static String getRightRotation(Point3D p, String selFaces) { double radius = p.magnitude(); double angle = Math.atan2(p.getY(), p.getX()); String face = ""; if (radius >= radMinimum && selFaces.contains("-") && selFaces.split("-").length == 2) { String[] faces = selFaces.split("-"); // select rotation if p.getX>p.getY if (-Math.PI / 4d <= angle && angle < Math.PI / 4d) { // X face = faces[0]; } else if (Math.PI / 4d <= angle && angle < 3d * Math.PI / 4d) { // Y face = faces[1]; } else if ((3d * Math.PI / 4d <= angle && angle <= Math.PI) || (-Math.PI <= angle && angle < -3d * Math.PI / 4d)) { // -X face = reverseRotation(faces[0]); } else { // -Y face = reverseRotation(faces[1]); } System.out.println("face: " + face); } else if (!face.isEmpty() && radius < radMinimum) { // reset previous face face = ""; } return face; }
public void SetTickSeperationXYZ(Point3D newTickSpeperation) { this.tickSeperationXYZ = newTickSpeperation; xAxisGrid.setTickSeperationXY(new Point2D(tickSeperationXYZ.getY(), tickSeperationXYZ.getZ())); yAxisGrid.setTickSeperationXY(new Point2D(tickSeperationXYZ.getZ(), tickSeperationXYZ.getX())); zAxisGrid.setTickSeperationXY(new Point2D(tickSeperationXYZ.getX(), tickSeperationXYZ.getY())); }
/** * Provides the projected Arrow3D angle between xz axes * * @return theta Double value of angle of projected xz arrow line */ public double theta() { // Relocate line start point to origin double x = p2.getX() - p1.getX(); double y = p2.getY() - p1.getY(); double z = p2.getZ() - p1.getZ(); // Compute theta return Math.atan2(z, x); }
public void checkScale(Point3D newMaxLengthXYZ) { // yz xAxisGrid.updateGrid(new Point2D(newMaxLengthXYZ.getY(), newMaxLengthXYZ.getZ())); // zx yAxisGrid.updateGrid(new Point2D(newMaxLengthXYZ.getZ(), newMaxLengthXYZ.getX())); // xy zAxisGrid.updateGrid(new Point2D(newMaxLengthXYZ.getX(), newMaxLengthXYZ.getY())); reDeclareLabels(); }
/** * Provides the Arrow3D angle with y axis * * @return phi Double value of angle of arrow line to y axis */ public double phi() { double x, y, z; // Relocate line start point to origin x = p2.getX() - p1.getX(); y = p2.getY() - p1.getY(); z = p2.getZ() - p1.getZ(); // Compute phi double rho = Math.sqrt(x * x + y * y + z * z); return Math.acos(-y / rho); }
private Cylinder createScaleAxis(Point3D direction, double length, double thickness) { // generate the cylinder // default position is centered on (0,0,0) in direction (0,1,0) Cylinder tempBox = new Cylinder(thickness, length * 1.05d); // rotate the axis to face the right direction // in this case the axis tempBox.getTransforms().add(Vector3DUtil.rotateVector(new Point3D(0, 1, 0), direction)); tempBox.getTransforms().add(new Translate(0, (length * 1.05d) / 2, 0)); // create the material to colour the axis PhongMaterial mat = new PhongMaterial(); mat.setDiffuseColor(new Color(direction.getX(), direction.getY(), direction.getZ(), 1)); mat.setSpecularColor(new Color(direction.getX(), direction.getY(), direction.getZ(), 1)); // set the material -> ie colour the axis tempBox.setMaterial(mat); return tempBox; }
private Point3D transform(double x, double y, double z) { javafx.geometry.Point3D ta = a.transform(x, y, z); return new Point3D((float) ta.getX(), (float) ta.getY(), (float) ta.getZ()); }
public AxisGroup( Point3D origin, Point3D maxLength, double axisThickness, Point3D tickSeperationXYZ) { this.tickSeperationXYZ = tickSeperationXYZ; // create axis grids // yz plane this.getChildren() .add( xAxisGrid = createBasicAxisGrid( new Point3D(1, 0, 0), new Point2D(tickSeperationXYZ.getY(), tickSeperationXYZ.getZ()), new Point2D(maxLength.getY(), maxLength.getZ()), axisThickness / 10)); // zx plane this.getChildren() .add( yAxisGrid = createBasicAxisGrid( new Point3D(0, 1, 0), new Point2D(tickSeperationXYZ.getZ(), tickSeperationXYZ.getX()), new Point2D(maxLength.getZ(), maxLength.getX()), axisThickness / 10)); // xy plane this.getChildren() .add( zAxisGrid = createBasicAxisGrid( new Point3D(0, 0, 1), new Point2D(tickSeperationXYZ.getX(), tickSeperationXYZ.getY()), new Point2D(maxLength.getX(), maxLength.getY()), axisThickness / 10)); }
private static Point2D project(Point3D p, double viewDistance, double fov, double cw, double ch) { return new Point2D( p.getX() * fov / (p.getZ() + viewDistance) + cw, p.getY() * fov / (p.getZ() + viewDistance) + ch); }
private static Point3D rotateY(Point3D p, Point3D axis, double radians) { Point3D input = new Point3D(p.getX() - axis.getX(), p.getY() - axis.getY(), p.getZ() - axis.getZ()); return new Point3D( input.getZ() * Math.sin(radians) + input.getX() * Math.cos(radians) + axis.getX(), input.getY() + axis.getY(), input.getZ() * Math.cos(radians) - input.getX() * Math.sin(radians) + axis.getZ()); }
private void reDeclareLabels() { xAxisGrid.reDeclareLabels( new Point2D(axisLimitMin.getY(), axisLimitMin.getZ()), new Point2D(axisLimitMax.getY(), axisLimitMax.getZ())); yAxisGrid.reDeclareLabels( new Point2D(axisLimitMin.getZ(), axisLimitMin.getX()), new Point2D(axisLimitMax.getZ(), axisLimitMax.getX())); zAxisGrid.reDeclareLabels( new Point2D(axisLimitMin.getX(), axisLimitMin.getY()), new Point2D(axisLimitMax.getX(), axisLimitMax.getY())); }
private Point3D transform(Point3D p) { javafx.geometry.Point3D ta = a.transform(p.x, p.y, p.z); return new Point3D((float) ta.getX(), (float) ta.getY(), (float) ta.getZ()); }