private void computePlaneEq(Point4d p1, Point4d p2, Point4d p3, Point4d p4, Vector4d planeEq) { tVec1.x = p3.x - p1.x; tVec1.y = p3.y - p1.y; tVec1.z = p3.z - p1.z; tVec2.x = p2.x - p1.x; tVec2.y = p2.y - p1.y; tVec2.z = p2.z - p1.z; tVec3.cross(tVec2, tVec1); tVec3.normalize(); planeEq.x = tVec3.x; planeEq.y = tVec3.y; planeEq.z = tVec3.z; planeEq.w = -(planeEq.x * p1.x + planeEq.y * p1.y + planeEq.z * p1.z); }
@Override PickShape transform(Transform3D t3d) { PickConeSegment newPCS = new PickConeSegment(); newPCS.origin.x = origin.x; newPCS.origin.y = origin.y; newPCS.origin.z = origin.z; newPCS.spreadAngle = spreadAngle; newPCS.end.x = end.x; newPCS.end.y = end.y; newPCS.end.z = end.z; t3d.transform(newPCS.origin); t3d.transform(newPCS.end); newPCS.direction.x = newPCS.end.x - newPCS.origin.x; newPCS.direction.y = newPCS.end.y - newPCS.origin.y; newPCS.direction.z = newPCS.end.z - newPCS.origin.z; newPCS.direction.normalize(); return newPCS; } }
@Override PickShape transform(Transform3D t3d) { Point3d end = new Point3d(); PickRay newPR = new PickRay(origin, direction); end.x = origin.x + direction.x; end.y = origin.y + direction.y; end.z = origin.z + direction.z; t3d.transform(newPR.origin); t3d.transform(end); newPR.direction.x = end.x - newPR.origin.x; newPR.direction.y = end.y - newPR.origin.y; newPR.direction.z = end.z - newPR.origin.z; newPR.direction.normalize(); return newPR; }
@Override PickShape transform(Transform3D t3d) { PickCylinderSegment newPCS = new PickCylinderSegment(); newPCS.origin.x = origin.x; newPCS.origin.y = origin.y; newPCS.origin.z = origin.z; newPCS.radius = radius * t3d.getScale(); newPCS.end.x = end.x; newPCS.end.y = end.y; newPCS.end.z = end.z; t3d.transform(newPCS.origin); t3d.transform(newPCS.end); newPCS.direction.x = newPCS.end.x - newPCS.origin.x; newPCS.direction.y = newPCS.end.y - newPCS.origin.y; newPCS.direction.z = newPCS.end.z - newPCS.origin.z; newPCS.direction.normalize(); return newPCS; }
@Override PickShape transform(Transform3D t3d) { Point3d end = new Point3d(); PickConeRay newPCR = new PickConeRay(); newPCR.origin.x = origin.x; newPCR.origin.y = origin.y; newPCR.origin.z = origin.z; newPCR.spreadAngle = spreadAngle; end.x = origin.x + direction.x; end.y = origin.y + direction.y; end.z = origin.z + direction.z; t3d.transform(newPCR.origin); t3d.transform(end); newPCR.direction.x = end.x - newPCR.origin.x; newPCR.direction.y = end.y - newPCR.origin.y; newPCR.direction.z = end.z - newPCR.origin.z; newPCR.direction.normalize(); return newPCR; } }
/** * Transforms the y-direction of the image plate to a normalized vector * representing this direction in the vworld space. * * @param v Vector3d in which the result in stored. * @param ipToVWorld the image plate to vworld transformation. */ public void getYDir(final Vector3d v, final Transform3D ipToVWorld) { origin.set(0, 0, 0); oneInY.set(0, 1, 0); ipToVWorld.transform(oneInY); ipToVWorld.transform(origin); v.sub(oneInY, origin); v.normalize(); }
/** * Transforms the z-direction of the image plate to a normalized vector * representing this direction in the vworld space. * * @param v Vector3d in which the result in stored. * @param ipToVWorld the image plate to vworld transformation. */ public void getZDir(final Vector3d v, final Transform3D ipToVWorld) { origin.set(0, 0, 0); oneInZ.set(0, 0, 1); ipToVWorld.transform(oneInZ); ipToVWorld.transform(origin); v.sub(origin, oneInZ); v.normalize(); }
/** * Transforms the x-direction of the image plate to a normalized vector * representing this direction in the vworld space. * * @param v Vector3d in which the result in stored. * @param ipToVWorld the image plate to vworld transformation. */ public void getXDir(final Vector3d v, final Transform3D ipToVWorld) { origin.set(0, 0, 0); oneInX.set(1, 0, 0); ipToVWorld.transform(oneInX); ipToVWorld.transform(origin); v.sub(oneInX, origin); v.normalize(); }
/** * Calculates from the specified axis in image plate coordinate system the * corresponding vector in the vworld coordinate system. */ public void getAxisVworld(final Vector3d axis, final Vector3d axisVW) { canvas.getImagePlateToVworld(ipToVWorld); origin.set(0, 0, 0); oneInX.set(axis); ipToVWorld.transform(oneInX); ipToVWorld.transform(origin); axisVW.sub(oneInX, origin); axisVW.normalize(); }
@Override public void run() { if (DisplayCanvas.this.srcRect.contains(target)) { // reached destination if (display.getLayer() != target_layer) display.toLayer(target_layer); playHighlight(target); cancelAnimation(sf[0]); } else { setSrcRect(srcRect.x + (int)v.x, srcRect.y + (int)v.y, srcRect.width, srcRect.height); // which layer? if (start_layer != target_layer) { final int cx = srcRect.x + srcRect.width/2; final int cy = srcRect.y + srcRect.height/2; final double dist = Math.sqrt(Math.pow((cx - ox)*pixelWidth, 2) + Math.pow((cy - oy)*pixelHeight, 2) + Math.pow((display.getLayer().getZ() - start_layer.getZ()) * pixelWidth, 2)); final Vector3d gg = new Vector3d(g); gg.normalize(); gg.scale((float)dist); final Layer la = display.getLayerSet().getNearestLayer(start_layer.getZ() + gg.z/pixelWidth); if (la != display.getLayer()) { display.toLayer(la); } } display.repaintAll2(); } } }, 0, 50, TimeUnit.MILLISECONDS);
@Override PickShape transform(Transform3D t3d) { PickCylinderRay newPCR = new PickCylinderRay(); Point3d end = new Point3d(); /* System.err.println("t3d : "); System.err.println(t3d); */ newPCR.origin.x = origin.x; newPCR.origin.y = origin.y; newPCR.origin.z = origin.z; newPCR.radius = radius * t3d.getScale(); end.x = origin.x + direction.x; end.y = origin.y + direction.y; end.z = origin.z + direction.z; t3d.transform(newPCR.origin); t3d.transform(end); newPCR.direction.x = end.x - newPCR.origin.x; newPCR.direction.y = end.y - newPCR.origin.y; newPCR.direction.z = end.z - newPCR.origin.z; newPCR.direction.normalize(); return newPCR; }
ry[n_new_points-1] - ry[0], rz[n_new_points-1] - rz[0]); v.normalize(); v.scale(segment_length); for (int i=1; i<n_new_points-1; i++) {
normal.normalize();
motion.transform(mousePosn); mouseVec.sub(mousePosn, eyePosn); mouseVec.normalize();
normal.normalize();
normal.normalize();
normal.normalize();
motion.transform(mousePosn); mouseVec.sub(mousePosn, eyePosn); mouseVec.normalize();
motion.transform(mousePosn); mouseVec.sub(mousePosn, eyePosn); mouseVec.normalize();
r = (float) p1.distance(centerInVWorld); vec.sub(centerInVWorld, eyePtInVWorld); vec.normalize(); vec.scale(-r); pickPtInVWorld.add(centerInVWorld, vec);