/** Compute the area of the triangle defined by 3 points in 3D space, returning half of the length of the vector resulting from the cross product of vectors p1p2 and p1p3. */ static public final double measureArea(final Point3f p1, final Point3f p2, final Point3f p3) { // Distance from p1 to line p2-p3, times length of line p2-p3, divided by 2: return 0.5 * M.distancePointToLine(p1.x, p1.y, p1.z, p2.x, p2.y, p2.z, p3.x, p3.y, p3.z) * p2.distance(p3); }
/** * Computes the length of the curve at a given point between * key frames. * @param u specifies the point between keyframes where 0 <= u <= 1. */ public float computeLength (float u) { float result = 0f; // if linear interpolation if (linear == 1) { result = u*keyFrame[2].position.distance(keyFrame[1].position); } else { // Need to transform domain [0,u] to [-1,1]. If 0 <= x <= u // and -1 <= t <= 1, then x = u*(t+1)/2. int degree = 5; for (int i = 0; i < degree; i++) result += (float)modCoeff[i]*computeSpeed(u*(float)modRoot[i]); result *= u; } return result; }
/** * Computes the length of the curve at a given point between * key frames. * @param u specifies the point between keyframes where 0 <= u <= 1. */ public float computeLength (float u) { float result = 0f; // if linear interpolation if (linear == 1) { result = u*keyFrame[2].position.distance(keyFrame[1].position); } else { // Need to transform domain [0,u] to [-1,1]. If 0 <= x <= u // and -1 <= t <= 1, then x = u*(t+1)/2. int degree = 5; for (int i = 0; i < degree; i++) result += (float)modCoeff[i]*computeSpeed(u*(float)modRoot[i]); result *= u; } return result; }
volume += M.volumeOfTruncatedCone(r, last_r, p.distance(last_p));
private static Point3f[] makeVertices(final Point3f from, final Point3f to, final float r, final int parallels) { final Point3f[] p = new Point3f[parallels + 2]; p[0] = new Point3f(from); p[1] = new Point3f(to); for (int i = 0; i < parallels; i++) { final double a = (i - 6) * (2 * Math.PI) / 12; final double c = r * Math.cos(a); final double s = r * Math.sin(a); p[i + 2] = new Point3f((float) c, (float) s, 0); } final Matrix4f ry = new Matrix4f(); final float ay = (float) Math.atan2((to.x - from.x), (to.z - from.z)); ry.rotY(ay); final Matrix4f rx = new Matrix4f(); final float ax = -(float) Math.asin((to.y - from.y) / from.distance(to)); rx.rotX(ax); rx.mul(ry, rx); for (int i = 2; i < p.length; i++) { final Point3f pi = p[i]; rx.transform(pi); pi.add(from); } return p; }
distanceSourceToCenterEar = workingPosition.distance(workingCenterEar); distanceSourceToRightEar = workingPosition.distance(xformRightEar); distanceSourceToLeftEar = workingPosition.distance(xformLeftEar); distanceBetweenEars = xformRightEar.distance(xformLeftEar); if (debugFlag) debugPrint(" distance from left,right ears to source: = (" +
xformPosition = positions[currentIndex]; xformCenterEar = centerEars[currentIndex]; distanceSourceToHead = xformPosition.distance(xformCenterEar); lastDistanceSourceToHead = lastXformPosition.distance(lastXformCenterEar); if (dopplerFlag) { debugPrint("JSPositionalSample.calculateDoppler - distances: " + averagedSoundDistances += positions[i+1].distance(positions[i]); averagedEarsDistances += centerEars[i+1].distance(centerEars[i]); debugPrint(" " + "soundPosition delta = " + xformPosition.distance(lastXformPosition)); debugPrint(" " + "soundVelocity = " + soundVelocity); debugPrint(" " + "headPosition delta = " + xformCenterEar.distance(lastXformCenterEar)); debugPrint(" " + "headVelocity = " + headVelocity);
final float tickSize, final boolean noTicks) final float lineLength = start.distance(end); final int nTicks = (int) Math.floor((lineLength - first) / tickDistance) + 1;
viewPosition.y = (float)((ViewPlatformRetained)vp.retained).schedSphere.center.y; viewPosition.z = (float)((ViewPlatformRetained)vp.retained).schedSphere.center.z; viewDistance = center.distance( viewPosition);