UNPKG

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.

28 lines (27 loc) 860 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.calculateVSOP87 = exports.calculateVSOP87Angle = void 0; const angleCalc_1 = require("../../utils/angleCalc"); function calculateVSOP87Angle(terms, t) { const result = calculateVSOP87(terms, t); return (0, angleCalc_1.rad2deg)(result); } exports.calculateVSOP87Angle = calculateVSOP87Angle; function calculateVSOP87(terms, t) { let result = 0.0; terms.forEach((term, key) => { result += _sumUpTerm(term, t) * Math.pow(t, key); }); return result; } exports.calculateVSOP87 = calculateVSOP87; function _sumUpTerm(terms, t) { let result = 0.0; terms.forEach((term) => { const a = term[0] || 0; const b = term[1] || 0; const c = term[2] || 0; result += a * Math.cos(b + c * t); }); return result; }