/** Compute delta path distance. *@param distanceStyle is the distance style. *@param x is the point x. *@param y is the point y. *@param z is the point z. *@return the distance metric, in aggregation form. */ public double pathDeltaDistance(final DistanceStyle distanceStyle, final double x, final double y, final double z) { if (!isWithin(x,y,z)) return Double.POSITIVE_INFINITY; final double theDistance = distanceStyle.toAggregationForm(distanceStyle.computeDistance(this.point, x, y, z)); return distanceStyle.aggregateDistances(theDistance, theDistance); }
/** Compute interior path distance. *@param distanceStyle is the distance style. *@param x is the point x. *@param y is the point y. *@param z is the point z. *@return the distance metric, in aggregation form. */ public double pathDistance(final DistanceStyle distanceStyle, final double x, final double y, final double z) { if (!isWithin(x,y,z)) return Double.POSITIVE_INFINITY; return distanceStyle.toAggregationForm(distanceStyle.computeDistance(this.point, x, y, z)); }
/** Compute external distance. *@param distanceStyle is the distance style. *@param x is the point x. *@param y is the point y. *@param z is the point z. *@return the distance metric. */ public double outsideDistance(final DistanceStyle distanceStyle, final double x, final double y, final double z) { return distanceStyle.computeDistance(this.point, x, y, z); }
@Override protected double distance(final DistanceStyle distanceStyle, final double x, final double y, final double z) { // Algorithm: // (1) If the point is within any of the segments along the path, return that value. // (2) If the point is within any of the segment end circles along the path, return that value. double currentDistance = 0.0; for (PathSegment segment : segments) { double distance = segment.pathDistance(planetModel, distanceStyle, x,y,z); if (distance != Double.POSITIVE_INFINITY) return distanceStyle.fromAggregationForm(distanceStyle.aggregateDistances(currentDistance, distance)); currentDistance = distanceStyle.aggregateDistances(currentDistance, segment.fullPathDistance(distanceStyle)); } int segmentIndex = 0; currentDistance = 0.0; for (SegmentEndpoint endpoint : endPoints) { double distance = endpoint.pathDistance(distanceStyle, x, y, z); if (distance != Double.POSITIVE_INFINITY) return distanceStyle.fromAggregationForm(distanceStyle.aggregateDistances(currentDistance, distance)); if (segmentIndex < segments.size()) currentDistance = distanceStyle.aggregateDistances(currentDistance, segments.get(segmentIndex++).fullPathDistance(distanceStyle)); } return Double.POSITIVE_INFINITY; }
/** Compute nearest path distance. *@param distanceStyle is the distance style. *@param x is the point x. *@param y is the point y. *@param z is the point z. *@return the distance metric (always value zero), in aggregation form, or POSITIVE_INFINITY * if the point is not within the bounds of the endpoint. */ public double nearestPathDistance(final DistanceStyle distanceStyle, final double x, final double y, final double z) { for (final Membership m : cutoffPlanes) { if (!m.isWithin(x,y,z)) { return Double.POSITIVE_INFINITY; } } return distanceStyle.toAggregationForm(0.0); }
@Override public double computeNearestDistance(final DistanceStyle distanceStyle, final double x, final double y, final double z) { double currentDistance = 0.0; double minPathCenterDistance = Double.POSITIVE_INFINITY; double bestDistance = Double.POSITIVE_INFINITY; int segmentIndex = 0; for (final SegmentEndpoint endpoint : endPoints) { final double endpointPathCenterDistance = endpoint.pathCenterDistance(distanceStyle, x, y, z); if (endpointPathCenterDistance < minPathCenterDistance) { // Use this endpoint minPathCenterDistance = endpointPathCenterDistance; bestDistance = currentDistance; } // Look at the following segment, if any if (segmentIndex < segments.size()) { final PathSegment segment = segments.get(segmentIndex++); final double segmentPathCenterDistance = segment.pathCenterDistance(planetModel, distanceStyle, x, y, z); if (segmentPathCenterDistance < minPathCenterDistance) { minPathCenterDistance = segmentPathCenterDistance; bestDistance = distanceStyle.aggregateDistances(currentDistance, segment.nearestPathDistance(planetModel, distanceStyle, x, y, z)); } currentDistance = distanceStyle.aggregateDistances(currentDistance, segment.fullPathDistance(distanceStyle)); } } return bestDistance; }
@Override protected double deltaDistance(final DistanceStyle distanceStyle, final double x, final double y, final double z) { // Algorithm: // (1) If the point is within any of the segments along the path, return that value. // (2) If the point is within any of the segment end circles along the path, return that value. // Finds best distance double bestDistance = Double.POSITIVE_INFINITY; for (final PathSegment segment : segments) { final double distance = segment.pathDeltaDistance(planetModel, distanceStyle, x, y, z); if (distance != Double.POSITIVE_INFINITY) { final double thisDistance = distanceStyle.fromAggregationForm(distance); if (thisDistance < bestDistance) { bestDistance = thisDistance; } } } for (final SegmentEndpoint endpoint : endPoints) { final double distance = endpoint.pathDeltaDistance(distanceStyle, x, y, z); if (distance != Double.POSITIVE_INFINITY) { final double thisDistance = distanceStyle.fromAggregationForm(distance); if (thisDistance < bestDistance) { bestDistance = thisDistance; } } } return bestDistance; }
/** Compute the distance from a plane to a point. * @param planetModel The planet model * @param plane The plane * @param point The point * @param bounds are the plane bounds * @return the distance */ public default double computeDistance(final PlanetModel planetModel, final Plane plane, final GeoPoint point, final Membership... bounds) { return computeDistance(planetModel, plane, point.x, point.y, point.z, bounds); }
/** Compute interior path distance. *@param distanceStyle is the distance style. *@param x is the point x. *@param y is the point y. *@param z is the point z. *@return the distance metric, in aggregation form. */ public double pathDistance(final DistanceStyle distanceStyle, final double x, final double y, final double z) { if (!isWithin(x,y,z)) return Double.POSITIVE_INFINITY; return distanceStyle.toAggregationForm(distanceStyle.computeDistance(this.point, x, y, z)); }
double distance = segment.pathDistance(planetModel, distanceStyle, x,y,z); if (distance != Double.POSITIVE_INFINITY) { final double thisDistance = distanceStyle.fromAggregationForm(distanceStyle.aggregateDistances(currentDistance, distance)); if (thisDistance < bestDistance) { bestDistance = thisDistance; currentDistance = distanceStyle.aggregateDistances(currentDistance, segment.fullPathDistance(distanceStyle)); double distance = endpoint.pathDistance(distanceStyle, x, y, z); if (distance != Double.POSITIVE_INFINITY) { final double thisDistance = distanceStyle.fromAggregationForm(distanceStyle.aggregateDistances(currentDistance, distance)); if (thisDistance < bestDistance) { bestDistance = thisDistance; currentDistance = distanceStyle.aggregateDistances(currentDistance, segments.get(segmentIndex++).fullPathDistance(distanceStyle));
/** Compute nearest path distance. *@param distanceStyle is the distance style. *@param x is the point x. *@param y is the point y. *@param z is the point z. *@return the distance metric (always value zero), in aggregation form, or POSITIVE_INFINITY * if the point is not within the bounds of the endpoint. */ public double nearestPathDistance(final DistanceStyle distanceStyle, final double x, final double y, final double z) { for (final Membership m : cutoffPlanes) { if (!m.isWithin(x,y,z)) { return Double.POSITIVE_INFINITY; } } return distanceStyle.toAggregationForm(0.0); }
@Override public double computeNearestDistance(final DistanceStyle distanceStyle, final double x, final double y, final double z) { double currentDistance = 0.0; double minPathCenterDistance = Double.POSITIVE_INFINITY; double bestDistance = Double.POSITIVE_INFINITY; int segmentIndex = 0; for (SegmentEndpoint endpoint : endPoints) { final double endpointPathCenterDistance = endpoint.pathCenterDistance(distanceStyle, x, y, z); if (endpointPathCenterDistance < minPathCenterDistance) { // Use this endpoint minPathCenterDistance = endpointPathCenterDistance; bestDistance = currentDistance; } // Look at the following segment, if any if (segmentIndex < segments.size()) { final PathSegment segment = segments.get(segmentIndex++); final double segmentPathCenterDistance = segment.pathCenterDistance(planetModel, distanceStyle, x, y, z); if (segmentPathCenterDistance < minPathCenterDistance) { minPathCenterDistance = segmentPathCenterDistance; bestDistance = distanceStyle.aggregateDistances(currentDistance, segment.nearestPathDistance(planetModel, distanceStyle, x, y, z)); } currentDistance = distanceStyle.aggregateDistances(currentDistance, segment.fullPathDistance(distanceStyle)); } } return bestDistance; }
/** Compute external distance. *@param distanceStyle is the distance style. *@param x is the point x. *@param y is the point y. *@param z is the point z. *@return the distance metric. */ public double outsideDistance(final DistanceStyle distanceStyle, final double x, final double y, final double z) { return distanceStyle.computeDistance(this.point, x, y, z); }
final double magnitude = Math.sqrt(perpX * perpX + perpY * perpY + perpZ * perpZ); if (Math.abs(magnitude) < Vector.MINIMUM_RESOLUTION) return distanceStyle.toAggregationForm(distanceStyle.computeDistance(start, x,y,z)); final double normFactor = 1.0/magnitude; final Plane normalizedPerpPlane = new Plane(perpX * normFactor, perpY * normFactor, perpZ * normFactor, 0.0); throw new RuntimeException("Can't find world intersection for point x="+x+" y="+y+" z="+z); return distanceStyle.aggregateDistances(distanceStyle.toAggregationForm(distanceStyle.computeDistance(thePoint, x, y, z)), distanceStyle.toAggregationForm(distanceStyle.computeDistance(start, thePoint.x, thePoint.y, thePoint.z)));
/** Compute the full distance along this path segment. *@param distanceStyle is the distance style. *@return the distance metric, in aggregation form. */ public double fullPathDistance(final DistanceStyle distanceStyle) { synchronized (fullDistanceCache) { Double dist = fullDistanceCache.get(distanceStyle); if (dist == null) { dist = distanceStyle.toAggregationForm(distanceStyle.computeDistance(start, end.x, end.y, end.z)); fullDistanceCache.put(distanceStyle, dist); } return dist.doubleValue(); } }
@Override protected double outsideDistance(final DistanceStyle distanceStyle, final double x, final double y, final double z) { double outsideDistance = Double.POSITIVE_INFINITY; for (final CircleSlice slice : circleSlices) { final double distance = distanceStyle.computeDistance(planetModel, slice.circlePlane, x, y, z, slice.plane1, slice.plane2); if (distance < outsideDistance) { outsideDistance = distance; } } return outsideDistance; }
final double magnitude = Math.sqrt(perpX * perpX + perpY * perpY + perpZ * perpZ); if (Math.abs(magnitude) < Vector.MINIMUM_RESOLUTION) return distanceStyle.toAggregationForm(distanceStyle.computeDistance(start, x,y,z)); final double normFactor = 1.0/magnitude; final Plane normalizedPerpPlane = new Plane(perpX * normFactor, perpY * normFactor, perpZ * normFactor, 0.0); throw new RuntimeException("Can't find world intersection for point x="+x+" y="+y+" z="+z); return distanceStyle.aggregateDistances(distanceStyle.toAggregationForm(distanceStyle.computeDistance(thePoint, x, y, z)), distanceStyle.toAggregationForm(distanceStyle.computeDistance(start, thePoint.x, thePoint.y, thePoint.z)));
/** Compute the full distance along this path segment. *@param distanceStyle is the distance style. *@return the distance metric, in aggregation form. */ public double fullPathDistance(final DistanceStyle distanceStyle) { synchronized (fullDistanceCache) { Double dist = fullDistanceCache.get(distanceStyle); if (dist == null) { dist = distanceStyle.toAggregationForm(distanceStyle.computeDistance(start, end.x, end.y, end.z)); fullDistanceCache.put(distanceStyle, dist); } return dist.doubleValue(); } }
@Override protected double distance(final DistanceStyle distanceStyle, final double x, final double y, final double z) { return distanceStyle.computeDistance(this.center, x, y, z); }
final double magnitude = Math.sqrt(perpX * perpX + perpY * perpY + perpZ * perpZ); if (Math.abs(magnitude) < Vector.MINIMUM_RESOLUTION) { final double theDistance = distanceStyle.computeDistance(start, x,y,z); return distanceStyle.aggregateDistances(theDistance, theDistance); throw new RuntimeException("Can't find world intersection for point x="+x+" y="+y+" z="+z); final double theDistance = distanceStyle.toAggregationForm(distanceStyle.computeDistance(thePoint, x, y, z)); return distanceStyle.aggregateDistances(theDistance, theDistance);