diff --git a/README.md b/README.md index 84cf432..85a0977 100644 --- a/README.md +++ b/README.md @@ -27,9 +27,12 @@ later refactored into this library for others to use. - [:wrench: Installation](#wrench-installation) - [Loading the Library](#loading-the-library) - [:satellite: Usage](#satellite-usage) + - [Common Patterns](#common-patterns) - [Propagating a TLE](#propagating-a-tle) - [Creating a Satellite](#creating-a-satellite) - [Creating a Sensor](#creating-a-sensor) + - [More Examples](#more-examples) + - [Changelog](#changelog) - [:desktop\_computer: Building](#desktop_computer-building) - [:gem: NPM Scripts](#gem-npm-scripts) - [:man\_teacher: Contributing](#man_teacher-contributing) @@ -57,6 +60,16 @@ const satellite = new Satellite({ ## :satellite: Usage +### Common Patterns + +- If you don't specify a date, the method will assume you want to use the current date/time. +- Many parameters are in shorthand - Ex: `sensor.rng`. +- Changing a variable requires you to cast its units before using it as a parameters - Ex: `(3.14 * -1) as Radians` +- Methods starting with 'to' change the class - Ex: `satellite.toGeodetic()` or `satellite.toITRF()` + - Methods that are optimized for loops are marked as `@variation optimized` + - Methods that are slower with expanded capabilities are marked as `@variation expanded` +- Class parameters assume degrees and specify radians - Ex: `sensor.az` is in `degrees` and `sensor.azRad` is in `radians`. + ### Propagating a TLE ```js @@ -112,12 +125,22 @@ sat.rae(sensor, time); // Get position in range, aziimuth, elevation relative to ### Creating a Sensor ```js -const sensor = new Ootk.Sensor({ name: 'Test', lat: lat, lon: lon, alt: alt }); +import { GroundPosition } from 'ootk-core'; + +const sensor = new GroundPosition({ name: 'Test', lat: lat, lon: lon, alt: alt }); sensor.rae(sat); // Get satellite position in range, aziimuth, elevation at the sensor's current time sensor.rae(sat, time); // Get position in range, aziimuth, elevation relative to a satellite object at the given time sensor.eci() // Get the sensor's position in ECI coordinates ``` +### More Examples + +More examples can be found in the `examples` folder of the code. + +## Changelog + +You can find a [list of changes here](https://github.com/thkruz/ootk-core/blob/main/CHANGELOG.md). + ## :desktop_computer: Building 1. Install [Node.js](https://nodejs.org/) and [Node Package Manager](https://www.npmjs.com/); diff --git a/examples/satellite-js-migration.js b/examples/satellite-js-migration.js index aebe304..10048f3 100644 --- a/examples/satellite-js-migration.js +++ b/examples/satellite-js-migration.js @@ -71,9 +71,9 @@ 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. -const rangeCache = satellite.rae(observer, exampleDate).range; -const azimuthCached = satellite.rae(observer, exampleDate).azimuth; -const elevationCached = satellite.rae(observer, exampleDate).elevation; +const rangeCache = satellite.rae(observer, exampleDate).rng; +const azimuthCached = satellite.rae(observer, exampleDate).az; +const elevationCached = satellite.rae(observer, exampleDate).el; const latitudeCached = satellite.lla(exampleDate).lat; const longitudeCached = satellite.lla(exampleDate).lon; const heightCached = satellite.lla(exampleDate).alt; diff --git a/src/objects/Satellite.ts b/src/objects/Satellite.ts index 251cbb4..e14643d 100644 --- a/src/objects/Satellite.ts +++ b/src/objects/Satellite.ts @@ -361,7 +361,7 @@ export class Satellite extends BaseObject { * @param date - The date at which to calculate the range. Optional, defaults to the current date. * @returns The range of the satellite from the given sensor at the specified time. */ - range(observer: GroundObject, date: Date = new Date()): Kilometers { + rng(observer: GroundObject, date: Date = new Date()): Kilometers { return this.rae(observer, date).rng; } diff --git a/test/objects/Satellite.test.ts b/test/objects/Satellite.test.ts index 6cd2416..997d96f 100644 --- a/test/objects/Satellite.test.ts +++ b/test/objects/Satellite.test.ts @@ -145,7 +145,7 @@ describe('Satellite', () => { // can calculate and return range to an observer it('should calculate and return range to an observer', () => { - const range = satellite.range(observer, exampleDate); + const range = satellite.rng(observer, exampleDate); expect(range).toMatchSnapshot(); });