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

What does the TODO comment about wrapping the latitude -315° mean? #87

Closed
dzfranklin opened this issue Aug 21, 2020 · 1 comment
Closed

Comments

@dzfranklin
Copy link

In dms.js:320 there is the line

return Math.abs((degrees%360 + 270)%360 - 180) - 90; // triangle wave p:360 a:±90 TODO: fix e.g. -315°

I don't understand what the comment means, or what implications this has.

@chrisveness
Copy link
Owner

I've been meaning to fix this for a long time!

I struggled originally to get the wrap90() and wrap180() functions to work correctly for all inputs of negative degrees (< -270°); spending a bit more time on it, I've worked out that this was because the JavaScript '%' operator is a 'rem' operator rather than a 'mod' operator, which handles negative dividends differently; I've also worked out the full forms of the triangle/sawtooth wave functions and based the code more closely on those so that the operation is clearer.

wrap90() and wrap180() now work correctly for all inputs.

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