Open dinhnhat0401 opened 11 years ago
You're right, I used south-based azimuth whereas north-based azimuth is usually used for sun position...
Thank you ! I'm currently writing an Android app and I've ported this awesome tool to java and I didn't understand where was my mistake concerning the sun azimuth :)
I created PR #35 to address this with tests.
just noticed this bug myself, thanks for the great work.
The pull request seems to fix it for me, will be double checking in the next days.
Will fix this be merged into the main branch soon?
Probably, but I'd suggest just adding a PI instead of waiting for it to be merged.
Is there a reason #35 hasn't been merged?
Yeah, hesitating to break backwards compatibility, leading to even more confusion :) I'll deal with this eventually, just didn't get my hands on it yet.
Makes sense! Crazy how many forks are downstream also…
If breaking backwards compatibility is a concern than it might be good to add a new interface method which would give the correct result and leave the old one for those who were doing their own workarounds.
I did not consider backwards functionality when I did the PR, that's my bad, I simply updated my library here and ran with it. @mourner if you have another solution, I'd be happy to work something up, otherwise no harm no foul on the PR.
Sorry but i find that the sun azimuth must plus 180 degree so: function getAzimuth(H, phi, dec) { return atan(sin(H), cos(H) * sin(phi) - tan(dec) * cos(phi)); }
must be: function getAzimuth(H, phi, dec) { return PI + atan(sin(H), cos(H) * sin(phi) - tan(dec) * cos(phi)); }