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.

59 lines 2.59 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. */ import { Celestial, ecf2eci, jday, MILLISECONDS_TO_DAYS, rae2ecf, Sgp4, SpaceObjectType, } from '../main.js'; import { BaseObject } from './BaseObject.js'; export class Star extends BaseObject { ra; dec; bf; h; pname; vmag; constructor(info) { super(info); this.type = SpaceObjectType.STAR; this.ra = info.ra; this.dec = info.dec; this.pname = info.pname ?? ''; this.bf = info.bf ?? ''; this.h = info.h ?? ''; this.vmag = info.vmag; } eci(lla = { lat: 180, lon: 0, alt: 0 }, date = new Date()) { const rae = this.rae(lla, date); const { gmst } = Star.calculateTimeVariables_(date); // Arbitrary distance to enable using ECI coordinates return ecf2eci(rae2ecf(rae, { lat: 0, lon: 0, alt: 0 }), gmst); } rae(lla = { lat: 180, lon: 0, alt: 0 }, date = new Date()) { const starPos = Celestial.azEl(date, lla.lat, lla.lon, this.ra, this.dec); return { az: starPos.az, el: starPos.el, rng: 250000 }; } static calculateTimeVariables_(date) { const j = jday(date.getUTCFullYear(), date.getUTCMonth() + 1, date.getUTCDate(), date.getUTCHours(), date.getUTCMinutes(), date.getUTCSeconds()) + date.getUTCMilliseconds() * MILLISECONDS_TO_DAYS; const gmst = Sgp4.gstime(j); return { gmst, j }; } } //# sourceMappingURL=Star.js.map