public boolean wereMostRecentlyDiscared(Point3D checkOnA, Point3D checkOnB) { if ((discardedOnA == null) || (discardedOnB == null)) return false; //TODO: Magic number. //TODO: Use == when the points are pointers. Need to be able to ask the shape if pointers or values... double epsilon = 1e-10; return ((discardedOnA.distanceSquared(checkOnA) < epsilon) && (discardedOnB.distanceSquared(checkOnB) < epsilon)); // return ((discardedOnA == checkOnA) && (discardedOnB == checkOnB)); }
private boolean isPointValueInList(Point3D pointToCheck, ArrayList<Point3D> pointList) { for (Point3D pointInList : pointList) { if (pointToCheck.distanceSquared(pointInList) < 1e-10) return true; } return false; }
/** * Calculates the squared value of the distance between the minimum and maximum coordinates of this * bounding box. * * @return the squared value of this bounding box diagonal. */ public double getDiagonalLengthSquared() { return minPoint.distanceSquared(maxPoint); }
public static Point3D getTheClosestVisibleExtrusionPoint(Point3DReadOnly pointToSortFrom, List<Point3D> extrusionPoints) { double minDistance = Double.MAX_VALUE; Point3D closestPoint = null; for (Point3D point : extrusionPoints) { double currentDistance = point.distanceSquared(pointToSortFrom); if (currentDistance < minDistance) { minDistance = currentDistance; closestPoint = point; } } return closestPoint; }
@Override public double computeRayMissProbability(Point3DReadOnly rayOrigin, Point3DReadOnly rayEnd, Vector3DReadOnly rayDirection, NormalOcTreeNode node, OccupancyParameters parameters) { Point3D hitLocation = new Point3D(); node.getHitLocation(hitLocation); if (hitLocation.distanceSquared(rayEnd) < distanceSquaredToEndThreshold) { return rayEndMissProbability; } else if (node.getNormalConsensusSize() > normalConsensusThreshold && node.isNormalSet()) { Point3D nodeHitLocation = new Point3D(); Vector3D nodeNormal = new Vector3D(); node.getHitLocation(nodeHitLocation); node.getNormal(nodeNormal); if (Math.abs(rayDirection.dot(nodeNormal)) < dotRayToNormalThreshold) return shallowAngleMissProbability; else return parameters.getMissProbability(); } else { return parameters.getMissProbability(); } } }
rayDirection.sub(pointOnSphere, observer); Point3D intersection = PlanarRegionTools.intersectRegionsWithRay(regions, observer, rayDirection); if (intersection == null || intersection.distanceSquared(observer) > rayLengthSquared)
rayDirection.sub(pointOnSphere, observer); Point3D intersection = PlanarRegionTools.intersectRegionsWithRay(regions, observer, rayDirection); if (intersection == null || intersection.distanceSquared(observer) > rayLengthSquared)
expectedSquaredDistance = projection.distanceSquared(testPoint); actualSquaredDistance = EuclidGeometryTools.distanceSquaredFromPoint3DToLineSegment3D(testPoint, lineSegmentStart, lineSegmentEnd); assertEquals(expectedSquaredDistance, actualSquaredDistance, EuclidGeometryTools.ONE_TRILLIONTH); testPoint.scaleAdd(EuclidCoreRandomTools.nextDouble(random, 10.0), orthogonal, projection); projection.set(lineSegmentStart); expectedSquaredDistance = projection.distanceSquared(testPoint); actualSquaredDistance = EuclidGeometryTools.distanceSquaredFromPoint3DToLineSegment3D(testPoint, lineSegmentStart, lineSegmentEnd); assertEquals(expectedSquaredDistance, actualSquaredDistance, EuclidGeometryTools.ONE_TRILLIONTH); testPoint.scaleAdd(EuclidCoreRandomTools.nextDouble(random, 10.0), orthogonal, projection); projection.set(lineSegmentEnd); expectedSquaredDistance = projection.distanceSquared(testPoint); actualSquaredDistance = EuclidGeometryTools.distanceSquaredFromPoint3DToLineSegment3D(testPoint, lineSegmentStart, lineSegmentEnd); assertEquals(expectedSquaredDistance, actualSquaredDistance, EuclidGeometryTools.ONE_TRILLIONTH);
@Test public void testDistanceSquaredBetweenPoint3Ds() throws Exception { Random random = new Random(23423L); for (int i = 0; i < ITERATIONS; i++) { Point3D firstPoint = EuclidCoreRandomTools.nextPoint3D(random); Point3D secondPoint = EuclidCoreRandomTools.nextPoint3D(random); firstPoint.scale(EuclidCoreRandomTools.nextDouble(random, 10.0)); secondPoint.scale(EuclidCoreRandomTools.nextDouble(random, 10.0)); double expectedDistance = firstPoint.distanceSquared(secondPoint); double actualDistance = EuclidGeometryTools.distanceSquaredBetweenPoint3Ds(firstPoint.getX(), firstPoint.getY(), firstPoint.getZ(), secondPoint.getX(), secondPoint.getY(), secondPoint.getZ()); assertEquals(expectedDistance, actualDistance, EPSILON); actualDistance = EuclidGeometryTools.distanceSquaredBetweenPoint3Ds(firstPoint.getX(), firstPoint.getY(), firstPoint.getZ(), secondPoint); assertEquals(expectedDistance, actualDistance, EPSILON); } }
double distanceSquared = closestPointToOrigin.distanceSquared(origin);