/** * Calculates the distance between the viewer's eye and the origin in the * vworld space. * * @return */ public double distanceEyeOrigin() { origin.set(0, 0, 0); return distanceEyeTo(origin); }
/** * Translates the view by the specified distances along the x, y and z * direction (of the vworld). * * @param v The distances in x, y and z direction, given in vworld dimensions. */ public void translate(final Vector3d v) { getTranslateTranslation(tmpV); tmpV.sub(v); translateXform.set(tmpV); translateTG.setTransform(translateXform); transformChanged(BehaviorCallback.TRANSLATE, translateXform); }
/** * Translates the view by the specified distances along the x and y direction * (of the image plate). * * @param dx The distance in x direction, given in vworld dimensions. * @param dy The distance in y direction, given in vworld dimensions. */ public void translateXY(final double dx, final double dy) { getXDir(xDir); getYDir(yDir); xDir.scale(dx); yDir.scale(dy); xDir.add(yDir); translate(xDir); }
/** * Rotates the view around the center of view by the specified angles around * the x and y axis (of the image plate). * * @param angleX The angle (in rad) around the x-axis * @param angleY The angle (in rad) around the y-axis */ public void rotateXY(final double angleX, final double angleY) { getXDir(xDir); aa.set(xDir, angleX); tmp.set(aa); getYDir(yDir); aa2.set(yDir, angleY); tmp2.set(aa2); // first apply the old transform rotationTG.getTransform(rotationXform); // rotate x rotationXform.mul(tmp, rotationXform); // rotate y rotationXform.mul(tmp2, rotationXform); rotationTG.setTransform(rotationXform); transformChanged(BehaviorCallback.ROTATE, rotationXform); }
/** * Rotates the view around the center of view by the specified angle around * the given axis (of the image plate). * * @param axis The axis of rotation (in image plate coordinate system) * @param angle The angle (in rad) around the given axis */ public void rotate(final Vector3d axis, final double angle) { final Vector3d axisVW = new Vector3d(); getAxisVworld(axis, axisVW); aa.set(axisVW, angle); tmp.set(aa); // first apply the old transform rotationTG.getTransform(rotationXform); // rotate rotationXform.mul(tmp, rotationXform); rotationTG.setTransform(rotationXform); transformChanged(BehaviorCallback.ROTATE, rotationXform); }
/** * 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); }
final float dD = (float) eyePos.distance(origin); originInCanvas(originInCanvas); canvas.getPixelLocationInImagePlate(originInCanvas, originOnIp); ipToVWorld.transform(originOnIp); univ.getViewer().getView().setBackClipDistance(5 * distance); univ.getViewer().getView().setFrontClipDistance(5 * distance / 100); transformChanged(BehaviorCallback.TRANSLATE, zoomXform);
/** * Rotates the view around the global rotation center by the specified angle * around the x axis (of the image plate). * * @param angle The angle (in rad) around the x-axis */ public void rotateX(final double angle) { xDir.set(1, 0, 0); rotate(xDir, angle); }
/** * Center the view at the given point. * * @param center */ public void centerAt(final Point3d center) { // set the center transformation to the translation given by // the specified point centerV.set(center.x, center.y, center.z); centerXform.set(centerV); centerTG.setTransform(centerXform); // set the global translation to identity centerXform.setIdentity(); translateTG.setTransform(centerXform); transformChanged(BehaviorCallback.TRANSLATE, centerXform); // update rotation center rotCenter.set(center); }
/** * 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. */ public void getZDir(final Vector3d v) { canvas.getImagePlateToVworld(ipToVWorld); getZDir(v, ipToVWorld); }
/** * 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. */ public void getXDir(final Vector3d v) { canvas.getImagePlateToVworld(ipToVWorld); getXDir(v, ipToVWorld); }
/** * Stores the y-direction in the image plate coordinate system, i.e. the * direction towards the user, in the given Vector3d. * * @param v Vector3d in which the result in stored. */ public void getYDir(final Vector3d v) { canvas.getImagePlateToVworld(ipToVWorld); getYDir(v, ipToVWorld); }
/** * Stores the canvas position of the origin of the vworld in the specified * Point2d. * * @param out */ public void originInCanvas(final Point2d out) { origin.set(0, 0, 0); pointInCanvas(origin, out); }
/** * Rotates the view around the global rotation center by the specified angle * around the z axis (of the image plate). * * @param angle The angle (in rad) around the z-axis */ public void rotateZ(final double angle) { zDir.set(0, 0, 1); rotate(zDir, angle); }
/** * Moves the view back (i.e. in the z-direction of the image plate) to the * specified distance. * * @param distance */ public void zoomTo(final double distance) { zDir.set(0, 0, 1); zDir.scale(distance); zoomXform.set(zDir); zoomTG.setTransform(zoomXform); univ.getViewer().getView().setBackClipDistance(5 * distance); univ.getViewer().getView().setFrontClipDistance(5 * distance / 100); transformChanged(BehaviorCallback.TRANSLATE, zoomXform); }
/** * Rotates the view around the global rotation center by the specified angle * around the y axis (of the image plate). * * @param angle The angle (in rad) around the y-axis */ public void rotateY(final double angle) { yDir.set(0, 1, 0); rotate(yDir, angle); }