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));
@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; }
@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 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 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); }
if (Math.abs(magnitude) < Vector.MINIMUM_RESOLUTION) { final double theDistance = distanceStyle.computeDistance(start, x,y,z); return distanceStyle.aggregateDistances(theDistance, theDistance); return distanceStyle.aggregateDistances(theDistance, theDistance);
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)));
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)));