@math.gl/sun
Advanced tools
Comparing version 3.5.0-alpha.1 to 3.5.0-beta.1
@@ -1,16 +0,16 @@ | ||
var DEGREES_TO_RADIANS = Math.PI / 180; | ||
var DAY_IN_MS = 1000 * 60 * 60 * 24; | ||
var JD1970 = 2440588; | ||
var JD2000 = 2451545; | ||
var e = DEGREES_TO_RADIANS * 23.4397; | ||
var M0 = 357.5291; | ||
var M1 = 0.98560028; | ||
var THETA0 = 280.147; | ||
var THETA1 = 360.9856235; | ||
const DEGREES_TO_RADIANS = Math.PI / 180; | ||
const DAY_IN_MS = 1000 * 60 * 60 * 24; | ||
const JD1970 = 2440588; | ||
const JD2000 = 2451545; | ||
const e = DEGREES_TO_RADIANS * 23.4397; | ||
const M0 = 357.5291; | ||
const M1 = 0.98560028; | ||
const THETA0 = 280.147; | ||
const THETA1 = 360.9856235; | ||
export function getSunPosition(timestamp, latitude, longitude) { | ||
var longitudeWestInRadians = DEGREES_TO_RADIANS * -longitude; | ||
var phi = DEGREES_TO_RADIANS * latitude; | ||
var d = toDays(timestamp); | ||
var c = getSunCoords(d); | ||
var H = getSiderealTime(d, longitudeWestInRadians) - c.rightAscension; | ||
const longitudeWestInRadians = DEGREES_TO_RADIANS * -longitude; | ||
const phi = DEGREES_TO_RADIANS * latitude; | ||
const d = toDays(timestamp); | ||
const c = getSunCoords(d); | ||
const H = getSiderealTime(d, longitudeWestInRadians) - c.rightAscension; | ||
return { | ||
@@ -22,7 +22,7 @@ azimuth: getAzimuth(H, phi, c.declination), | ||
export function getSunDirection(timestamp, latitude, longitude) { | ||
var _getSunPosition = getSunPosition(timestamp, latitude, longitude), | ||
azimuth = _getSunPosition.azimuth, | ||
altitude = _getSunPosition.altitude; | ||
var azimuthN = azimuth + Math.PI; | ||
const { | ||
azimuth, | ||
altitude | ||
} = getSunPosition(timestamp, latitude, longitude); | ||
const azimuthN = azimuth + Math.PI; | ||
return [-Math.sin(azimuthN), Math.cos(azimuthN), -Math.sin(altitude)]; | ||
@@ -40,3 +40,3 @@ } | ||
function getRightAscension(eclipticLongitude, b) { | ||
var lambda = eclipticLongitude; | ||
const lambda = eclipticLongitude; | ||
return Math.atan2(Math.sin(lambda) * Math.cos(e) - Math.tan(b) * Math.sin(e), Math.cos(lambda)); | ||
@@ -46,3 +46,3 @@ } | ||
function getDeclination(eclipticLongitude, b) { | ||
var lambda = eclipticLongitude; | ||
const lambda = eclipticLongitude; | ||
return Math.asin(Math.sin(b) * Math.cos(e) + Math.cos(b) * Math.sin(e) * Math.sin(lambda)); | ||
@@ -52,5 +52,5 @@ } | ||
function getAzimuth(hourAngle, latitudeInRadians, declination) { | ||
var H = hourAngle; | ||
var phi = latitudeInRadians; | ||
var delta = declination; | ||
const H = hourAngle; | ||
const phi = latitudeInRadians; | ||
const delta = declination; | ||
return Math.atan2(Math.sin(H), Math.cos(H) * Math.sin(phi) - Math.tan(delta) * Math.cos(phi)); | ||
@@ -60,5 +60,5 @@ } | ||
function getAltitude(hourAngle, latitudeInRadians, declination) { | ||
var H = hourAngle; | ||
var phi = latitudeInRadians; | ||
var delta = declination; | ||
const H = hourAngle; | ||
const phi = latitudeInRadians; | ||
const delta = declination; | ||
return Math.asin(Math.sin(phi) * Math.sin(delta) + Math.cos(phi) * Math.cos(delta) * Math.cos(H)); | ||
@@ -76,5 +76,5 @@ } | ||
function getEclipticLongitude(meanAnomaly) { | ||
var M = meanAnomaly; | ||
var C = DEGREES_TO_RADIANS * (1.9148 * Math.sin(M) + 0.02 * Math.sin(2 * M) + 0.0003 * Math.sin(3 * M)); | ||
var P = DEGREES_TO_RADIANS * 102.9372; | ||
const M = meanAnomaly; | ||
const C = DEGREES_TO_RADIANS * (1.9148 * Math.sin(M) + 0.02 * Math.sin(2 * M) + 0.0003 * Math.sin(3 * M)); | ||
const P = DEGREES_TO_RADIANS * 102.9372; | ||
return M + C + P + Math.PI; | ||
@@ -84,4 +84,4 @@ } | ||
function getSunCoords(dates) { | ||
var M = getSolarMeanAnomaly(dates); | ||
var L = getEclipticLongitude(M); | ||
const M = getSolarMeanAnomaly(dates); | ||
const L = getEclipticLongitude(M); | ||
return { | ||
@@ -88,0 +88,0 @@ declination: getDeclination(L, 0), |
@@ -8,3 +8,3 @@ { | ||
}, | ||
"version": "3.5.0-alpha.1", | ||
"version": "3.5.0-beta.1", | ||
"keywords": [ | ||
@@ -32,3 +32,3 @@ "javascript", | ||
}, | ||
"gitHead": "d40d72a2b16a54129c9608f2ca326b812903d856" | ||
"gitHead": "193857458219ebd3a605c5c64f3b330ff48dcf02" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
317
34808