Skip to content

Commit

Permalink
feat: ✨ update transforms
Browse files Browse the repository at this point in the history
  • Loading branch information
thkruz committed Jan 1, 2024
1 parent 20bc194 commit c6824a4
Show file tree
Hide file tree
Showing 55 changed files with 1,010 additions and 858 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"callback-return": "error",
"camelcase": "error",
"capitalized-comments": "off",
"class-methods-use-this": "error",
"class-methods-use-this": "off",
"comma-dangle": ["error", "always-multiline"],
"comma-spacing": "error",
"comma-style": "error",
Expand Down
18 changes: 16 additions & 2 deletions examples/sensor.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable no-console */
import { Satellite } from '@src/objects/Satellite';
import { Sensor } from '../src/objects';
import { Degrees, Kilometers, SpaceObjectType, TleLine1, TleLine2 } from '../src/ootk';
import { Degrees, Kilometers, SpaceObjectType, TleLine1, TleLine2, Transforms } from '../src/ootk';

const capeCodRadar = new Sensor({
lat: <Degrees>41.754785,
Expand All @@ -17,14 +17,28 @@ const capeCodRadar = new Sensor({
type: SpaceObjectType.PHASED_ARRAY_RADAR,
});

const testSensor = new Sensor({
lat: <Degrees>41,
lon: <Degrees>-71,
alt: <Kilometers>1,
});

const sat = new Satellite({
tle1: '1 00005U 58002B 23361.70345217 .00000401 00000-0 53694-3 0 99999' as TleLine1,
tle2: '2 00005 34.2395 218.8683 1841681 30.7692 338.8934 10.85144797345180' as TleLine2,
});

const date = new Date('2023-12-31T20:51:19.934Z');

sat.propagateTo(date);
const rae = Transforms.ecf2rae(testSensor, {
x: 4000 as Kilometers,
y: 7000 as Kilometers,
z: 3000 as Kilometers,
});

console.log(rae);

// sat.propagateTo(date);

// console.log(sat.raeOpt(capeCodRadar, date));
console.log(sat.getJ2000().inertial);
3 changes: 1 addition & 2 deletions src/body/Celestial.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { AzEl, RaDec, Radians } from '@src/ootk';
import { AzEl, Degrees, RaDec, Radians } from '@src/ootk';
import { RAD2DEG } from '@src/utils/constants';
import { Degrees } from './../../lib/types/types.d';
import { Sun } from './Sun';

export class Celestial {
Expand Down
13 changes: 3 additions & 10 deletions src/body/Earth.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
import { Radians } from '@src/ootk';
import { EpochUTC } from '@src/time/EpochUTC';
import { AngularDiameterMethod } from '@src/types/types';
import { DataHandler } from '../data/DataHandler';
import {
asec2rad,
deg2rad,
rad2deg,
secondsPerDay,
secondsPerSiderealDay,
tau,
ttasec2rad,
} from '../operations/constants';
import { angularDiameter, AngularDiameterMethod, evalPoly } from '../operations/functions';
import { Vector3D } from '../operations/Vector3D';
import { asec2rad, deg2rad, rad2deg, secondsPerDay, secondsPerSiderealDay, tau, ttasec2rad } from '../utils/constants';
import { angularDiameter, evalPoly } from '../utils/functions';
import { NutationAngles } from './NutationAngles';
import { PrecessionAngles } from './PrecessionAngles';

Expand Down
5 changes: 3 additions & 2 deletions src/body/Moon.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { EpochUTC } from '@src/time/EpochUTC';
import { deg2rad } from '../operations/constants';
import { angularDiameter, AngularDiameterMethod } from '../operations/functions';
import { AngularDiameterMethod } from '@src/types/types';
import { Vector3D } from '../operations/Vector3D';
import { deg2rad } from '../utils/constants';
import { angularDiameter } from '../utils/functions';
import { Earth } from './Earth';
import { Sun } from './Sun';

Expand Down
7 changes: 3 additions & 4 deletions src/body/Sun.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { AzEl, Degrees, Kilometers, Meters, Radians, SunTime } from '@src/ootk';
import { EpochUTC } from '@src/time/EpochUTC';
import { RaDec } from '@src/types/types';
import { astronomicalUnit, deg2rad, speedOfLight, tau } from '../operations/constants';
import { angularDiameter, AngularDiameterMethod } from '../operations/functions';
import { AngularDiameterMethod, RaDec } from '@src/types/types';
import { Vector3D } from '../operations/Vector3D';
import { DEG2RAD, MS_PER_DAY } from '../utils/constants';
import { astronomicalUnit, deg2rad, DEG2RAD, MS_PER_DAY, speedOfLight, tau } from '../utils/constants';
import { angularDiameter } from '../utils/functions';
import { Celestial } from './Celestial';
import { Earth } from './Earth';

Expand Down
5 changes: 2 additions & 3 deletions src/coordinate/ClassicalElements.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { EpochUTC } from '@src/time/EpochUTC';
import { Earth } from '../body/Earth';
import { sec2min, secondsPerDay } from '../operations/constants';
import { clamp, matchHalfPlane, newtonNu } from '../operations/functions';
import { Vector3D } from '../operations/Vector3D';
import { rad2deg, tau } from './../operations/constants';
import { rad2deg, sec2min, secondsPerDay, tau } from '../utils/constants';
import { clamp, matchHalfPlane, newtonNu } from '../utils/functions';
import { EquinoctialElements } from './EquinoctialElements';
import { OrbitRegime } from './OrbitRegime';
import { PositionVelocity, StateVector } from './StateVector';
Expand Down
4 changes: 2 additions & 2 deletions src/coordinate/EquinoctialElements.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { EpochUTC } from '@src/time/EpochUTC';
import { Earth } from '../body/Earth';
import { newtonM } from '../operations/functions';
import { secondsPerDay, tau } from './../operations/constants';
import { secondsPerDay, tau } from '../utils/constants';
import { newtonM } from '../utils/functions';
import { ClassicalElements } from './ClassicalElements';
import { PositionVelocity } from './StateVector';
/** Equinoctial element set. */
Expand Down
5 changes: 3 additions & 2 deletions src/coordinate/Geodetic.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { EpochUTC } from '@src/time/EpochUTC';
import { AngularDistanceMethod } from '@src/types/types';
import { Earth } from '../body/Earth';
import { deg2rad, rad2deg } from '../operations/constants';
import { angularDistance, AngularDistanceMethod } from '../operations/functions';
import { Vector3D } from '../operations/Vector3D';
import { deg2rad, rad2deg } from '../utils/constants';
import { angularDistance } from '../utils/functions';
import { ITRF } from './ITRF';

// / Geodetic coordinates.
Expand Down
2 changes: 1 addition & 1 deletion src/coordinate/StateVector.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { EpochUTC } from '@src/time/EpochUTC';
import { Earth } from '../body/Earth';
import { Vector3D } from '../operations/Vector3D';
import { tau } from './../operations/constants';
import { tau } from '../utils/constants';
import { ClassicalElements } from './ClassicalElements';

// / Position and velocity [Vector3D] container.
Expand Down
2 changes: 1 addition & 1 deletion src/coordinate/TLE.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { EciVec3, SatelliteRecord, StateVectorSgp4 } from '@src/ootk';
import { Sgp4, Sgp4GravConstants } from '@src/sgp4/sgp4';
import { EpochUTC } from '@src/time/EpochUTC';
import { Earth } from '../body/Earth';
import { deg2rad, rad2deg, secondsPerDay, tau } from '../operations/constants';
import { Vector3D } from '../operations/Vector3D';
import { deg2rad, rad2deg, secondsPerDay, tau } from '../utils/constants';
import { TEME } from './TEME';

export enum Sgp4OpsMode {
Expand Down
2 changes: 1 addition & 1 deletion src/data/values/Egm96Data.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { factorial } from '../../operations/functions';
import { factorial } from '../../utils/functions';
import { egm96 } from './egm96';

// / EGM-96 entry for l, m indexes and clm, slm values.
Expand Down
2 changes: 1 addition & 1 deletion src/force/AtmosphericDrag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { Earth } from '../body/Earth';
import { ITRF } from '../coordinate/ITRF';
import { J2000 } from '../coordinate/J2000';
import { DataHandler } from '../data/DataHandler';
import { deg2rad } from '../operations/constants';
import { Vector3D } from '../operations/Vector3D';
import { deg2rad } from '../utils/constants';
import { Sun } from './../body/Sun';
import { Force } from './Force';

Expand Down
2 changes: 1 addition & 1 deletion src/force/SolarRadiationPressure.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Sun } from '../body/Sun';
import { J2000 } from '../coordinate/J2000';
import { astronomicalUnit } from '../operations/constants';
import { Vector3D } from '../operations/Vector3D';
import { astronomicalUnit } from '../utils/constants';
import { Force } from './Force';

// / Solar radiation pressure model.
Expand Down
2 changes: 1 addition & 1 deletion src/interpolator/VerletBlendInterpolator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { EpochUTC } from '@src/time/EpochUTC';
import { EpochWindow } from '@src/time/EpochWindow';
import { Earth } from '../body/Earth';
import { J2000 } from '../coordinate/J2000';
import { copySign } from '../operations/functions';
import { Vector3D } from '../operations/Vector3D';
import { copySign } from '../utils/functions';
import { CubicSplineInterpolator } from './CubicSplineInterpolator';
import { LagrangeInterpolator } from './LagrangeInterpolator';
import { StateInterpolator } from './StateInterpolator';
Expand Down
53 changes: 20 additions & 33 deletions src/objects/.detailed-sat.ts → src/objects/DetailedSatellite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,43 +6,30 @@
* @file The DetailedSat class is an extension of the Sat class that provides additional
* properties for categorizing and filtering satellites.
*
* @license AGPL-3.0-or-later
* @Copyright (c) 2020-2023 Theodore Kruczek
* @license MIT License
* @Copyright (c) 2020-2024 Theodore Kruczek
*
* 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.
* 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:
*
* 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.
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* 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/>.
* 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 {
LaunchDetails,
OperationsDetails,
SpaceCraftDetails,
SpaceObjectType,
TleLine1,
TleLine2,
} from '../types/types';

import { OptionsParams, Satellite } from './Satellite';

/**
* Information about a space object.
*/
interface ObjectInfo {
name?: string;
rcs?: number;
tle1: TleLine1;
tle2: TleLine2;
type?: SpaceObjectType;
vmag?: number;
}
import { LaunchDetails, OperationsDetails, SpaceCraftDetails } from '../types/types';
import { OptionsParams, Satellite, SatelliteObjectParams } from './Satellite';

/**
* Represents a detailed satellite object with launch, spacecraft, and operations details.
Expand Down Expand Up @@ -70,7 +57,7 @@ export class DetailedSat extends Satellite {
user: string;

constructor(
info: ObjectInfo,
info: SatelliteObjectParams,
options: OptionsParams,
details: {
launchDetails: LaunchDetails;
Expand Down
46 changes: 23 additions & 23 deletions src/objects/Satellite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,29 @@
* @description Orbital Object ToolKit (OOTK) is a collection of tools for working
* with satellites and other orbital objects.
*
* @file The Sat class provides functions for calculating satellites positions relative
* to earth based sensors and other orbital objects.
* @file The Satellite class provides functions for calculating satellites positions
* relative to earth based sensors and other orbital objects.
*
* @license AGPL-3.0-or-later
* @Copyright (c) 2020-2023 Theodore Kruczek
* @license MIT License
* @Copyright (c) 2020-2024 Theodore Kruczek
*
* Orbital Object ToolKit is free software: you can redistribute it and/or modify it under the
* terms of the GNU Affero General License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later version.
* 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:
*
* 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 License for more details.
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* You should have received a copy of the GNU Affero General License along with
* Orbital Object ToolKit. If not, see <http://www.gnu.org/licenses/>.
* 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 {
Expand All @@ -41,15 +48,13 @@ import { DAY_TO_MS, DEG2RAD, MINUTES_PER_DAY, RAD2DEG } from '../utils/constants
import { Geodetic } from '@src/coordinate/Geodetic';
import { ITRF } from '@src/coordinate/ITRF';
import { J2000 } from '@src/coordinate/J2000';
import { Sensor } from '@src/objects';
import { RAE } from '@src/observation/RAE';
import { Transforms } from '@src/ootk';
import { Transforms, Utils } from '@src/ootk';
import { Vector3D } from '@src/operations/Vector3D';
import { EpochUTC } from '@src/time/EpochUTC';
import { Sgp4 } from '../sgp4/sgp4';
import { Tle } from '../tle/tle';
import { Utils } from '../utils/utils';
import { Sensor } from './sensor';

/**
* TODO: Reduce unnecessary calls to calculateTimeVariables using optional
* parameters and caching.
Expand All @@ -58,7 +63,7 @@ import { Sensor } from './sensor';
/**
* Information about a space object.
*/
interface SatelliteObjectParams {
export interface SatelliteObjectParams {
name?: string;
rcs?: number;
tle1: TleLine1;
Expand Down Expand Up @@ -259,13 +264,8 @@ export class Satellite {
const { gmst } = Satellite.calculateTimeVariables(date, this.satrec);
const eci = this.getEci(date).position;
const ecf = Transforms.eci2ecf(eci, gmst);
const rae = Transforms.ecf2rae(sensor, ecf);

return {
az: (rae.az * RAD2DEG) as Degrees,
el: (rae.el * RAD2DEG) as Degrees,
rng: rae.rng,
};
return Transforms.ecf2rae(sensor, ecf);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/objects/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export { Satellite as Sat } from './Satellite';

Check failure on line 1 in src/objects/index.ts

View workflow job for this annotation

GitHub Actions / build

Cannot find module './Sensor' or its corresponding type declarations.
export { Sensor } from './sensor';
export { Sensor } from './Sensor';
export { Star } from './star';
Loading

0 comments on commit c6824a4

Please sign in to comment.