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); }
private boolean projectToPlane(Vector3d projVec, Vector3d planeVec) { double dis = planeVec.dot(projVec); projVec.x = projVec.x - planeVec.x*dis; projVec.y = projVec.y - planeVec.y*dis; projVec.z = projVec.z - planeVec.z*dis; double length = projVec.length(); if (length < EPSILON) { // projVec is parallel to planeVec return false; } projVec.scale(1 / length); return true; }
private boolean projectToPlane(Vector3d projVec, Vector3d planeVec) { double dis = planeVec.dot(projVec); projVec.x = projVec.x - planeVec.x*dis; projVec.y = projVec.y - planeVec.y*dis; projVec.z = projVec.z - planeVec.z*dis; double length = projVec.length(); if (length < EPSILON) { return false; } projVec.scale(1 / length); return true; }
/** * 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); }
@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);
/** * 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); }
/** 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); }
rz[n_new_points-1] - rz[0]); v.normalize(); v.scale(segment_length); for (int i=1; i<n_new_points-1; i++) { rx[i] = rx[0] + v.x * i;
zDir.scale(units * factor);
v3d.scale(frameTime * currSpeed) ; translateTransform(viewPlatformToVworld, v3d) ; targetTG.setTransform(viewPlatformToVworld) ;
frameTime = (e.getTime() - e.getLastTime()) / 1e9 ; v3d.scale(frameTime * speedScaled * length) ;
vector.scale(-1.0); // vector to translate back
dv.scale(deltaTime, a); navVec.add(dv);
vector.scale(-1.0); // vector to translate back