Skip to content

Commit

Permalink
docs: 📝 update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
thkruz committed Jan 15, 2024
1 parent bf90e5d commit f27b230
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 23 deletions.
20 changes: 10 additions & 10 deletions examples/satellite-js-migration.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/* eslint-disable multiline-comment-style */
/* eslint-disable no-console */

import { calcGmst, DEG2RAD, GroundPosition, Satellite, Sgp4 } from '../dist/main.js';
import { calcGmst, DEG2RAD, GroundObject, Satellite, Sgp4 } from '../dist/main.js';

// Example Date
const exampleDate = new Date(1705109326817);
Expand Down Expand Up @@ -33,7 +33,7 @@ const positionEci = positionAndVelocity.position;
const velocityEci = positionAndVelocity.velocity;

// Set the Observer at 71°W, 41°N, 0.37 km altitude using DEGREES because who likes using Radians?
const observer = new GroundPosition({
const observer = new GroundObject({
lon: -71.0308,
lat: 41.9613422,
alt: 0.37,
Expand All @@ -43,10 +43,10 @@ const observer = new GroundPosition({
const { gmst, j } = calcGmst(new Date());

// You can get ECF, Geodetic, Look Angles, and Doppler Factor.
const positionEcf = satellite.ecf();
const positionEcf = satellite.ecf(exampleDate);
const observerEcf = observer.ecf();
const positionGd = satellite.lla(exampleDate);
const lookAngles = satellite.rae(observer, exampleDate);
const lookAngles = satellite.toRae(observer, exampleDate);
// This never worked in satellite.js, but it does now!
const uplinkFreq = 420e6;
const dopplerFactor = satellite.dopplerFactor(observer, exampleDate);
Expand All @@ -62,12 +62,12 @@ const satelliteY = position.y;
const satelliteZ = position.z;

// Look Angles may be accessed by `azimuth`, `elevation`, `range` properties.
const azimuth = lookAngles.azimuth; // Radians
const azimuthDegrees = lookAngles.azimuthDegrees; // Degrees
const elevation = lookAngles.elevation; // Radians
const elevationDegrees = lookAngles.elevationDegrees; // Degrees
const rangeSat = lookAngles.range; // Kilometers
const rangeRate = lookAngles.rangeRate; // Kilometers/Second
const azimuth = lookAngles.azRad; // Radians
const azimuthDegrees = lookAngles.az; // Degrees
const elevation = lookAngles.elRad; // Radains
const elevationDegrees = lookAngles.el; // Degrees
const rangeSat = lookAngles.rng; // Kilometers
const rangeRate = lookAngles.rngRate; // Kilometers/Second

// There is a built in cache to allow fast retrieval of repeated calculations.
// This means you can make repeat calls to `.rae()` for minimal performance hit.
Expand Down
16 changes: 8 additions & 8 deletions examples/satellite-js-migration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const exampleDate = new Date(1705109326817);

// Sample TLE
const tle1 = '1 56006U 23042W 24012.45049317 .00000296 00000-0 36967-4 0 9992' as TleLine1;
const tle2 = '2 56006 143.0043 13.3620 0001137 267.5965 92.4747 15.02542972 44491' as TleLine2;
const tle2 = '2 56006 43.0043 13.3620 0001137 267.5965 92.4747 15.02542972 44491' as TleLine2;

// Initialize a Satellite Object
const satellite = new Satellite({
Expand Down Expand Up @@ -48,7 +48,7 @@ const positionAndVelocity3 = satellite.eci();
* The position_velocity result is a key-value pair of ECI coordinates. These
* are the base results from which all other coordinates are derived.
*/
const positionEci = positionAndVelocity.position; // positionAndVelocity might be false
const positionEci = positionAndVelocity.position; // positionAndVelocity might fail, but
const velocityEci = positionAndVelocity.velocity; // typescript will error on this code

/*
Expand Down Expand Up @@ -99,12 +99,12 @@ const satelliteY = position.y; // to prevent you from accidentally
const satelliteZ = position.z; // mixing Meters with Kilometers.

// Look Angles may be accessed by `azimuth`, `elevation`, `range` properties.
const azimuth = lookAngles.azimuth; // Typed as Radians
const azimuthDegrees = lookAngles.azimuthDegrees; // Typed as Degrees
const elevation = lookAngles.elevation; // Typed as Radains
const elevationDegrees = lookAngles.elevationDegrees; // Typed as Degrees
const rangeSat = lookAngles.range; // Typed as Kilometers
const rangeRate = lookAngles.rangeRate; // Kilometers/Second
const azimuth = lookAngles.azRad; // Typed as Radians
const azimuthDegrees = lookAngles.az; // Typed as Degrees
const elevation = lookAngles.elRad; // Typed as Radains
const elevationDegrees = lookAngles.el; // Typed as Degrees
const rangeSat = lookAngles.rng; // Typed as Kilometers
const rangeRate = lookAngles.rngRate; // Kilometers/Second

/*
* There is a built in cache to allow fast retrieval of repeated calculations.
Expand Down
2 changes: 1 addition & 1 deletion examples/sun.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Degrees, Meters, Sun } from '../../lib/index';
import { Degrees, Meters, Sun } from '../dist/main';
/* eslint-disable no-console */

console.log(Sun.getTimes(new Date(), 41 as Degrees, -71 as Degrees, 0 as Meters));
5 changes: 4 additions & 1 deletion examples/tle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/* eslint-disable no-console */
/* eslint-disable @typescript-eslint/no-unused-vars */

import { Tle, TleLine1, TleLine2 } from '../../lib/index';
import { Tle, TleLine1, TleLine2 } from '../dist/main';

// Sample TLE
const tle1 = '1 25544U 98067A 19156.50900463 .00003075 00000-0 59442-4 0 9992' as TleLine1;
Expand Down Expand Up @@ -85,3 +85,6 @@ const tleAll = Tle.parseAll(tle1, tle2);
// checksum2: 2,
// period: 92.83287537651032
// }

console.log('TLE 1: ', tle1);
console.log('TLE 2: ', tle2);
6 changes: 3 additions & 3 deletions examples/transforms.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* eslint-disable no-console */
import { Degrees, ecf2rae, EcfVec3, GroundPosition, Kilometers, lla2ecf, lla2sez, RAD2DEG } from '../../src/ootk-core';
import { Degrees, ecf2rae, EcfVec3, GroundObject, Kilometers, lla2ecf, lla2sez, RAD2DEG } from '../dist/main';

const observer = new GroundPosition({
name: 'ground-position',
const observer = new GroundObject({
name: 'ground-object',
lat: (0.7287584767123405 * RAD2DEG) as Degrees,
lon: (-1.2311404365114507 * RAD2DEG) as Degrees,
alt: 0.060966 as Kilometers,
Expand Down

0 comments on commit f27b230

Please sign in to comment.