Skip to content

Commit

Permalink
docs: 📝 update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
thkruz committed Feb 19, 2024
1 parent 4e27633 commit 754e2e1
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 7 deletions.
27 changes: 26 additions & 1 deletion src/force/EarthGravity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,37 @@ import { DataHandler, Earth, ITRF, J2000, Kilometers, KilometersPerSecond, Vecto

import { Force } from './Force';

// / tesseral geopotential perturbations.
/**
* designed to model the Earth's gravitational field, which is not uniformly distributed due to variations in mass
* distribution within the Earth and the Earth's shape (it's not a perfect sphere). To accurately model this complex
* field, the gravity model is expanded into a series of spherical harmonics, characterized by their degree and order.
*
* This `degree` parameter is related to the spatial resolution of the gravity model. A higher degree corresponds to a
* finer resolution, capable of representing smaller-scale variations in the gravity field. The degree essentially
* denotes how many times the gravitational potential function varies over the surface of the Earth.
*
* For each degree, there can be multiple orders ranging from 0 up to the degree. The `order` accounts for the
* longitudinal variation in the gravity field. Each order within a degree captures different characteristics of the
* gravity anomalies.
*
* `Degree 0` corresponds to the overall, mean gravitational force of the Earth (considered as a point mass).
*
* `Degree 1` terms are related to the Earth's center of mass but are usually not used because the center of mass is
* defined as the origin of the coordinate system.
*
* `Degree 2` and higher capture the deviations from this spherical symmetry, such as the flattening at the poles and
* bulging at the equator (degree 2), and other anomalies at finer scales as the degree increases.
*/
export class EarthGravity implements Force {
degree: number;
order: number;
_asphericalFlag: boolean;

/**
* Creates a new instance of the EarthGravity class.
* @param degree The degree of the Earth's gravity field. Must be between 0 and 36.
* @param order The order of the Earth's gravity field. Must be between 0 and 36.
*/
constructor(degree: number, order: number) {
this.degree = Math.min(Math.max(degree, 0), 36);
this.order = Math.min(Math.max(order, 0), 36);
Expand Down
8 changes: 8 additions & 0 deletions src/force/ForceModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ export class ForceModel {
this._solarRadiationPressure = new SolarRadiationPressure(mass, area, coeff);
}

/**
* Sets the atmospheric drag for the force model.
* @deprecated This is still a work in progress!
* @param mass - The mass of the object.
* @param area - The cross-sectional area of the object.
* @param coeff - The drag coefficient. Default value is 2.2.
* @param cosine - The cosine of the angle between the object's velocity vector and the drag force vector.
*/
setAtmosphericDrag(mass: number, area: number, coeff = 2.2, cosine = 4): void {
this._atmosphericDrag = new AtmosphericDrag(mass, area, coeff, cosine);
}
Expand Down
8 changes: 4 additions & 4 deletions src/orbit_determination/BatchLeastSquaresOD.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ import { BatchLeastSquaresResult } from './BatchLeastSquaresResult';
* Batch least squares orbit determination.
*/
export class BatchLeastSquaresOD {
// / Propagator pair cache, for generating observation Jacobians.
/** Propagator pair cache, for generating observation Jacobians. */
private propPairs_: PropagatorPairs;
// / Nominal state propagator.
/** Nominal state propagator. */
private propagator_: Propagator;
// / State estimate during solve.
/** State estimate during solve. */
private nominal_: J2000;
// / Solve start epoch.
/** Solve start epoch. */
private start_: EpochUTC;

/**
Expand Down
44 changes: 42 additions & 2 deletions src/propagator/Sgp4Propagator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@ import { Thrust } from '../force/Thrust';
import { VerletBlendInterpolator } from '../interpolator/VerletBlendInterpolator';
import { Propagator } from './Propagator';

// / SGP4 propagator.
/**
* Sgp4Propagator is a propagator that uses the SGP4 model to propagate the state of an object.
* This class is useful for propagating multiple states with the same TLE, since it caches the
* state of the TLE at different epochs.
*/
export class Sgp4Propagator extends Propagator {
// / Create a new [Sgp4Propagator] object from a [TLE].
constructor(private tle: Tle) {
super();
this._cacheState = tle.state.toJ2000();
Expand All @@ -33,38 +36,75 @@ export class Sgp4Propagator extends Propagator {
private _cacheState: J2000;
private _checkpoints: J2000[] = [];

/**
* Gets the state of the propagator in the J2000 coordinate system.
* @returns The J2000 state of the propagator.
*/
get state(): J2000 {
return this._cacheState;
}

/**
* Calculates the ephemeris maneuver using the SGP4 propagator.
* @param start The start epoch in UTC.
* @param finish The finish epoch in UTC.
* @param maneuvers The array of thrust maneuvers.
* @param interval The time interval in seconds.
*/
ephemerisManeuver(start: EpochUTC, finish: EpochUTC, maneuvers: Thrust[], interval = 60.0): VerletBlendInterpolator {
throw new Error('Maneuvers cannot be modelled with SGP4.');
}

/**
* Performs a maneuver with the given thrust.
* @param maneuver - The thrust maneuver to perform.
* @param interval - The time interval for the maneuver (default: 60.0 seconds).
* @throws Error if maneuvers cannot be modeled with SGP4.
*/
maneuver(maneuver: Thrust, interval = 60.0): J2000[] {
throw new Error('Maneuvers cannot be modelled with SGP4.');
}

/**
* Propagates the state of the Sgp4Propagator to a specified epoch in J2000 coordinates.
* @param epoch - The epoch in UTC format.
* @returns The propagated state in J2000 coordinates.
*/
propagate(epoch: EpochUTC): J2000 {
this._cacheState = this.tle.propagate(epoch).toJ2000();

return this._cacheState;
}

/**
* Resets the state of the Sgp4Propagator by updating the cache state
* to the current J2000 state of the TLE.
*/
reset(): void {
this._cacheState = this.tle.state.toJ2000();
}

/**
* Saves the current state of the propagator and returns the index of the checkpoint.
* @returns The index of the checkpoint.
*/
checkpoint(): number {
this._checkpoints.push(this._cacheState);

return this._checkpoints.length - 1;
}

/**
* Clears all the checkpoints in the propagator.
*/
clearCheckpoints(): void {
this._checkpoints = [];
}

/**
* Restores the state of the propagator to a previously saved checkpoint.
* @param index - The index of the checkpoint to restore.
*/
restore(index: number): void {
this._cacheState = this._checkpoints[index];
}
Expand Down

0 comments on commit 754e2e1

Please sign in to comment.