Closed mmahalwy closed 7 years ago
Good idea, should be easy enough to add in.
If you can tell me where I can find the code for it, I can add it to JS
Most qibla direction websites/apps (even Guidance) use the equation for the azimuth of two points on a sphere. Despite the Earth not being spherical, this is done for simplicity and most people would consider it acceptable as the margin of error is less than a degree.
However there are algorithms for calculating the azimuth of an ellipsoid that can give values of much higher accuracy.
It would be sufficient to provide the spherical equation, but in keeping with the high accuracy intent of this library I think it would be preferable (and more interesting) to do the full ellipsoid calculation.
Ellipsoid algorithms: https://en.wikipedia.org/wiki/Vincenty%27s_formulae http://link.springer.com/article/10.1007%2Fs00190-012-0578-z http://geographiclib.sourceforge.net/
Thoughts?
cc @ahmedre
perhaps start with the spherical equation, and, if we can do the ellipsoid later on, we can insha'Allah and people can choose which to use
Sounds good! I'd love to help!
Here's one written in Swift: https://github.com/ethemozcan/QiblaDirection
I use this in a production app and works great, perhaps we can borrow some logic.
We can go ahead and simply implement the basic azimuth equation. I'll add it in Swift and then if you want to do the JS @mmahalwy that would be great. I had intended to find an academic source for the equation so that it could be appropriately cited and then got distracted. I will look again for a citable reference.
okay, that'd be great!
@mmahalwy the swift version has been implemented, you can see the equation here #50
@z3bi heads up, I don't have write permission for repo!
Salaam @mmahalwy, correct me if I'm wrong, but you'll have to fork the repo and create a pull request against the master branch.
@basememara yep, that's what I ended up doing: https://github.com/batoulapps/Adhan/pull/51
Might be interesting to include