/** The sum of all vectors, or what is the same: a vector from first to last points. */ public Vector3d sumVector() { return new Vector3d(x[length-1] - x[0], y[length-1] - y[0], z[length-1] - z[0]); }
static public final double distancePointToSegmentSq (final double px, final double py, final double pz, final double lx1, final double ly1, final double lz1, final double lx2, final double ly2, final double lz2) { return distancePointToSegmentSq(new Vector3d(px, py, pz), new Vector3d(lx1, ly1, lz1), new Vector3d(lx2, ly2, lz2)); }
static public final double distancePointToSegment (final double px, final double py, final double pz, final double lx1, final double ly1, final double lz1, final double lx2, final double ly2, final double lz2) { return distancePointToSegment(new Vector3d(px, py, pz), new Vector3d(lx1, ly1, lz1), new Vector3d(lx2, ly2, lz2)); } static public final double distancePointToSegmentSq
/** In 3D */ static public double distancePointToLine(final double px, final double py, final double pz, final double lx1, final double ly1, final double lz1, final double lx2, final double ly2, final double lz2 ) { final double segment_length = new Vector3d(lx2 - lx1, ly2 - ly1, lz2 - lz1).length(); if (0 == segment_length) return 0; final Vector3d cross = new Vector3d(); cross.cross(new Vector3d(px - lx1, py - ly1, pz - lz1), new Vector3d(px - lx2, py - ly2, pz - lz2)); return cross.length() / segment_length; }
private void initHeadToHeadTracker() { // By default the center of the crystal eyes tracker is 20mm down // and 35 mm closer to the screen from the origin of head coordinates // (the center eye). Vector3d v = new Vector3d(0.0, 0.020, 0.035); headToHeadTracker.set(v); } }
/** * Constructs an empty PickCone. * The origin and direction of the cone are * initialized to (0,0,0). The spread angle is initialized * to <code>PI/64</code>. */ public PickCone() { this.origin = new Point3d(); this.direction = new Vector3d(); this.spreadAngle = Math.PI / 64.0; }
/** * Constructs an empty PickRay. The origin and direction of the * ray are initialized to (0,0,0). */ public PickRay() { origin = new Point3d(); direction = new Vector3d(); }
/** * Constructs an infinite ray pick shape from the specified * parameters. * @param origin the origin of the ray. * @param direction the direction of the ray. */ public PickRay(Point3d origin, Vector3d direction) { this.origin = new Point3d(origin); this.direction = new Vector3d(direction); }
/** * Constructs an infinite cylindrical ray pick shape from the specified * parameters. * @param origin the origin of the cylindrical ray. * @param direction the direction of the cylindrical ray. * @param radius the radius of the cylindrical ray. */ public PickCylinderRay(Point3d origin, Vector3d direction, double radius) { this.origin = new Point3d(origin); this.direction = new Vector3d(direction); this.radius = radius; }
/** * Constructs an infinite cone pick shape from the specified * parameters. * @param origin the origin of the cone * @param direction the direction of the cone * @param spreadAngle the spread angle of the cone in radians */ public PickConeRay(Point3d origin, Vector3d direction, double spreadAngle) { this.origin = new Point3d(origin); this.direction = new Vector3d(direction); this.spreadAngle = spreadAngle; }
/** * The floating point distance between the specified * HiResCoord and this HiResCoord. * @param h1 the second HiResCoord */ public double distance(HiResCoord h1) { Vector3d diff = new Vector3d(); hiResDiff( this, h1, diff); return( Math.sqrt( diff.x*diff.x + diff.y*diff.y + diff.z*diff.z)); }
/** * Constructs an empty PickCylinder. * The origin of the cylinder is * initialized to (0,0,0). The radius is initialized * to 0. */ public PickCylinder() { origin = new Point3d(); direction = new Vector3d(); radius = 0.0; }
static boolean intersectRay(Point3d coordinates[], PickRay ray, PickIntersection pi) { Point3d origin = new Point3d(); Vector3d direction = new Vector3d(); boolean result; ray.get (origin, direction); result = intersectRayOrSegment(coordinates, direction, origin, pi, false); return result; }
/** * Constructs a finite cone pick shape from the specified * parameters. * @param origin the origin of the cone * @param end the end of the cone along the direction vector * @param spreadAngle the spread angle of the cone in radians */ public PickConeSegment (Point3d origin, Point3d end, double spreadAngle) { this.origin = new Point3d(origin); this.end = new Point3d(end); this.direction = new Vector3d(); this.spreadAngle = spreadAngle; calcDirection(); // calculate direction, based on start and end }
/** * Rotate the univere so that the user looks in the positive direction of the * x-axis. */ public void rotateToPositiveYZ() { fireTransformationStarted(); getRotationTG().setTransform(new Transform3D()); waitForNextFrame(); rotateUniverse(new Vector3d(1, 0, 0), -Math.PI / 2); }
/** * Rotate the univere so that the user looks in the negative direction of the * x-axis. */ public void rotateToNegativeYZ() { fireTransformationStarted(); getRotationTG().setTransform(new Transform3D()); waitForNextFrame(); rotateUniverse(new Vector3d(0, 1, 0), Math.PI / 2); }
/** * Rotate the univere so that the user looks in the positive direction of the * z-axis. */ public void rotateToPositiveXY() { fireTransformationStarted(); getRotationTG().setTransform(new Transform3D()); waitForNextFrame(); rotateUniverse(new Vector3d(0, 1, 0), Math.PI); }
/** * Rotate the univere so that the user looks in the negative direction of the * y-axis. */ public void rotateToNegativeXZ() { fireTransformationStarted(); getRotationTG().setTransform(new Transform3D()); waitForNextFrame(); rotateUniverse(new Vector3d(1, 0, 0), Math.PI / 2); }
/** * Rotate the univere so that the user looks in the positive direction of the * y-axis. */ public void rotateToPositiveXZ() { fireTransformationStarted(); getRotationTG().setTransform(new Transform3D()); waitForNextFrame(); rotateUniverse(new Vector3d(0, 1, 0), -Math.PI / 2); }
/** * Sets the given matrix to contain the position, orientation, and * scale values for the keyframe */ void setMatrix(Matrix4d mat) { setRotationMatrix(mat); mat.setTranslation(new Vector3d(x, y, z)); Matrix4d m = new Matrix4d(); m.setColumn(0, xScale, 0, 0, 0); // setScale not yet implemented m.setColumn(1, 0, yScale, 0, 0); m.setColumn(2, 0, 0, zScale, 0); m.setColumn(3, 0, 0, 0, 1); mat.mul(m); }