@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; }
@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; }
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; 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;