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.

115 lines (114 loc) 5.84 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const AstronomicalObject_1 = __importDefault(require("../astronomicalObject/AstronomicalObject")); const calculationCache_1 = require("../cache/calculationCache"); const coordinateCalc_1 = require("../coordinates/calculations/coordinateCalc"); const vsop87Calc_1 = require("../planets/calculations/vsop87Calc"); const angleCalc_1 = require("../utils/angleCalc"); const calculations_1 = require("./calculations"); class Earth extends AstronomicalObject_1.default { constructor(toi) { super(toi, 'earth'); } getHeliocentricEclipticRectangularJ2000Coordinates() { return __awaiter(this, void 0, void 0, function* () { const coords = yield this.getHeliocentricEclipticSphericalJ2000Coordinates(); return (0, coordinateCalc_1.spherical2rectangular)(coords); }); } getHeliocentricEclipticRectangularDateCoordinates() { return __awaiter(this, void 0, void 0, function* () { const coords = yield this.getHeliocentricEclipticSphericalDateCoordinates(); return (0, coordinateCalc_1.spherical2rectangular)(coords); }); } getHeliocentricEclipticSphericalJ2000Coordinates() { return __awaiter(this, void 0, void 0, function* () { return yield (0, calculationCache_1.getAsyncCachedCalculation)('earth_heliocentric_spherical_j2000', this.t, () => __awaiter(this, void 0, void 0, function* () { const vsop87 = yield Promise.resolve().then(() => __importStar(require('./vsop87/vsop87EarthSphericalJ2000'))); return { lon: (0, angleCalc_1.normalizeAngle)((0, vsop87Calc_1.calculateVSOP87Angle)(vsop87.VSOP87_X, this.t)), lat: (0, vsop87Calc_1.calculateVSOP87Angle)(vsop87.VSOP87_Y, this.t), radiusVector: (0, vsop87Calc_1.calculateVSOP87)(vsop87.VSOP87_Z, this.t), }; })); }); } getHeliocentricEclipticSphericalDateCoordinates() { return __awaiter(this, void 0, void 0, function* () { return yield (0, calculationCache_1.getAsyncCachedCalculation)('earth_heliocentric_spherical_date', this.t, () => __awaiter(this, void 0, void 0, function* () { const vsop87 = yield Promise.resolve().then(() => __importStar(require('./vsop87/vsop87EarthSphericalDate'))); return { lon: (0, angleCalc_1.normalizeAngle)((0, vsop87Calc_1.calculateVSOP87Angle)(vsop87.VSOP87_X, this.t)), lat: (0, vsop87Calc_1.calculateVSOP87Angle)(vsop87.VSOP87_Y, this.t), radiusVector: (0, vsop87Calc_1.calculateVSOP87)(vsop87.VSOP87_Z, this.t), }; })); }); } getGeocentricEclipticRectangularJ2000Coordinates() { return Promise.resolve({ x: 0, y: 0, z: 0 }); } getGeocentricEclipticRectangularDateCoordinates() { return Promise.resolve({ x: 0, y: 0, z: 0 }); } getGeocentricEclipticSphericalJ2000Coordinates() { return Promise.resolve({ lon: 0, lat: 0, radiusVector: 0 }); } getGeocentricEclipticSphericalDateCoordinates() { return Promise.resolve({ lon: 0, lat: 0, radiusVector: 0 }); } getApparentGeocentricEclipticSphericalCoordinates() { return __awaiter(this, void 0, void 0, function* () { return Promise.resolve({ lon: 0, lat: 0, radiusVector: 0 }); }); } getNutationInLongitude() { return calculations_1.earthCalc.getNutationInLongitude(this.T); } getNutationInObliquity() { return calculations_1.earthCalc.getNutationInObliquity(this.T); } getMeanObliquityOfEcliptic() { return calculations_1.earthCalc.getMeanObliquityOfEcliptic(this.T); } getTrueObliquityOfEcliptic() { return calculations_1.earthCalc.getTrueObliquityOfEcliptic(this.T); } } exports.default = Earth;