Skip to content

Commit

Permalink
refactor: ♻️ fix formatting and jsdocs
Browse files Browse the repository at this point in the history
  • Loading branch information
thkruz committed Jan 15, 2024
1 parent 647eff3 commit b2eaaab
Show file tree
Hide file tree
Showing 23 changed files with 624 additions and 352 deletions.
4 changes: 2 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"sourceType": "module"
},
"plugins": ["@typescript-eslint", "jsdoc"],
"rules": {
"rules": {
"accessor-pairs": "error",
"array-bracket-newline": "error",
"array-bracket-spacing": "error",
Expand Down Expand Up @@ -209,7 +209,7 @@
"prefer-spread": "error",
"prefer-template": "error",
"quote-props": "off",
"quotes": ["off", "single"],
"quotes": ["error", "single"],
"radix": "off",
"require-atomic-updates": "error",
"require-await": "error",
Expand Down
25 changes: 23 additions & 2 deletions src/data/DataHandler.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,26 @@
/* eslint-disable class-methods-use-this */
/**
* @author Theodore Kruczek.
* @license MIT
* @copyright (c) 2022-2024 Theodore Kruczek 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:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 { egm96Data, Egm96Entry } from './values/Egm96Data';
import { hpAtmosphereData } from './values/HpAtmosphereData';
import { HpAtmosphereResult } from './values/HpAtmosphereResult';
Expand Down Expand Up @@ -48,7 +70,6 @@ export class DataHandler {

/**
* Retrieves the number of leap seconds for a given Julian date.
*
* @param jd The Julian date.
* @returns The number of leap seconds.
*/
Expand Down
2 changes: 2 additions & 0 deletions src/data/values/Egm96Data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ export class Egm96Data {
/**
* Create a new [Egm96Data] container given a list of EGM-96
* coefficient tuples [vals].
* @param vals List of EGM-96 coefficient tuples.
* @returns A new [Egm96Data] object.
*/
static fromVals(vals: Egm96Entry[]): Egm96Data {
const output: Egm96Entry[] = [];
Expand Down
2 changes: 2 additions & 0 deletions src/data/values/Iau1980Data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export class Iau1980Data {
/**
* Create a new [Iau1980Data] container object from an array of IAU-1980
* coefficient tuples [coeffs].
* @param coeffs IAU-1980 coefficients.
* @returns A new [Iau1980Data] object.
*/
static fromCoeffs(coeffs: Array<Iau1980Entry>): Iau1980Data {
const output: Iau1980Entry[] = [];
Expand Down
25 changes: 25 additions & 0 deletions src/data/values/LeapSecondData.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
/**
* @author Theodore Kruczek.
* @license MIT
* @copyright (c) 2022-2024 Theodore Kruczek 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:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 { LeapSecond } from './LeapSecond';
// / Leap second value tuples.
const leapSeconds: Array<[number, number]> = [
Expand Down Expand Up @@ -50,6 +73,8 @@ class LeapSecondData {
/**
* Create a new [LeapSecondData] container given a list of leap second
* value tuples [vals].
* @param vals Leap second value tuples.
* @returns A new [LeapSecondData] container.
*/
static fromVals(vals: [number, number][]): LeapSecondData {
const output: LeapSecond[] = [];
Expand Down
37 changes: 16 additions & 21 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,16 @@
/**
* @author @thkruz Theodore Kruczek
* @description Orbital Object ToolKit Core (ootk-Core) is a base collection
* of tools for working with satellites and other orbital objects. This core
* library is provided under the MIT license and is free to use in any project.
* For additional features, see the full library at:
* https://github.com/thkruz/ootk.
* @author Theodore Kruczek.
* @license MIT
* @copyright (c) 2022-2024 Theodore Kruczek 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:
*
* @license MIT License
* @Copyright (c) 2020-2024 Theodore Kruczek
*
* Many of the classes are based off of the work of @david-rc-dayton and his
* Pious Squid library (https://github.com/david-rc-dayton/pious_squid).
*
* 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:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
Expand All @@ -29,6 +19,11 @@
* 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.
* @copyright Copyright (c) 2023 David RC Dayton
*
* Many of the classes are based off of the work of @david-rc-dayton and his
* Pious Squid library
* @see https://github.com/david-rc-dayton/pious_squid
*/

export * from './enums';
Expand Down
39 changes: 17 additions & 22 deletions src/objects/Star.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,24 @@
/**
* @author Theodore Kruczek.
* @description Orbital Object ToolKit Core (ootk-core) is a collection of tools for working
* with satellites and other orbital objects.
* @license MIT
* @copyright (c) 2022-2024 Theodore Kruczek 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:
*
* @file The Star class is meant to help with cacluating star positions relative to
* satellites and earth based sensors.
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* @license MIT License
*
* @Copyright (c) 2024 Theodore Kruczek
* 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:
*
* The above copyright notice and this permission notice shall be included in all copies or
* substantial portions of the Software.
*
* 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.
* 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 Down
38 changes: 38 additions & 0 deletions src/observation/RAE.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
/**
* @author Theodore Kruczek.
* @license MIT
* @copyright (c) 2022-2024 Theodore Kruczek 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:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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.
*/

/* eslint-disable no-undefined */
import { ITRF } from '../coordinate/ITRF';
import { J2000 } from '../coordinate/J2000';
Expand Down Expand Up @@ -61,6 +84,9 @@ export class RAE {

/**
* Create a [Razel] object from an inertial [state] and [site] vector.
* @param state The inertial [state] vector.
* @param site The observer [site] vector.
* @returns A new [Razel] object.
*/
static fromStateVectors(state: J2000, site: J2000): RAE {
const stateEcef = state.toITRF();
Expand Down Expand Up @@ -136,6 +162,10 @@ export class RAE {
*
* An optional azimuth [az] _(rad)_ and elevation [el] _(rad)_ value can be
* passed to override the values contained in this observation.
* @param site The observer [site].
* @param az Azimuth _(rad)_.
* @param el Elevation _(rad)_.
* @returns A [Vector3D] object.
*/
position(site: J2000, az?: Radians, el?: Radians): Vector3D<Kilometers> {
const ecef = site.toITRF();
Expand Down Expand Up @@ -165,6 +195,8 @@ export class RAE {
*
* This will throw an error if the [rangeRate], [elevationRate], or
* [azimuthRate] are not defined.
* @param site The observer [site].
* @returns A [J2000] state vector.
*/
toStateVector(site: J2000): J2000 {
if (!this.rangeRate || !this.elevationRate || !this.azimuthRate) {
Expand Down Expand Up @@ -201,6 +233,9 @@ export class RAE {
/**
* Calculate the angular distance _(rad)_ between this and another [Razel]
* object.
* @param razel The other [Razel] object.
* @param method The angular distance method to use.
* @returns The angular distance _(rad)_.
*/
angle(razel: RAE, method: AngularDistanceMethod = AngularDistanceMethod.Cosine): number {
return angularDistance(this.azimuth, this.elevation, razel.azimuth, razel.elevation, method);
Expand All @@ -209,6 +244,9 @@ export class RAE {
/**
* Calculate the angular distance _(°)_ between this and another [Razel]
* object.
* @param razel The other [Razel] object.
* @param method The angular distance method to use.
* @returns The angular distance _(°)_.
*/
angleDegrees(razel: RAE, method: AngularDistanceMethod = AngularDistanceMethod.Cosine): number {
return this.angle(razel, method) * RAD2DEG;
Expand Down
42 changes: 42 additions & 0 deletions src/observation/RadecGeocentric.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
/**
* @author Theodore Kruczek.
* @license MIT
* @copyright (c) 2022-2024 Theodore Kruczek 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:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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.
*/

/* eslint-disable no-undefined */
import { J2000 } from '../coordinate/J2000';
import { AngularDistanceMethod } from '../enums/AngularDistanceMethod';
Expand Down Expand Up @@ -25,6 +48,14 @@ export class RadecGeocentric {
/**
* Create a new [RadecGeocentric] object, using degrees for the
* angular values.
* @param epoch UTC epoch.
* @param rightAscensionDegrees Right-ascension _(°)_.
* @param declinationDegrees Declination _(°)_.
* @param range Range _(km)_.
* @param rightAscensionRateDegrees Right-ascension rate _(°/s)_.
* @param declinationRateDegrees Declination rate _(°/s)_.
* @param rangeRate Range rate _(km/s)_.
* @returns A new [RadecGeocentric] object.
*/
static fromDegrees(
epoch: EpochUTC,
Expand Down Expand Up @@ -107,6 +138,8 @@ export class RadecGeocentric {
*
* An optional [range] _(km)_ value can be passed to override the value
* contained in this observation.
* @param range Range _(km)_.
* @returns A [Vector3D] object.
*/
position(range?: number): Vector3D {
const r = range ?? this.range ?? 1.0;
Expand All @@ -119,6 +152,9 @@ export class RadecGeocentric {
*
* An optional [range] _(km)_ and [rangeRate] _(km/s)_ value can be passed
* to override the value contained in this observation.
* @param range Range _(km)_.
* @param rangeRate Range rate _(km/s)_.
* @returns A [Vector3D] object.
*/
velocity(range?: number, rangeRate?: number): Vector3D {
if (!this.rightAscensionRate || !this.declinationRate) {
Expand All @@ -133,6 +169,9 @@ export class RadecGeocentric {
/**
* Calculate the angular distance _(rad)_ between this and another
* [RadecGeocentric] object.
* @param radec - The other [RadecGeocentric] object.
* @param method - The angular distance method to use.
* @returns The angular distance _(rad)_.
*/
angle(radec: RadecGeocentric, method: AngularDistanceMethod = AngularDistanceMethod.Cosine): number {
return angularDistance(this.rightAscension, this.declination, radec.rightAscension, radec.declination, method);
Expand All @@ -141,6 +180,9 @@ export class RadecGeocentric {
/**
* Calculate the angular distance _(°)_ between this and another
* [RadecGeocentric] object.
* @param radec - The other [RadecGeocentric] object.
* @param method - The angular distance method to use.
* @returns The angular distance _(°)_.
*/
angleDegrees(radec: RadecGeocentric, method: AngularDistanceMethod = AngularDistanceMethod.Cosine): number {
return this.angle(radec, method) * RAD2DEG;
Expand Down
Loading

0 comments on commit b2eaaab

Please sign in to comment.