private void recomputeLength() { length = 0; for (int i = 1; i < vertices.length; ++i) { length += vertices[i - 1].distance(vertices[i]); } if (cyclic) { // if the first vertex is repeated at the end the distance will be = 0 so it won't affect the result, and if it is not repeated // then it is necessary to add the length between the last and the first vertex length += vertices[vertices.length - 1].distance(vertices[0]); } }
/** * Find the distance from the center of this Bounding Volume to the given * point. * * @param point * The point to get the distance to * @return distance */ public final float distanceTo(Vector3f point) { return center.distance(point); }
public float distanceToEdge(Vector3f point) { return center.distance(point) - radius; }
/** * @return the length of the edge */ public float getLength() { return this.getFirstVertex().distance(this.getSecondVertex()); }
@Override public void simpleUpdate(float tpf) { if (timeToNextPrint > 0f) { timeToNextPrint -= tpf; return; } if (numFalling > 0) { Vector3f fallingLocation = falling[0].getWorldTranslation(); System.out.printf(" falling[0] location(x=%f, z=%f)", fallingLocation.x, fallingLocation.z); /* * If an object is falling vertically, its X- and Z-coordinates * should not change. */ } if (numPendulums > 0) { Vector3f bobLocation = bobs[0].getWorldTranslation(); Vector3f pivotLocation = pivots[0].getWorldTranslation(); float distance = bobLocation.distance(pivotLocation); System.out.printf(" bob[0] distance=%f", distance); /* * If the hinge is working properly, the distance from the * pivot to the bob should remain roughly constant. */ } System.out.println(); timeToNextPrint = 1f; } }
continue; distance = bone.getModelSpacePosition().distance(ikTargets.get(boneName)); if (distance < IKThreshold) { Logger.getLogger(KinematicRagdollControl.class.getSimpleName()).log(Level.FINE, "Distance is close enough");
continue; distance = bone.getModelSpacePosition().distance(ikTargets.get(boneName)); if (distance < IKThreshold) { Logger.getLogger(KinematicRagdollControl.class.getSimpleName()).log(Level.FINE, "Distance is close enough");
if (i != index && i != indexToIgnore) { Vector3f v2 = vertices.get(i); float d = v2.distance(v1); if (d < distance && this.contains(new Edge(index, i, 0, true, temporalMesh)) && (indexToIgnore < 0 || this.contains(new Edge(indexToIgnore, i, 0, true, temporalMesh)))) { result = i;
/** * The method computes the value of a point at the certain relational distance from its beginning. * @param alongRatio * the relative distance along the curve; should be a value between 0 and 1 inclusive; * if the value exceeds the boundaries it is truncated to them * @return computed value along the curve */ public Vector3f getValueAlongCurve(float alongRatio) { alongRatio = FastMath.clamp(alongRatio, 0, 1); Vector3f result = new Vector3f(); float probeLength = this.getLength() * alongRatio; float length = 0; for (int i = 1; i < vertices.length; ++i) { float edgeLength = vertices[i].distance(vertices[i - 1]); if (length + edgeLength > probeLength) { float ratioAlongEdge = (probeLength - length) / edgeLength; return FastMath.interpolateLinear(ratioAlongEdge, vertices[i - 1], vertices[i]); } else if (length + edgeLength == probeLength) { return vertices[i]; } length += edgeLength; } return result; }
double minDistance = Double.MAX_VALUE; for(Vector3f dcv : distinctCrossingVectors) { minDistance = Math.min(minDistance, dcv.distance(cv));
public boolean calculateLod(TerrainPatch terrainPatch, List<Vector3f> locations, HashMap<String, UpdatedTerrainPatch> updates) { if (locations == null || locations.isEmpty()) return false;// no camera yet float distance = getCenterLocation(terrainPatch).distance(locations.get(0));
float distance = patchPos.distance(locations.get(0));
float worldSpaceDist = o.distance(contactPoint);
Triangle hit = new Triangle(); checkTriangles(loc.x, loc.y, workRay, intersection, patch, hit); float distance = worldPickRay.origin.distance(intersection); CollisionResult cr = new CollisionResult(intersection, distance); cr.setGeometry(patch); if (checkTriangles(loc.x, loc.y, workRay, intersection, patch, hit)) { float distance = worldPickRay.origin.distance(intersection); CollisionResult cr = new CollisionResult(intersection, distance); cr.setGeometry(patch); float distance = worldPickRay.origin.distance(intersection); CollisionResult cr = new CollisionResult(intersection, distance); results.addCollision(cr);
measureDist[posOrNeg] = tipBone.getModelSpacePosition().distance(target); link.bone.setLocalRotation(preQuat);
measureDist[posOrNeg] = tipBone.getModelSpacePosition().distance(target); link.bone.setLocalRotation(preQuat);
if(currentVelocity.distance(velocity) > FastMath.ZERO_TOLERANCE) rigidBody.setLinearVelocity(velocity); if (jump) {
if(currentVelocity.distance(velocity) > FastMath.ZERO_TOLERANCE) rigidBody.setLinearVelocity(velocity); if (jump) {
public static Spatial getNearest(Spatial spatial, final String targetRol) { Spatial result = null; float minDist = Float.MAX_VALUE; for(Spatial s: getSpatialsByRole(getRootNode(spatial), targetRol)) { float distance = s.getWorldTranslation().distance(spatial.getWorldTranslation()); if(distance < minDist) { minDist = distance; result = s; } } return result; }