List of usage examples for javafx.geometry Point3D getZ
public final double getZ()
From source file:be.makercafe.apps.makerbench.editors.GCodeEditor.java
/** * Draws a line in 3D between 2 3D points on the given group. * // w w w. jav a 2 s. c om * @param origin * Origin point * @param target * Target point * @return 3D line (cylinder) between to points */ private Cylinder drawLine3D(Group group, Point3D origin, Point3D target, Material color) { if (color == null) { color = MATERIAL_BLACK; // default to orange } Point3D yAxis = new Point3D(0, 1, 0); Point3D diff = target.subtract(origin); double height = diff.magnitude(); Point3D mid = target.midpoint(origin); Translate moveToMidpoint = new Translate(mid.getX(), mid.getY(), mid.getZ()); Point3D axisOfRotation = diff.crossProduct(yAxis); double angle = Math.acos(diff.normalize().dotProduct(yAxis)); Rotate rotateAroundCenter = new Rotate(-Math.toDegrees(angle), axisOfRotation); Cylinder line = new Cylinder(1, height); line.setMaterial(color); line.getTransforms().addAll(moveToMidpoint, rotateAroundCenter); if (group != null) { group.getChildren().add(line); } return line; }