Skip to content

Commit

Permalink
refactor: 🏷️ export types
Browse files Browse the repository at this point in the history
  • Loading branch information
thkruz committed Jul 20, 2022
1 parent e90436b commit 12ce662
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/ootk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@
export { Sgp4 } from './sgp4';
export { Transforms } from './transforms';
export { Utils } from './utils';
export * from './types';
2 changes: 1 addition & 1 deletion src/sgp4.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
*/

import { DEG2RAD, PI, TAU, temp4, x2o3 } from './utils/constants';
import { SatelliteRecord, StateVector, Vec3Flat } from './utils/types';
import { SatelliteRecord, StateVector, Vec3Flat } from './types';

/* ----------------------------------------------------------------
*
Expand Down
2 changes: 1 addition & 1 deletion src/transforms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* SOFTWARE.
*/

import { Degrees, EcfVec3, EciVec3, Kilometer, LlaVec3, Radians, RaeVec3, SezVec3 } from './utils/types';
import { Degrees, EcfVec3, EciVec3, Kilometer, LlaVec3, Radians, RaeVec3, SezVec3 } from './types';
import { PI, TAU } from './utils/constants';

class Transforms {
Expand Down
File renamed without changes.
16 changes: 11 additions & 5 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,27 +24,33 @@
* SOFTWARE.
*/

import { EciVec3, Kilometer } from './utils/types';
import * as Types from './types';

class Utils {
public static distance(pos1: EciVec3, pos2: EciVec3): Kilometer {
public static Types = Types;

public static distance(pos1: Types.EciVec3, pos2: Types.EciVec3): Types.Kilometer {
return Math.sqrt((pos1.x - pos2.x) ** 2 + (pos1.y - pos2.y) ** 2 + (pos1.z - pos2.z) ** 2);
}

private static sign = (value: number) => (value >= 0 ? 1 : -1);

public static dopplerFactor(location: EciVec3, position: EciVec3, velocity: EciVec3): Kilometer {
public static dopplerFactor(
location: Types.EciVec3,
position: Types.EciVec3,
velocity: Types.EciVec3,
): Types.Kilometer {
const mfactor = 7.292115e-5;
const c = 299792.458; // Speed of light in km/s

const range = <EciVec3>{
const range = <Types.EciVec3>{
x: position.x - location.x,
y: position.y - location.y,
z: position.z - location.z,
};
const distance = Math.sqrt(range.x ** 2 + range.y ** 2 + range.z ** 2);

const rangeVel = <EciVec3>{
const rangeVel = <Types.EciVec3>{
x: velocity.x + mfactor * location.y,
y: velocity.y - mfactor * location.x,
z: velocity.z,
Expand Down

0 comments on commit 12ce662

Please sign in to comment.