Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LatLonSpherical.intersection algorithm is different from edwilliams aviation formula. #107

Closed
aldas opened this issue Dec 3, 2022 · 1 comment

Comments

@aldas
Copy link

aldas commented Dec 3, 2022

http://www.edwilliams.org/avform147.htm#Intersection has

IF sin(lon2-lon1)<0
   crs12=acos((sin(lat2)-sin(lat1)*cos(dst12))/(sin(dst12)*cos(lat1)))
   crs21=2.*pi-acos((sin(lat1)-sin(lat2)*cos(dst12))/(sin(dst12)*cos(lat2)))
ELSE
   crs12=2.*pi-acos((sin(lat2)-sin(lat1)*cos(dst12))/(sin(dst12)*cos(lat1)))
   crs21=acos((sin(lat1)-sin(lat2)*cos(dst12))/(sin(dst12)*cos(lat2)))
ENDIF

but same condition seems to be inversed in this library

geodesy/latlon-spherical.js

Lines 426 to 427 in 761587c

const θ12 = Math.sin(λ2-λ1)>0 ? θa : 2*π-θa;
const θ21 = Math.sin(λ2-λ1)>0 ? 2*π-θb : θb;

meaning that Williams algorithm for crs12 in case sin(lon2-lon1)<0 is crs12=acos((sin(lat2)-sin(lat1)*cos(dst12))/(sin(dst12)*cos(lat1))) but in this library same condition results θ12 = 2*π-θa;

which one is right?

I am totally clueless at trigonometry but noticed this difference

@aldas aldas changed the title LatLonSpherical.intersection is algoritm is different from edwilliams aviation formula. LatLonSpherical.intersection algorithm is different from edwilliams aviation formula. Dec 3, 2022
@chrisveness
Copy link
Owner

Williams chose to take west longitudes as positive (“For the convenience of North Americans I will take North latitudes and West longitudes as positive and South and East negative. The longitude is the opposite of the usual mathematical convention”).

I have stuck to normal sign convention with west -ve and east +ve.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants