Skip to content

Commit

Permalink
add pi. fix upstream issue #6 using pr #35
Browse files Browse the repository at this point in the history
use the fix xqjibz recommended. upstream (mourner) never merged xqjibz's pull request because it would've broken dependent apps. it was suggested to merge the pr with a major version increment in order to avoid dependent apps automatically updating, but that suggestion was never heeded. my repo doesn't have dependent apps right now so i can go ahead and just solve this issue.
  • Loading branch information
sonicbluesky committed Jan 21, 2025
1 parent 6bc2757 commit 34ebc96
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
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 @@ -38,7 +38,7 @@ var heightTestTimes = {
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 @@ -64,7 +64,7 @@ t.test('getTimes adjusts sun phases when additionally given the observer height'
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.014551482243892251), 'altitude');
t.ok(near(moonPos.distance, 364121.37256256194), 'distance');
t.end();
Expand Down

0 comments on commit 34ebc96

Please sign in to comment.