ootk
Version:
Orbital Object Toolkit including Multiple Propagators, Initial Orbit Determination, and Maneuver Calculations.
120 lines • 4.57 kB
JavaScript
/**
* @author @thkruz Theodore Kruczek
* @description Orbital Object ToolKit (ootk) is a collection of tools for working
* with satellites and other orbital objects.
* @license AGPL-3.0-or-later
* @copyright (c) 2025 Kruczek Labs LLC
*
* Many of the classes are based off of the work of @david-rc-dayton and his
* Pious Squid library (https://github.com/david-rc-dayton/pious_squid) which
* is licensed under the MIT license.
*
* Orbital Object ToolKit is free software: you can redistribute it and/or modify it under the
* terms of the GNU Affero General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later version.
*
* Orbital Object ToolKit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License along with
* Orbital Object ToolKit. If not, see <http://www.gnu.org/licenses/>.
*/
import { Earth } from '../body/Earth.js';
import { ITRF } from './ITRF.js';
import { StateVector } from './StateVector.js';
import { TEME } from './TEME.js';
/**
* Represents a position and velocity in the J2000 coordinate system. This is an Earth-centered inertial (ECI)
* coordinate system.
*
* Commonly used ECI frame is defined with the Earth's Mean Equator and Mean Equinox (MEME) at 12:00 Terrestrial Time on
* 1 January 2000. It can be referred to as J2K, J2000 or EME2000. The x-axis is aligned with the mean vernal equinox.
* The z-axis is aligned with the Earth's rotation axis (or equivalently, the celestial North Pole) as it was at that
* time. The y-axis is rotated by 90° East about the celestial equator.
* @see https://en.wikipedia.org/wiki/Earth-centered_inertial
*/
export class J2000 extends StateVector {
/**
* Creates a J2000 coordinate from classical elements.
* @param elements The classical elements.
* @returns The J2000 coordinate.
*/
static fromClassicalElements(elements) {
const rv = elements.toPositionVelocity();
return new J2000(elements.epoch, rv.position, rv.velocity);
}
/**
* Gets the name of the coordinate system.
* @returns The name of the coordinate system.
*/
get name() {
return 'J2000';
}
/**
* Gets a value indicating whether the coordinate system is inertial.
* @returns A boolean value indicating whether the coordinate system is inertial.
*/
get inertial() {
return true;
}
/**
* Converts the coordinates from J2000 to the International Terrestrial Reference Frame (ITRF).
* This is an ECI to ECF transformation.
* @returns The ITRF coordinates.
*/
toITRF() {
const p = Earth.precession(this.epoch);
const n = Earth.nutation(this.epoch);
const ast = (this.epoch.gmstAngle() + n.eqEq);
const rMOD = this.position
.rotZ(-p.zeta)
.rotY(p.theta)
.rotZ(-p.zed);
const vMOD = this.velocity
.rotZ(-p.zeta)
.rotY(p.theta)
.rotZ(-p.zed);
const rTOD = rMOD
.rotX(n.mEps)
.rotZ(-n.dPsi)
.rotX(-n.eps);
const vTOD = vMOD
.rotX(n.mEps)
.rotZ(-n.dPsi)
.rotX(-n.eps);
const rPEF = rTOD.rotZ(ast);
const vPEF = vTOD.rotZ(ast).add(Earth.rotation.negate().cross(rPEF));
return new ITRF(this.epoch, rPEF, vPEF);
}
/**
* Converts the J2000 coordinate to the TEME coordinate.
* @returns The TEME coordinate.
*/
toTEME() {
const p = Earth.precession(this.epoch);
const n = Earth.nutation(this.epoch);
const eps = n.mEps + n.dEps;
const dPsiCosEps = (n.dPsi * Math.cos(eps));
const rMOD = this.position
.rotZ(-p.zeta)
.rotY(p.theta)
.rotZ(-p.zed);
const vMOD = this.velocity
.rotZ(-p.zeta)
.rotY(p.theta)
.rotZ(-p.zed);
const rTEME = rMOD
.rotX(n.mEps)
.rotZ(-n.dPsi)
.rotX(-eps)
.rotZ(dPsiCosEps);
const vTEME = vMOD
.rotX(n.mEps)
.rotZ(-n.dPsi)
.rotX(-eps)
.rotZ(dPsiCosEps);
return new TEME(this.epoch, rTEME, vTEME);
}
}
//# sourceMappingURL=J2000.js.map