Skip to content

Fixes #6 #35

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion suncalc.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ var e = rad * 23.4397; // obliquity of the Earth
function rightAscension(l, b) { return atan(sin(l) * cos(e) - tan(b) * sin(e), cos(l)); }
function declination(l, b) { return asin(sin(b) * cos(e) + cos(b) * sin(e) * sin(l)); }

function azimuth(H, phi, dec) { return atan(sin(H), cos(H) * sin(phi) - tan(dec) * cos(phi)); }
function azimuth(H, phi, dec) { return PI + atan(sin(H), cos(H) * sin(phi) - tan(dec) * cos(phi)); }
function altitude(H, phi, dec) { return asin(sin(phi) * sin(dec) + cos(phi) * cos(dec) * cos(H)); }

function siderealTime(d, lw) { return rad * (280.16 + 360.9856235 * d) - lw; }
Expand Down
4 changes: 2 additions & 2 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var testTimes = {
t.test('getPosition returns azimuth and altitude for the given time and location', function (t) {
var sunPos = SunCalc.getPosition(date, lat, lng);

t.ok(near(sunPos.azimuth, -2.5003175907168385), 'azimuth');
t.ok(near(sunPos.azimuth, 0.6412750628729547), 'azimuth');
t.ok(near(sunPos.altitude, -0.7000406838781611), 'altitude');
t.end();
});
Expand All @@ -47,7 +47,7 @@ t.test('getTimes returns sun phases for the given date and location', function (
t.test('getMoonPosition returns moon position data given time and location', function (t) {
var moonPos = SunCalc.getMoonPosition(date, lat, lng);

t.ok(near(moonPos.azimuth, -0.9783999522438226), 'azimuth');
t.ok(near(moonPos.azimuth, 2.1631927013459706), 'azimuth');
t.ok(near(moonPos.altitude, 0.006969727754891917), 'altitude');
t.ok(near(moonPos.distance, 364121.37256256194), 'distance');
t.end();
Expand Down