suncalc icon indicating copy to clipboard operation
suncalc copied to clipboard

Wrong azimuth angle

Open dinhnhat0401 opened this issue 13 years ago • 12 comments

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)); }

dinhnhat0401 avatar Mar 21 '13 13:03 dinhnhat0401

You're right, I used south-based azimuth whereas north-based azimuth is usually used for sun position...

mourner avatar Mar 21 '13 15:03 mourner

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 :)

florianmski avatar Apr 14 '13 15:04 florianmski

I created PR #35 to address this with tests.

xqjibz avatar Oct 28 '14 01:10 xqjibz

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.

ghost avatar Nov 10 '14 22:11 ghost

Will fix this be merged into the main branch soon?

spencerthayer avatar Nov 19 '14 19:11 spencerthayer

Probably, but I'd suggest just adding a PI instead of waiting for it to be merged.

mourner avatar Nov 19 '14 19:11 mourner

Is there a reason #35 hasn't been merged?

warpling avatar Jun 18 '15 01:06 warpling

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.

mourner avatar Jun 26 '15 11:06 mourner

Makes sense! Crazy how many forks are downstream also…

warpling avatar Jun 26 '15 17:06 warpling

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.

ghost avatar Jun 27 '15 10:06 ghost

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.

xqjibz avatar Jul 01 '15 18:07 xqjibz

According to semver, the way to avoid breaking users existing apps is to release a new version with a major version number change (i.e. release as 2.0.0). This way, the vast majority of users won't pull it into their project automatically.

ultrafez avatar Oct 25 '16 22:10 ultrafez