/** * Constructs a PickPoint using a default point. * The point is initialized to (0,0,0). */ public PickPoint() { location = new Point3d(); }
/** * Returns the distance from the intersectPoint for item and * origin. */ double getDistanceFrom( Point3d origin ) { return intersectPoint.distance(origin); }
/** * Retrieves the actual position of the center eye * in image-plate * coordinates and copies that value into the object provided. * The center eye is the fictional eye half-way between the left and * right eye. * This value is a function of the windowEyepointPolicy, the tracking * enable flag, and the manual right and left eye positions. * @param position the object that will receive the position * @see #setMonoscopicViewPolicy */ // XXXX: This might not make sense for field-sequential HMD. public void getCenterEyeInImagePlate(Point3d position) { if (canvasViewCache != null) { synchronized(canvasViewCache) { position.set(canvasViewCache.getCenterEyeInImagePlate()); } } else { Point3d cenEye = new Point3d(); cenEye.add(leftManualEyeInImagePlate, rightManualEyeInImagePlate); cenEye.scale(0.5); position.set(cenEye); } }
@Override void computeCentroid() { Point3d pnt0 = new Point3d(); Point3d pnt1 = new Point3d(); double length; double totallength = 0; int i = ((vertexFormat & GeometryArray.BY_REFERENCE) == 0 ? initialVertexIndex : initialCoordIndex); centroid.x = 0; centroid.y = 0; centroid.z = 0; while (i < validVertexCount) { getVertexData(i++, pnt0); getVertexData(i++, pnt1); length = pnt0.distance(pnt1); centroid.x += (pnt0.x + pnt1.x) * length; centroid.y += (pnt0.y + pnt1.y) * length; centroid.z += (pnt0.z + pnt1.z) * length; totallength += length; } if (totallength != 0.0) { length = 1.0/(2.0 * totallength); centroid.x *= length; centroid.y *= length; centroid.z *= length; } }
public void getMin(final Point3d min) { min.set(Double.MAX_VALUE, Double.MAX_VALUE, Double.MAX_VALUE); final Point3d tmp = new Point3d(); for (final ContentInstant c : contents.values()) { c.getContent().getMin(tmp); if (tmp.x < min.x) min.x = tmp.x; if (tmp.y < min.y) min.y = tmp.y; if (tmp.z < min.z) min.z = tmp.z; } }
/** * Returns the position of this bounding sphere as a point. * @param center a Point to receive the center of the bounding sphere */ @Override public void getCenter(Point3d center) { center.set(this.center); }
/** * Make sure that the average center of all contents is visible in the canvas. */ public void addCenterOf(final Iterable<Content> contents) { final Point3d center = new Point3d(); final Point3d tmp = new Point3d(); int counter = 0; for (final Content c : contents) { final Transform3D localToVworld = new Transform3D(); c.getContent().getLocalToVworld(localToVworld); c.getContent().getMin(tmp); center.add(tmp); c.getContent().getMax(tmp); center.add(tmp); counter += 2; } center.x /= counter; center.y /= counter; center.z /= counter; add(center); }
boolean intersect_ptope_ptope( BoundingPolytope poly1, BoundingPolytope poly2) { boolean intersect; Point3d p = new Point3d(); Point3d g = new Point3d(); Point3d gnew = new Point3d(); Point3d pnew = new Point3d(); double prevDist = p.distanceSquared(g); double dist; dist = p.distanceSquared(gnew); g.set(gnew); intersect = closest_point( g, poly2.planes, pnew ); if (debug) { g.set(gnew); break; dist = pnew.distanceSquared(g); p.set(pnew); if( !intersect ) { intersect = closest_point( p, poly1.planes, gnew ); p.set(pnew); break;
boolean intersect_ptope_sphere( BoundingPolytope polyTope, BoundingSphere sphere) { Point3d p = new Point3d(); boolean inside; if (p.distanceSquared( sphere.center) > sphere.radius*sphere.radius){ if (debug) {
float r = 0, dD = 0; if (p != null) { pickPtInVWorld.set(p); localToVWorld.transform(pickPtInVWorld); r = (float) pickPtInVWorld.distance(centerInVWorld); r = (float) p1.distance(centerInVWorld); vec.sub(centerInVWorld, eyePtInVWorld); vec.normalize(); vec.scale(-r); pickPtInVWorld.add(centerInVWorld, vec); dD = (float) pickPtInVWorld.distance(eyePtInVWorld); final float dd = (float) p1.distance(eyePtInVWorld); final float dx = (float) p1.distance(p2); final float dy = (float) p1.distance(p3);
/** * Translates the view suitable to a mouse movement by dxPix and dyPix on the * canvas. * * @param dxPix * @param dyPix */ public void translateXY(final int dxPix, final int dyPix) { origin.set(0, 0, 0); canvas.getCenterEyeInImagePlate(eyePos); canvas.getImagePlateToVworld(ipToVWorld); ipToVWorld.transform(eyePos); final float dD = (float) eyePos.distance(origin); originInCanvas(originInCanvas); canvas.getPixelLocationInImagePlate(originInCanvas, originOnIp); ipToVWorld.transform(originOnIp); final float dd = (float) eyePos.distance(originOnIp); canvas.getPixelLocationInImagePlate((int) Math.round(originInCanvas.x + 1), (int) Math.round(originInCanvas.y), currentPtOnIp); ipToVWorld.transform(currentPtOnIp); final float dx = (float) originOnIp.distance(currentPtOnIp); canvas.getPixelLocationInImagePlate((int) Math.round(originInCanvas.x), (int) Math.round(originInCanvas.y + 1), currentPtOnIp); ipToVWorld.transform(currentPtOnIp); final float dy = (float) originOnIp.distance(currentPtOnIp); final float dX = dx * dxPix * dD / dd; final float dY = dy * dyPix * dD / dd; translateXY(dX, dY); }
private void cacheEyePosCoexistenceRelative(Point3d leftManualEyeInCoexistence, Point3d rightManualEyeInCoexistence) { tPnt1.set(leftManualEyeInCoexistence); viewCache.coexistenceToTrackerBase.transform(tPnt1); screenViewCache.trackerBaseToImagePlate.transform(tPnt1); tPnt1.add(coexistenceCenter); tPnt2.set(rightManualEyeInCoexistence); viewCache.coexistenceToTrackerBase.transform(tPnt2); screenViewCache.trackerBaseToImagePlate.transform(tPnt2); tPnt2.add(coexistenceCenter); cacheEyePosScreenRelative(tPnt1, tPnt2); }
private void calcDistSqFromEye(final Point3d eyePosInLocal) { distSqFromEye = eyePosInLocal.distanceSquared(midp); }
void translate(final int xNew, final int yNew) { if (content == null || content.isLocked()) return; final int dx = xNew - xLast; final int dy = yNew - yLast; translateTG.getTransform(translateOld); v1.scale(dx, translationPerDx); v2.scale(-dy, translationPerDy); translation.add(v1, v2); translateNew.set(translation); translateNew.mul(translateOld); translateTG.setTransform(translateNew); transformChanged(BehaviorCallback.TRANSLATE, translateNew); xLast = xNew; yLast = yNew; }
/** * Indicates whether the specified <code>bounds</code> object is * equal to this BoundingSphere object. They are equal if the * specified <code>bounds</code> object is an instance of * BoundingSphere and all of the data * members of <code>bounds</code> are equal to the corresponding * data members in this BoundingSphere. * @param bounds the object with which the comparison is made. * @return true if this BoundingSphere is equal to <code>bounds</code>; * otherwise false * * @since Java 3D 1.2 */ @Override public boolean equals(Object bounds) { try { BoundingSphere sphere = (BoundingSphere)bounds; return (center.equals(sphere.center) && radius == sphere.radius); } catch (NullPointerException e) { return false; } catch (ClassCastException e) { return false; } }