/** * Translates a coordinate system. * * @param transform the coordinate system to be translated * @param translation the vector by which to translate */ protected void translateTransform(Transform3D transform, Vector3d translation) { transform.get(v3dTmp) ; v3dTmp.add(translation) ; transform.setTranslation(v3dTmp) ; }
private void accKeyAdd(Vector3d a, Vector3d da, Vector3d drag, double scaleVel) { /* Scaling of acceleration due to modification keys */ nda.scale(scaleVel, da); /* Addition of sufficent acceleration to counteract drag */ nda.sub(drag); /* Summing into overall acceleration */ a.add(nda); }
/** * 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); }
/** * Transforms the target coordinate system about a center point. * This can be used for rotation and scaling. * * @param target the coordinate system to transform * @param center the center point about which to transform * @param transform the transform to apply */ protected void transformAboutCenter (Transform3D target, Point3d center, Transform3D transform) { // Translate to the center. target.get(v3dTmp) ; v3dTmp.sub(center) ; target.setTranslation(v3dTmp) ; // Apply the transform. target.mul(transform, target) ; // Translate back. target.get(v3dTmp) ; v3dTmp.add(center) ; target.setTranslation(v3dTmp) ; }
if (pre < 0.0) { if (pre + fwdDrag.z * deltaTime < 0.0) a.add(fwdDrag); else a.z -= pre/deltaTime; } else if (pre > 0.0) { if (pre + bwdDrag.z * deltaTime > 0.0) a.add(bwdDrag); else a.z -= pre/deltaTime; if (pre < 0.0) { if (pre + leftDrag.x * deltaTime < 0.0) a.add(leftDrag); else a.x -= pre/deltaTime; } else if (pre > 0.0) { if (pre + rightDrag.x * deltaTime > 0.0) a.add(rightDrag); else a.x -= pre/deltaTime; if (pre < 0.0) { if (pre + downDrag.y * deltaTime < 0.0) a.add(downDrag); else a.y -= pre/deltaTime; } else if (pre > 0.0) { if (pre + upDrag.y * deltaTime > 0.0)
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; }
/** Minimum distance between point v0 and a line segment defined by points v1 and v2. */ static public final double distancePointToSegment(final Vector3d p, final Vector3d v1, final Vector3d v2) { final Vector3d v = new Vector3d(); v.sub(v2, v1); final Vector3d w = new Vector3d(); w.sub(p, v1); final double c1 = w.dot(v); if (c1 <= 0) return distance(p, v1); final double c2 = v.dot(v); if (c2 <= c1) return distance(p, v2); final double b = c1 / c2; final Vector3d pb = new Vector3d(v); pb.scale(b); pb.add(v1); return distance(p, pb); }
static public final double distancePointToSegmentSq(final Vector3d p, final Vector3d v1, final Vector3d v2) { final Vector3d v = new Vector3d(); v.sub(v2, v1); final Vector3d w = new Vector3d(); w.sub(p, v1); final double c1 = w.dot(v); if (c1 <= 0) return distanceSq(p, v1); final double c2 = v.dot(v); if (c2 <= c1) return distanceSq(p, v2); final double b = c1 / c2; final Vector3d pb = new Vector3d(v); pb.scale(b); pb.add(v1); return distanceSq(p, pb); }