astronomy-bundle
Version:
Bundle for astronomical calculations such as position of moon, sun and planets, sunrise, sunset or solar eclipses. Most of the calculations are based on Jean Meeus 'Astronomical Algorithms' book and the VSOP87 theory.
210 lines (209 loc) • 8.24 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getOpticalLiberationInLatitude = exports.getOpticalLiberationInLongitude = exports.getDistanceToEarth = exports.getRadiusVector = exports.getLatitude = exports.getLongitude = exports.getEquatorialHorizontalParallax = exports.getMeanLongitudeOfAscendingNode = exports.getMeanLongitude = exports.getArgumentOfLatitude = exports.getMeanAnomaly = exports.getMeanElongation = void 0;
const calculations_1 = require("../../earth/calculations");
const calculations_2 = require("../../sun/calculations");
const angleCalc_1 = require("../../utils/angleCalc");
const distanceCalc_1 = require("../../utils/distanceCalc");
const calculations_3 = require("../constants/calculations");
function getMeanElongation(T) {
const D = 297.8501921
+ 445267.1114034 * T
- 0.0018819 * Math.pow(T, 2)
+ Math.pow(T, 3) / 545868
- Math.pow(T, 4) / 113065000;
return (0, angleCalc_1.normalizeAngle)(D);
}
exports.getMeanElongation = getMeanElongation;
function getMeanAnomaly(T) {
const Mmoon = 134.9633964
+ 477198.8675055 * T
+ 0.0087414 * Math.pow(T, 2)
+ Math.pow(T, 3) / 69699
- Math.pow(T, 4) / 1471200;
return (0, angleCalc_1.normalizeAngle)(Mmoon);
}
exports.getMeanAnomaly = getMeanAnomaly;
function getArgumentOfLatitude(T) {
const F = 93.2720950
+ 483202.0175233 * T
- 0.0036539 * Math.pow(T, 2)
- Math.pow(T, 3) / 352600
+ Math.pow(T, 4) / 86331000;
return (0, angleCalc_1.normalizeAngle)(F);
}
exports.getArgumentOfLatitude = getArgumentOfLatitude;
function getMeanLongitude(T) {
const L = 218.3164477
+ 481267.88123421 * T
- 0.0015786 * Math.pow(T, 2)
+ Math.pow(T, 3) / 538841
- Math.pow(T, 4) / 65194000;
return (0, angleCalc_1.normalizeAngle)(L);
}
exports.getMeanLongitude = getMeanLongitude;
function getMeanLongitudeOfAscendingNode(T) {
return 125.0445479
- 1934.1362891 * T
+ 0.0020754 * Math.pow(T, 2)
+ Math.pow(T, 3) / 467441
- Math.pow(T, 4) / 60616000;
}
exports.getMeanLongitudeOfAscendingNode = getMeanLongitudeOfAscendingNode;
function getEquatorialHorizontalParallax(T) {
const d = getDistanceToEarth(T);
return (0, angleCalc_1.rad2deg)(Math.asin(6378.14 / d));
}
exports.getEquatorialHorizontalParallax = getEquatorialHorizontalParallax;
function getLongitude(T) {
const L = getMeanLongitude(T);
const sumL = _getSumL(T);
return L + sumL / 1000000;
}
exports.getLongitude = getLongitude;
function getLatitude(T) {
const sumB = _getSumB(T);
return sumB / 1000000;
}
exports.getLatitude = getLatitude;
function getRadiusVector(T) {
return (0, distanceCalc_1.km2au)(getDistanceToEarth(T));
}
exports.getRadiusVector = getRadiusVector;
function getDistanceToEarth(T) {
const sumR = _getSumR(T);
return 385000.56 + sumR / 1000;
}
exports.getDistanceToEarth = getDistanceToEarth;
function _getSumR(T) {
const D = getMeanElongation(T);
const Msun = calculations_2.sunCalc.getMeanAnomaly(T);
const Mmoon = getMeanAnomaly(T);
const F = getArgumentOfLatitude(T);
const E = 1 - 0.002516 * T - 0.0000074 * Math.pow(T, 2);
let sumR = 0;
calculations_3.MOON_ARGUMENTS_LR.forEach((args) => {
const argD = args[0];
const argMsun = args[1];
const argMmoon = args[2];
const argF = args[3];
const argSumR = args[5];
let tmpSumR = Math.cos((0, angleCalc_1.deg2rad)(argD * D + argMsun * Msun + argMmoon * Mmoon + argF * F));
switch (argMsun) {
case 1:
case -1:
tmpSumR = tmpSumR * argSumR * E;
break;
case 2:
case -2:
tmpSumR = tmpSumR * argSumR * E * E;
break;
default:
tmpSumR = tmpSumR * argSumR;
break;
}
sumR += tmpSumR;
});
return sumR;
}
function _getSumL(T) {
const L = getMeanLongitude(T);
const D = getMeanElongation(T);
const Msun = calculations_2.sunCalc.getMeanAnomaly(T);
const Mmoon = getMeanAnomaly(T);
const F = getArgumentOfLatitude(T);
const A1 = 119.75 + 131.849 * T;
const A2 = 53.09 + 479264.290 * T;
const E = 1 - 0.002516 * T - 0.0000074 * Math.pow(T, 2);
let sumL = 3958 * Math.sin((0, angleCalc_1.deg2rad)(A1))
+ 1962 * Math.sin((0, angleCalc_1.deg2rad)(L - F))
+ 318 * Math.sin((0, angleCalc_1.deg2rad)(A2));
calculations_3.MOON_ARGUMENTS_LR.forEach((args) => {
const argD = args[0];
const argMsun = args[1];
const argMmoon = args[2];
const argF = args[3];
const argSumL = args[4];
let tmpSumL = Math.sin((0, angleCalc_1.deg2rad)(argD * D + argMsun * Msun + argMmoon * Mmoon + argF * F));
switch (argMsun) {
case 1:
case -1:
tmpSumL = tmpSumL * argSumL * E;
break;
case 2:
case -2:
tmpSumL = tmpSumL * argSumL * E * E;
break;
default:
tmpSumL = tmpSumL * argSumL;
break;
}
sumL += tmpSumL;
});
return sumL;
}
function _getSumB(T) {
const L = getMeanLongitude(T);
const D = getMeanElongation(T);
const Msun = calculations_2.sunCalc.getMeanAnomaly(T);
const Mmoon = getMeanAnomaly(T);
const F = getArgumentOfLatitude(T);
const A1 = 119.75 + 131.849 * T;
const A3 = 313.45 + 481266.484 * T;
const E = 1 - 0.002516 * T - 0.0000074 * Math.pow(T, 2);
let sumB = -2235 * Math.sin((0, angleCalc_1.deg2rad)(L))
+ 382 * Math.sin((0, angleCalc_1.deg2rad)(A3))
+ 175 * Math.sin((0, angleCalc_1.deg2rad)(A1 - F))
+ 175 * Math.sin((0, angleCalc_1.deg2rad)(A1 + F))
+ 127 * Math.sin((0, angleCalc_1.deg2rad)(L - Mmoon))
- 115 * Math.sin((0, angleCalc_1.deg2rad)(L + Mmoon));
calculations_3.MOON_ARGUMENTS_B.forEach((args) => {
const argD = args[0];
const argMsun = args[1];
const argMmoon = args[2];
const argF = args[3];
const argSumB = args[4];
let tmpSumB = Math.sin((0, angleCalc_1.deg2rad)(argD * D + argMsun * Msun + argMmoon * Mmoon + argF * F));
switch (argMsun) {
case 1:
case -1:
tmpSumB = tmpSumB * argSumB * E;
break;
case 2:
case -2:
tmpSumB = tmpSumB * argSumB * Math.pow(E, 2);
break;
default:
tmpSumB = tmpSumB * argSumB;
break;
}
sumB += tmpSumB;
});
return sumB;
}
function getOpticalLiberationInLongitude(longitude, latitude, T) {
const latRad = (0, angleCalc_1.deg2rad)(latitude);
const i = 1.54242;
const iRad = (0, angleCalc_1.deg2rad)(i);
const phi = calculations_1.earthCalc.getNutationInLongitude(T);
const F = getArgumentOfLatitude(T);
const Omega = getMeanLongitudeOfAscendingNode(T);
const W = (0, angleCalc_1.normalizeAngle)(longitude - phi - Omega);
const WRad = (0, angleCalc_1.deg2rad)(W);
const ARad = Math.atan2(Math.sin(WRad) * Math.cos(latRad) * Math.cos(iRad) - Math.sin(latRad) * Math.sin(iRad), Math.cos(WRad) * Math.cos(latRad));
const A = (0, angleCalc_1.normalizeAngle)((0, angleCalc_1.rad2deg)(ARad));
return A - F;
}
exports.getOpticalLiberationInLongitude = getOpticalLiberationInLongitude;
function getOpticalLiberationInLatitude(longitude, latitude, T) {
const latRad = (0, angleCalc_1.deg2rad)(latitude);
const i = 1.54242;
const iRad = (0, angleCalc_1.deg2rad)(i);
const phi = calculations_1.earthCalc.getNutationInLongitude(T);
const Omega = getMeanLongitudeOfAscendingNode(T);
const W = (0, angleCalc_1.normalizeAngle)(longitude - phi - Omega);
const WRad = (0, angleCalc_1.deg2rad)(W);
const bRad = Math.asin(-1 * Math.sin(WRad) * Math.cos(latRad) * Math.sin(iRad) - Math.sin(latRad) * Math.cos(iRad));
return (0, angleCalc_1.rad2deg)(bRad);
}
exports.getOpticalLiberationInLatitude = getOpticalLiberationInLatitude;