public final double getDistanceKmToPath ( Position p1 , Position p2 ) { double d = radiusEarthKm * asin ( sin ( getDistanceToKm ( p1 ) / radiusEarthKm ) * sin ( toRadians ( getBearingDegrees ( p1 ) - p1 . getBearingDegrees ( p2 ) ) ) ) ; return abs ( d ) ; }
calculates the distance of a point to the great circle path between p1 and p2 .