webdial

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

commit 8936e55035c19b06f466d230800e39522263aa84
parent 94b1ed8e2c5a3d0211c4d56c391793a92c8579eb
Author: Sean Lynch <seanl@literati.org>
Date:   Thu,  8 Sep 2011 20:41:37 -0700

Re-add wraparound logic

Diffstat:
Msun.js | 13+++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/sun.js b/sun.js @@ -83,8 +83,17 @@ function Sun() { for (deg = 0; deg < 360; deg++) { H = deg * Math.PI / 180.0; equ = this.ecl_to_equ(H, alt, obl); - x = (180 + equ.ra * 180.0 / Math.PI) % 360; - y = (0.5 - equ.dec / Math.PI) * 180 - 90; + x = equ.ra * 180.0 / Math.PI; + y = (0.5 - equ.dec / Math.PI) * 180; + if (lat < alt) { + if (x > px) { + points.push([0,0]); + points.push([359,0]); + } + } else if (lat > -alt && x < px) { + points.push([w-1,h-1]); + points.push([0,h-1]); + } points.push([x,y]); px = x; py = y;