UNPKG

ootk-core

Version:

Orbital Object Toolkit. A modern typed replacement for satellite.js including SGP4 propagation, TLE parsing, Sun and Moon calculations, and more.

138 lines (137 loc) 5.4 kB
/** * @author Theodore Kruczek. * @license MIT * @copyright (c) 2022-2025 Theodore Kruczek Permission is * hereby granted, free of charge, to any person obtaining a copy of this * software and associated documentation files (the "Software"), to deal in the * Software without restriction, including without limitation the rights to use, * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of * the Software, and to permit persons to whom the Software is furnished to do * so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * @copyright (c) 2011-2015, Vladimir Agafonkin * @copyright (c) 2022 Robert Gester https://github.com/hypnos3/suncalc3 * @see suncalc.LICENSE.md * Some of the math in this file was originally created by Vladimir Agafonkin. * Robert Gester's update was referenced for documentation. There were a couple * of bugs in both versions so there will be some differences if you are * migrating from either to this library. * * suncalc is a JavaScript library for calculating sun/moon position and light * phases. https://github.com/mourner/suncalc * It was reworked and enhanced by Robert Gester. * * The original suncalc is released under the terms of the BSD 2-Clause License. * @see http://aa.quae.nl/en/reken/hemelpositie.html * moon calculations are based on formulas from this website */ import { Degrees, Kilometers, RaDec, Radians } from '../main.js'; import { Vector3D } from '../operations/Vector3D.js'; import { EpochUTC } from '../time/EpochUTC.js'; type MoonIlluminationData = { fraction: number; phase: { from: number; to: number; id: string; emoji: string; code: string; name: string; weight: number; css: string; }; phaseValue: number; angle: number; next: { value: number; date: string; type: string; newMoon: { value: number; date: string; }; fullMoon: { value: number; date: string; }; firstQuarter: { value: number; date: string; }; thirdQuarter: { value: number; date: string; }; }; }; export declare class Moon { private constructor(); static readonly mu = 4902.799; static readonly radiusEquator = 1738; static eci(epoch?: EpochUTC): Vector3D<Kilometers>; /** * Calculates the illumination of the Moon at a given epoch. * @param epoch - The epoch in UTC. * @param origin - The origin vector. Defaults to the origin vector if not provided. * @returns The illumination of the Moon, ranging from 0 to 1. */ static illumination(epoch: EpochUTC, origin?: Vector3D<Kilometers>): number; /** * Calculates the diameter of the Moon. * @param obsPos - The position of the observer. * @param moonPos - The position of the Moon. * @returns The diameter of the Moon. */ static diameter(obsPos: Vector3D, moonPos: Vector3D): number; /** * calculations for illumination parameters of the moon, based on * http://idlastro.gsfc.nasa.gov/ftp/pro/astro/mphase.pro formulas and Chapter 48 of "Astronomical Algorithms" 2nd * edition by Jean Meeus (Willmann-Bell, Richmond) 1998. * @param date Date object or timestamp for calculating moon-illumination * @returns result object of moon-illumination */ static getMoonIllumination(date: number | Date): MoonIlluminationData; static rae(date: Date, lat: Degrees, lon: Degrees): { az: Radians; el: Radians; rng: Kilometers; parallacticAngle: Radians; }; /** * calculations for moon rise/set times are based on http://www.stargazing.net/kepler/moonrise.html article * @param date Date object or timestamp for calculating moon rise/set * @param lat Latitude of observer in degrees * @param lon Longitude of observer in degrees * @param isUtc If true, date will be interpreted as UTC * @returns result object of moon rise/set */ static getMoonTimes(date: Date, lat: Degrees, lon: Degrees, isUtc?: boolean): { rise: Date | null; set: Date | null; ye: number | null; alwaysUp: boolean | null; alwaysDown: boolean | null; highest: Date | null; }; private static hoursLater_; /** * Calculates the geocentric ecliptic coordinates of the moon. * @param d - The number of days since year 2000. * @returns An object containing the right ascension, declination, and * distance to the moon. */ static moonCoords(d: number): RaDec; private static calculateRiseSetTimes_; private static readonly moonCycles_; } export {};