You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You calculate the azimuth (bearing/direction) between p1 and p2, and from that azimuth, you try to make a perpendicular great circle by changing that azimuth by +180 (or -180, whatever). The problem with this is that, as you move along the path from p1 to p2, your azimuth constantly changes, assuming you are taking the shortest great-circle distance (ie: Haversine/Vincenty). Unless you use a line that assumes the azimuth does not change (ie: occasionally used for moving by sea), your azimuth only applies for p1. p2 has a different azimuth, and so does every single point along that great-circle.
It is a decent approximation of an answer for short distances, but know that this calculation will be way* off if distance(p1, p2) is either long, or if you're close to true north/south pole.
If you do have the proper code for this, I would welcome you let me know.
Thanks
-Phil
The text was updated successfully, but these errors were encountered:
https://github.com/Turfjs/turf/blob/master/packages/turf-nearest-point-on-line/index.ts
This code is wrong. It is an approximation.
You calculate the azimuth (bearing/direction) between p1 and p2, and from that azimuth, you try to make a perpendicular great circle by changing that azimuth by +180 (or -180, whatever). The problem with this is that, as you move along the path from p1 to p2, your azimuth constantly changes, assuming you are taking the shortest great-circle distance (ie: Haversine/Vincenty). Unless you use a line that assumes the azimuth does not change (ie: occasionally used for moving by sea), your azimuth only applies for p1. p2 has a different azimuth, and so does every single point along that great-circle.
It is a decent approximation of an answer for short distances, but know that this calculation will be way* off if distance(p1, p2) is either long, or if you're close to true north/south pole.
If you do have the proper code for this, I would welcome you let me know.
Thanks
-Phil
The text was updated successfully, but these errors were encountered: