webdial

Incomplete JS port of moondial.
git clone https://code.literati.org/webdial.git
Log | Files | Refs

commit 698c91600ea20550aadb954ac230d2a00d669d6f
parent 3db22798248c132063108c6f2a35a981c5bb2cd0
Author: Sean Lynch <seanl@literati.org>
Date:   Wed,  7 Sep 2011 23:57:41 -0700

Oh, right, new.

Diffstat:
Msun.js | 4++--
Mwebdial.js | 21+++++++++++----------
2 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/sun.js b/sun.js @@ -1,4 +1,4 @@ -var Sun = function() { +function Sun() { var _DtoR = Math.PI / 180.0; function d_to_r(d) { return d * _DtoR; @@ -221,4 +221,4 @@ var Sun = function() { this.aberration_low = function(R) { return -_lk4 / R }; -}(); +}; diff --git a/webdial.js b/webdial.js @@ -1,5 +1,6 @@ function WebDial(canvas) { var continents; + var sun = new Sun(); function drawPoly(ctx, w, h, points) { function lon2x(lon) { @@ -32,23 +33,23 @@ function WebDial(canvas) { function drawNight(ctx, w, h) { console.debug(1); ctx.fillStyle = "rgba(0, 0, 0, 128)"; - console.debug(Sun); - var jd = Sun.cal_to_jd(new Date()); + console.debug(sun); + var jd = sun.cal_to_jd(new Date()); console.debug(3); - var epsilon = Sun.obliquity(jd); + var epsilon = sun.obliquity(jd); console.debug(4); - var geometric_lon = Sun.longitude_radius_low(jd).longitude; + var geometric_lon = sun.longitude_radius_low(jd).longitude; console.debug(5); - var lon = Sun.apparent_longitude_low(jd, geometric_lon); + var lon = sun.apparent_longitude_low(jd, geometric_lon); console.debug(6); - var equ = Sun.ecl_to_equ(lon, 0.0, epsilon); + var equ = sun.ecl_to_equ(lon, 0.0, epsilon); console.debug(7); - var st = Sun.sidereal_time_greenwich(jd); + var st = sun.sidereal_time_greenwich(jd); console.debug(8); - var geo = Sun.equ_to_geo(ra, dec, st); + var geo = sun.equ_to_geo(ra, dec, st); console.debug(9); - var points = Sun.terminator(geo.latitude, geo.longitude, - Sun.sun_rst_altitude, w, h); + var points = sun.terminator(geo.latitude, geo.longitude, + sun.sun_rst_altitude, w, h); console.debug(points); ctx.beginPath(); drawPoly(ctx, w, h, points);