diff --git a/.eslintrc.json b/.eslintrc.json index badb2f6..2413405 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -12,7 +12,7 @@ "sourceType": "module" }, "plugins": ["@typescript-eslint", "jsdoc"], - "rules": { + "rules": { "accessor-pairs": "error", "array-bracket-newline": "error", "array-bracket-spacing": "error", @@ -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", diff --git a/src/data/DataHandler.ts b/src/data/DataHandler.ts index eac1e61..8328745 100644 --- a/src/data/DataHandler.ts +++ b/src/data/DataHandler.ts @@ -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'; @@ -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. */ diff --git a/src/data/values/Egm96Data.ts b/src/data/values/Egm96Data.ts index 3277670..a98bba9 100644 --- a/src/data/values/Egm96Data.ts +++ b/src/data/values/Egm96Data.ts @@ -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[] = []; diff --git a/src/data/values/Iau1980Data.ts b/src/data/values/Iau1980Data.ts index 465daea..49ea018 100644 --- a/src/data/values/Iau1980Data.ts +++ b/src/data/values/Iau1980Data.ts @@ -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): Iau1980Data { const output: Iau1980Entry[] = []; diff --git a/src/data/values/LeapSecondData.ts b/src/data/values/LeapSecondData.ts index 57986db..b6cf265 100644 --- a/src/data/values/LeapSecondData.ts +++ b/src/data/values/LeapSecondData.ts @@ -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]> = [ @@ -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[] = []; diff --git a/src/main.ts b/src/main.ts index 8eac7ca..2d976ea 100644 --- a/src/main.ts +++ b/src/main.ts @@ -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, @@ -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'; diff --git a/src/objects/Star.ts b/src/objects/Star.ts index d01b050..d318794 100644 --- a/src/objects/Star.ts +++ b/src/objects/Star.ts @@ -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 { diff --git a/src/observation/RAE.ts b/src/observation/RAE.ts index 62d00ab..0398bcc 100644 --- a/src/observation/RAE.ts +++ b/src/observation/RAE.ts @@ -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'; @@ -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(); @@ -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 { const ecef = site.toITRF(); @@ -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) { @@ -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); @@ -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; diff --git a/src/observation/RadecGeocentric.ts b/src/observation/RadecGeocentric.ts index de1fb3e..a71f250 100644 --- a/src/observation/RadecGeocentric.ts +++ b/src/observation/RadecGeocentric.ts @@ -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'; @@ -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, @@ -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; @@ -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) { @@ -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); @@ -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; diff --git a/src/observation/RadecTopocentric.ts b/src/observation/RadecTopocentric.ts index 5205909..c5cddea 100644 --- a/src/observation/RadecTopocentric.ts +++ b/src/observation/RadecTopocentric.ts @@ -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'; @@ -25,6 +48,14 @@ export class RadecTopocentric { /** * Create a new [RadecTopocentric] 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 [RadecTopocentric] object. */ static fromDegrees( epoch: EpochUTC, @@ -52,6 +83,9 @@ export class RadecTopocentric { /** * Create a [RadecTopocentric] object from an inertial [state] and * [site] vector. + * @param state Inertial state vector. + * @param site Site vector. + * @returns A new [RadecTopocentric] object. */ static fromStateVectors(state: J2000, site: J2000): RadecTopocentric { const p = state.position.subtract(site.position); @@ -112,6 +146,9 @@ export class RadecTopocentric { * * An optional [range] _(km)_ value can be passed to override the value * contained in this observation. + * @param site Observer site. + * @param range Range _(km)_. + * @returns A [Vector3D] object. */ position(site: J2000, range?: number): Vector3D { const r = range ?? this.range ?? 1.0; @@ -124,6 +161,10 @@ export class RadecTopocentric { * * An optional [range] _(km)_ and [rangeRate] _(km/s)_ value can be passed * to override the values contained in this observation. + * @param site Observer site. + * @param range Range _(km)_. + * @param rangeRate Range rate _(km/s)_. + * @returns A [Vector3D] object. */ velocity(site: J2000, range?: number, rangeRate?: number): Vector3D { if (!this.rightAscensionRate || !this.declinationRate) { @@ -155,6 +196,9 @@ export class RadecTopocentric { /** * Calculate the angular distance _(rad)_ between this and another * [RadecTopocentric] object. + * @param radec - The other [RadecTopocentric] object. + * @param method - The angular distance method to use. + * @returns The angular distance _(rad)_. */ angle(radec: RadecTopocentric, method: AngularDistanceMethod = AngularDistanceMethod.Cosine): number { return angularDistance(this.rightAscension, this.declination, radec.rightAscension, radec.declination, method); @@ -163,6 +207,9 @@ export class RadecTopocentric { /** * Calculate the angular distance _(°)_ between this and another * [RadecTopocentric] object. + * @param radec - The other [RadecTopocentric] object. + * @param method - The angular distance method to use. + * @returns The angular distance _(°)_. */ angleDegrees(radec: RadecTopocentric, method: AngularDistanceMethod = AngularDistanceMethod.Cosine): number { return this.angle(radec, method) * RAD2DEG; diff --git a/src/operations/Matrix.ts b/src/operations/Matrix.ts index 368fb70..6b02232 100644 --- a/src/operations/Matrix.ts +++ b/src/operations/Matrix.ts @@ -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 { Radians } from 'src/main'; import { Vector } from './Vector'; import { Vector3D } from './Vector3D'; @@ -19,10 +42,9 @@ export class Matrix { /** * Creates a matrix with all elements set to zero. - * * @param rows - The number of rows in the matrix. - * @param columns - The number of columns in the matrix. @returns A matrix - * with all elements set to zero. + * @param columns - The number of columns in the matrix. + * @returns A matrix with all elements set to zero. */ static allZeros(rows: number, columns: number): Matrix { return this.fill(rows, columns, 0.0); @@ -31,13 +53,9 @@ export class Matrix { /** * Creates a new Matrix with the specified number of rows and columns, filled * with the specified value. - * * @param rows The number of rows in the matrix. - * * @param columns The number of columns in the matrix. - * * @param value The value to fill the matrix with. Default is 0.0. - * * @returns A new Matrix filled with the specified value. */ static fill(rows: number, columns: number, value = 0.0): Matrix { @@ -56,7 +74,6 @@ export class Matrix { /** * Creates a rotation matrix around the X-axis. * @param theta - The angle of rotation in radians. - * * @returns The rotation matrix. */ static rotX(theta: Radians): Matrix { @@ -76,7 +93,6 @@ export class Matrix { /** * Creates a rotation matrix around the y-axis. * @param theta - The angle of rotation in radians. - * * @returns The rotation matrix. */ static rotY(theta: Radians): Matrix { @@ -95,7 +111,6 @@ export class Matrix { /** * Creates a rotation matrix around the Z-axis. - * * @param theta The angle of rotation in radians. * @returns The rotation matrix. */ @@ -116,9 +131,7 @@ export class Matrix { /** * Creates a zero matrix with the specified number of rows and columns. * @param rows The number of rows in the matrix. - * * @param columns The number of columns in the matrix. - * * @returns A new Matrix object representing the zero matrix. */ static zero(rows: number, columns: number): Matrix { @@ -137,7 +150,6 @@ export class Matrix { /** * Creates an identity matrix of the specified dimension. * @param dimension The dimension of the identity matrix. - * * @returns The identity matrix. */ static identity(dimension: number): Matrix { @@ -155,9 +167,7 @@ export class Matrix { /** * Creates a diagonal matrix with the given diagonal elements. - * * @param d - An array of diagonal elements. - * * @returns A new Matrix object representing the diagonal matrix. */ static diagonal(d: number[]): Matrix { @@ -177,7 +187,6 @@ export class Matrix { /** * Adds the elements of another matrix to this matrix and returns the result. * @param m - The matrix to be added. - * * @returns The resulting matrix after addition. */ add(m: Matrix): Matrix { @@ -194,9 +203,7 @@ export class Matrix { /** * Subtracts the elements of another matrix from this matrix. - * * @param m - The matrix to subtract. - * * @returns A new matrix containing the result of the subtraction. */ subtract(m: Matrix): Matrix { @@ -214,7 +221,6 @@ export class Matrix { /** * Scales the matrix by multiplying each element by a scalar value. * @param n - The scalar value to multiply each element by. - * * @returns A new Matrix object representing the scaled matrix. */ scale(n: number): Matrix { @@ -240,7 +246,6 @@ export class Matrix { /** * Multiplies this matrix with another matrix. * @param m The matrix to multiply with. - * * @returns The resulting matrix. */ multiply(m: Matrix): Matrix { @@ -259,9 +264,7 @@ export class Matrix { /** * Computes the outer product of this matrix with another matrix. - * * @param m - The matrix to compute the outer product with. - * * @returns The resulting matrix. */ outerProduct(m: Matrix): Matrix { @@ -279,7 +282,6 @@ export class Matrix { /** * Multiplies the matrix by a vector. * @param v The vector to multiply by. - * * @returns A new vector representing the result of the multiplication. */ multiplyVector(v: Vector): Vector { @@ -299,11 +301,8 @@ export class Matrix { /** * Multiplies a 3D vector by the matrix. - * * @template T - The type of the vector elements. - * * @param v - The 3D vector to multiply. - * * @returns The resulting 3D vector after multiplication. */ multiplyVector3D(v: Vector3D): Vector3D { @@ -373,7 +372,6 @@ export class Matrix { /** * Performs the Cholesky decomposition on the matrix. - * * @returns A new Matrix object representing the Cholesky decomposition of the * original matrix. */ @@ -399,7 +397,6 @@ export class Matrix { /** * Swaps two rows in the matrix. - * * @param i - The index of the first row. * @param j - The index of the second row. */ @@ -452,7 +449,6 @@ export class Matrix { /** * Calculates the inverse of the matrix. - * * @returns The inverse of the matrix. */ inverse(): Matrix { diff --git a/src/operations/Random.ts b/src/operations/Random.ts index 0fa51ae..4130899 100644 --- a/src/operations/Random.ts +++ b/src/operations/Random.ts @@ -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. + */ + /** * A generator of random bool, int, or double values. * @@ -19,6 +42,8 @@ export class Random { /** * To create a non-negative random integer uniformly distributed in the range from 0, * inclusive, to max, exclusive, use nextInt(int max). + * @param max The bound on the random number to be returned. Must be positive. + * @returns A pseudorandom, uniformly distributed int value between 0 (inclusive) and the specified value (exclusive). */ nextInt(max = 1): number { return Math.round(this.nextFloat(max) * max); diff --git a/src/operations/Vector.ts b/src/operations/Vector.ts index 2e3a3d1..23bc05f 100644 --- a/src/operations/Vector.ts +++ b/src/operations/Vector.ts @@ -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 { Degrees, Radians } from 'src/main'; import { Matrix } from './Matrix'; import { Vector3D } from './Vector3D'; @@ -58,7 +81,6 @@ export class Vector { /** * Creates a zero vector of the specified length. * @param length The length of the vector. - * * @returns A new Vector object representing the zero vector. */ static zero(length: number): Vector { @@ -69,9 +91,7 @@ export class Vector { * Creates a new Vector with the specified length, filled with the specified * value. * @param length The length of the new Vector. - * * @param value The value to fill the Vector with. - * * @returns A new Vector filled with the specified value. */ static filled(length: number, value: number): Vector { @@ -80,7 +100,6 @@ export class Vector { /** * Creates a new Vector instance from an array of elements. - * * @param elements - The array of elements to create the Vector from. * @returns A new Vector instance. */ @@ -90,7 +109,6 @@ export class Vector { /** * Returns a string representation of the vector. - * * @param fixed - The number of digits to appear after the decimal point. * Defaults to -1. * @returns A string representation of the vector. @@ -106,6 +124,7 @@ export class Vector { /** * Returns a string representation of the x value of the vector. + * @returns A string representation of the x value of the vector. */ get x(): number { return this.elements[0]; @@ -113,6 +132,7 @@ export class Vector { /** * Returns a string representation of the y value of the vector. + * @returns A string representation of the y value of the vector. */ get y(): number { return this.elements[1]; @@ -120,6 +140,7 @@ export class Vector { /** * Returns a string representation of the z value of the vector. + * @returns A string representation of the z value of the vector. */ get z(): number { return this.elements[2]; @@ -127,7 +148,6 @@ export class Vector { /** * Converts the vector elements to an array. - * * @returns An array containing the vector elements. */ toList(): number[] { @@ -136,7 +156,6 @@ export class Vector { /** * Converts the vector to a Float64Array. - * * @returns The vector as a Float64Array. */ toArray(): Float64Array { @@ -145,7 +164,6 @@ export class Vector { /** * Calculates the magnitude of the vector. - * * @returns The magnitude of the vector. */ magnitude(): number { @@ -162,7 +180,6 @@ export class Vector { * Adds the elements of another vector to this vector and returns a new * vector. * @param v - The vector to add. - * * @returns A new vector containing the sum of the elements. */ add(v: Vector): Vector { @@ -178,7 +195,6 @@ export class Vector { /** * Subtracts a vector from the current vector. * @param v The vector to subtract. - * * @returns A new vector representing the result of the subtraction. */ subtract(v: Vector): Vector { @@ -194,7 +210,6 @@ export class Vector { /** * Scales the vector by a given factor. * @param n The scaling factor. - * * @returns A new Vector object representing the scaled vector. */ scale(n: number): Vector { @@ -218,7 +233,6 @@ export class Vector { /** * Return the Euclidean distance between this and another Vector. * @param v The vector to calculate the distance to. - * * @returns The distance between the two vectors. */ distance(v: Vector): number { @@ -243,7 +257,6 @@ export class Vector { /** * Calculates the dot product of this vector and another vector. - * * @param v - The vector to calculate the dot product with. * @returns The dot product of the two vectors. */ @@ -260,7 +273,6 @@ export class Vector { /** * Calculates the outer product of this vector with another vector. * @param v The vector to calculate the outer product with. - * * @returns A matrix representing the outer product of the two vectors. */ outer(v: Vector): Matrix { @@ -279,7 +291,6 @@ export class Vector { /** * Calculates the cross product of this vector and the given vector. * @param v - The vector to calculate the cross product with. - * * @returns The resulting vector. */ cross(v: Vector): Vector { @@ -296,8 +307,8 @@ export class Vector { /** * Calculate the skew-symmetric matrix for this [Vector]. - * - * An error will be thrown if the vector is not length 3. + * @returns The skew-symmetric matrix. + * @throws [Error] if the vector is not of length 3. */ skewSymmetric(): Matrix { if (this.length !== 3) { @@ -313,7 +324,6 @@ export class Vector { /** * Rotates the vector around the X-axis by the specified angle. - * * @param theta The angle in radians. * @returns The rotated vector. */ @@ -331,7 +341,6 @@ export class Vector { /** * Rotates the vector around the Y-axis by the specified angle. - * * @param theta The angle of rotation in radians. * @returns A new Vector representing the rotated vector. */ @@ -349,7 +358,6 @@ export class Vector { /** * Rotates the vector around the Z-axis by the specified angle. - * * @param theta The angle of rotation in radians. * @returns A new Vector representing the rotated vector. */ @@ -368,7 +376,6 @@ export class Vector { /** * Calculates the angle between this vector and another vector. * @param v The other vector. - * * @returns The angle between the two vectors in radians. */ angle(v: Vector): Radians { @@ -385,7 +392,6 @@ export class Vector { /** * Calculates the angle between this vector and another vector in degrees. * @param v The other vector. - * * @returns The angle between the two vectors in degrees. */ angleDegrees(v: Vector): Degrees { @@ -396,9 +402,7 @@ export class Vector { * Determines if there is line of sight between this vector and another vector * within a given radius. * @param v - The vector to check line of sight with. - * * @param radius - The radius within which line of sight is considered. - * * @returns True if there is line of sight, false otherwise. */ sight(v: Vector, radius: number): boolean { @@ -428,7 +432,6 @@ export class Vector { * the given vector's magnitude by this vector's magnitude, and then * normalizing the resulting vector. * @param v - The vector to calculate the bisect with. - * * @returns The bisect vector. */ bisect(v: Vector): Vector { @@ -437,8 +440,8 @@ export class Vector { /** * Joins the current vector with another vector. - * @param v The vector to join with. @returns A new vector that contains the - * elements of both vectors. + * @param v The vector to join with. + * @returns A new vector that contains the elements of both vectors. */ join(v: Vector): Vector { return new Vector(this.toList().concat(v.toList())); @@ -447,9 +450,9 @@ export class Vector { /** * Returns a new Vector containing a portion of the elements from the * specified start index to the specified end index - * @param start The start index of the slice (inclusive). @param end The end - * index of the slice (exclusive). @returns A new Vector containing the sliced - * elements. + * @param start The start index of the slice (inclusive). + * @param end The end index of the slice (exclusive). + * @returns A new Vector containing the sliced elements. */ slice(start: number, end: number): Vector { return new Vector(this.elements.slice(start, end)); @@ -457,7 +460,7 @@ export class Vector { /** * Returns a new Matrix object representing the row vector. - * @returns {Matrix} The row vector as a Matrix object. + * @returns The row vector as a Matrix object. */ row(): Matrix { return new Matrix([this.toList()]); @@ -465,7 +468,7 @@ export class Vector { /** * Returns a new Matrix object representing the column vector of this Vector. - * @returns {Matrix} The column vector as a Matrix object. + * @returns The column vector as a Matrix object. */ column(): Matrix { return new Matrix(this.toList().map((e) => [e])); @@ -473,8 +476,8 @@ export class Vector { /** * Converts the elements at the specified index to a Vector3D object. - * @param index - The index of the elements to convert. @returns A new - * Vector3D object containing the converted elements. + * @param index - The index of the elements to convert. + * @returns A new Vector3D object containing the converted elements. */ toVector3D(index: number): Vector3D { return new Vector3D(this.elements[index], this.elements[index + 1], this.elements[index + 2]); diff --git a/src/sgp4/sgp4.ts b/src/sgp4/sgp4.ts index 18543ba..5163170 100644 --- a/src/sgp4/sgp4.ts +++ b/src/sgp4/sgp4.ts @@ -1,32 +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 Sgp4 module contains a TypeScript port of the 2020 version of - * sgp4unit.cpp from "Fundamentals of Astrodynamics and Applications" by David - * Vallado. All of the original comments and notes are inserted in the code below - * in order provide context to the functions and clarify any adjustments made for - * TypeScript/JavaScript compatibility. + * 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. */ // NOTE: This file is meant to maintain as much of the original format as possible. diff --git a/src/time/EpochGPS.ts b/src/time/EpochGPS.ts index 6add72f..cd6a333 100644 --- a/src/time/EpochGPS.ts +++ b/src/time/EpochGPS.ts @@ -6,6 +6,9 @@ export class EpochGPS { /** * Create a new GPS epoch given the [week] since reference epoch, and number * of [seconds] into the [week]. + * @param week Number of weeks since the GPS reference epoch. + * @param seconds Number of seconds into the week. + * @param reference Reference epoch. */ constructor(public week: number, public seconds: number, reference: EpochUTC) { if (week < 0) { diff --git a/src/transforms/transforms.ts b/src/transforms/transforms.ts index 79a910d..75891b6 100644 --- a/src/transforms/transforms.ts +++ b/src/transforms/transforms.ts @@ -1,31 +1,24 @@ -/* eslint-disable init-declarations */ /** * @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 Transforms module contains a collection of conversions not contained - * in the original SGP4 library such as ECI to ECF and ECF to RAE. This was based - * on some of the functions in satellite.js. + * 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 { @@ -59,6 +52,10 @@ import { TransformCache } from './TransformCache'; * Azimuth is the angle off of boresight in the horizontal plane. * Elevation is the angle off of boresight in the vertical plane. * Cone half angle is the angle of the cone of the radar max field of view. + * @param az - Azimuth in radians + * @param el - Elevation in radians + * @param coneHalfAngle - Cone half angle in radians + * @returns U and V in radians */ export function azel2uv(az: Radians, el: Radians, coneHalfAngle: Radians): { u: Radians; v: Radians } { if (az > coneHalfAngle && az < coneHalfAngle) { @@ -86,7 +83,9 @@ export function azel2uv(az: Radians, el: Radians, coneHalfAngle: Radians): { u: * [X] [C -S 0][X] * [Y] = [S C 0][Y] * [Z]eci [0 0 1][Z]ecf - * + * @param ecf takes xyz coordinates + * @param gmst takes a number in gmst time + * @returns array containing eci coordinates */ export function ecf2eci(ecf: EcfVec3, gmst: number): EciVec3 { const X = (ecf.x * Math.cos(gmst) - ecf.y * Math.sin(gmst)) as T; @@ -123,6 +122,9 @@ export function ecf2enu(ecf: EcefVec3, lla: LlaVec3): EnuVe * [X] [C S 0][X] * [Y] = [-S C 0][Y] * [Z]ecf [0 0 1][Z]eci + * @param eci takes xyz coordinates + * @param gmst takes a number in gmst time + * @returns array containing ecf coordinates */ export function eci2ecf(eci: EciVec3, gmst: number): EcfVec3 { const x = (eci.x * Math.cos(gmst) + eci.y * Math.sin(gmst)); @@ -138,12 +140,10 @@ export function eci2ecf(eci: EciVec3, gmst: number): EcfVec /** * EciToGeodetic converts eci coordinates to lla coordinates - * - * @cached - * - * @param {vec3} eci takes xyz coordinates - * @param {number} gmst takes a number in gmst time - * @returns {array} array containing lla coordinates + * @variation cached - results are cached + * @param eci takes xyz coordinates + * @param gmst takes a number in gmst time + * @returns array containing lla coordinates */ export function eci2lla(eci: EciVec3, gmst: number): LlaVec3 { // Check cache @@ -194,10 +194,13 @@ export function eci2lla(eci: EciVec3, gmst: number): LlaVec3} enu - The ENU coordinates to be converted. - * @param {A} az - The azimuth angle in radians. - * @param {A} el - The elevation angle in radians. - * @returns {RfVec3} The converted RF coordinates. + * @param enu - The ENU coordinates to be converted. + * @param enu.x - The east coordinate. + * @param enu.y - The north coordinate. + * @param enu.z - The up coordinate. + * @param az - The azimuth angle in radians. + * @param el - The elevation angle in radians. + * @returns The converted RF coordinates. */ export function enu2rf({ x, y, z }: EnuVec3, az: A, el: A): RfVec3 { const xrf = Math.cos(el) * Math.cos(az) * x - Math.sin(az) * y + Math.sin(el) * Math.cos(az) * z; @@ -213,6 +216,8 @@ export function enu2rf({ x, y, z } /** * Converts geodetic coordinates (longitude, latitude, altitude) to Earth-Centered Earth-Fixed (ECF) coordinates. + * @param lla The geodetic coordinates in radians and meters. + * @returns The ECF coordinates in meters. */ export function llaRad2ecf(lla: LlaVec3): EcfVec3 { const { lon, lat, alt } = lla; @@ -236,6 +241,8 @@ export function llaRad2ecf(lla: LlaVec3(lla: LlaVec3): EcfVec3 { const { lon, lat, alt } = lla; @@ -252,9 +259,7 @@ export function lla2ecf(lla: LlaVec3, gmst: GreenwichMeanSi /** * Calculates Geodetic Lat Lon Alt to ECEF coordinates. - * * @deprecated This needs to be validated. + * @param lla The geodetic coordinates in degrees and meters. + * @returns The ECEF coordinates in meters. */ export function lla2ecef(lla: LlaVec3): EcefVec3 { const { lat, lon, alt } = lla; @@ -306,6 +312,9 @@ export function lla2ecef(lla: LlaVec3): EcefVec3(lla: LlaVec3, ecf: EcfVec3): SezVec3 { const lon = lla.lon; @@ -334,7 +343,6 @@ export function lla2sez(lla: LlaVec3, ecf: EcfVec3 /** * Converts a vector in Right Ascension, Elevation, and Range (RAE) coordinate system * to a vector in South, East, and Zenith (SEZ) coordinate system. - * * @param rae The vector in RAE coordinate system. * @returns The vector in SEZ coordinate system. */ @@ -353,7 +361,6 @@ export function rae2sez(rae: RaeVec3): SezVec3 /** * Converts a vector in Right Ascension, Elevation, and Range (RAE) coordinate system * to Earth-Centered Fixed (ECF) coordinate system. - * * @template D - The dimension of the RAE vector. * @template A - The dimension of the LLA vector. * @param rae - The vector in RAE coordinate system. @@ -390,9 +397,7 @@ export function rae2ecf(rae: RaeVec3, lla: LlaVec3 /** * Converts a vector from RAE (Range, Azimuth, Elevation) coordinates to ECI (Earth-Centered Inertial) coordinates. - * - * @cached - * + * @variation cached - results are cached * @param rae The vector in RAE coordinates. * @param lla The vector in LLA (Latitude, Longitude, Altitude) coordinates. * @param gmst The Greenwich Mean Sidereal Time. @@ -434,10 +439,10 @@ export function rae2enu(rae: RaeVec3): EnuVec3 { /** * Determine azimuth and elevation off of boresight based on sensor orientation and RAE. - * - * @param {rae} rae Range, Azimuth, Elevation - * @param {RadarSensor} sensor Radar sensor object - * @returns {az, el} Azimuth and Elevation off of boresight + * @param rae Range, Azimuth, Elevation + * @param sensor Radar sensor object + * @param maxSensorAz Maximum sensor azimuth + * @returns Azimuth and Elevation off of boresight */ export function rae2raeOffBoresight( rae: RaeVec3, @@ -458,6 +463,10 @@ export function rae2raeOffBoresight( /** * Converts Range Az El to Range U V. + * @param rae Range, Azimuth, Elevation + * @param sensor Radar sensor object + * @param maxSensorAz Maximum sensor azimuth + * @returns Range, U, V */ export function rae2ruv(rae: RaeVec3, sensor: RadarSensor, maxSensorAz: Degrees): RuvVec3 { const { az, el } = rae2raeOffBoresight(rae, sensor, maxSensorAz); @@ -469,7 +478,7 @@ export function rae2ruv(rae: RaeVec3, sensor: RadarSensor, maxSensorAz: Degrees) /** * Converts South, East, and Zenith (SEZ) coordinates to Right Ascension, Elevation, and Range (RAE) coordinates. * @param sez The SEZ coordinates. - * @returns {RaeVec3} Rng, Az, El array + * @returns Rng, Az, El array */ export function sez2rae(sez: SezVec3): RaeVec3 { const rng = Math.sqrt(sez.s * sez.s + sez.e * sez.e + sez.z * sez.z); @@ -481,10 +490,10 @@ export function sez2rae(sez: SezVec3): RaeVec3 /** * Converts U and V to Azimuth and Elevation off of boresight. - * * @param u The U coordinate. * @param v The V coordinate. * @param coneHalfAngle The cone half angle of the radar. + * @returns Azimuth and Elevation off of boresight. */ export function uv2azel(u: Radians, v: Radians, coneHalfAngle: Radians): { az: Radians; el: Radians } { if (u > 1 || u < -1) { @@ -506,7 +515,6 @@ export function uv2azel(u: Radians, v: Radians, coneHalfAngle: Radians): { az: R /** * Converts Earth-Centered Fixed (ECF) coordinates to Right Ascension (RA), * Elevation (E), and Azimuth (A) coordinates. - * * @param lla The Latitude, Longitude, and Altitude (LLA) coordinates. * @param ecf The Earth-Centered Fixed (ECF) coordinates. * @returns The Right Ascension (RA), Elevation (E), and Azimuth (A) coordinates. @@ -521,9 +529,7 @@ export function ecfRad2rae(lla: LlaVec3, ecf: EcfV /** * Converts Earth-Centered Fixed (ECF) coordinates to Right Ascension (RA), * Elevation (E), and Azimuth (A) coordinates. - * - * @cached - * + * @variation cached - results are cached * @param lla The Latitude, Longitude, and Altitude (LLA) coordinates. * @param ecf The Earth-Centered Fixed (ECF) coordinates. * @returns The Right Ascension (RA), Elevation (E), and Azimuth (A) coordinates. @@ -578,7 +584,6 @@ export const jday = (year?: number, mon?: number, day?: number, hr?: number, min /** * Calculates the Greenwich Mean Sidereal Time (GMST) for a given date. - * * @param date - The date for which to calculate the GMST. * @returns An object containing the GMST value and the Julian date. */ @@ -601,13 +606,11 @@ export function calcGmst(date: Date): { gmst: GreenwichMeanSiderealTime; j: numb /** * Converts ECI coordinates to RAE (Right Ascension, Azimuth, Elevation) coordinates. - * - * @cached - * - * @param {Date} now - Current date and time. - * @param {EciArr3} eci - ECI coordinates of the satellite. - * @param {SensorObject} sensor - Sensor object containing observer's geodetic coordinates. - * @returns {Object} Object containing azimuth, elevation and range in degrees and kilometers respectively. + * @variation cached - results are cached + * @param now - Current date and time. + * @param eci - ECI coordinates of the satellite. + * @param sensor - Sensor object containing observer's geodetic coordinates. + * @returns Object containing azimuth, elevation and range in degrees and kilometers respectively. */ export function eci2rae(now: Date, eci: EciVec3, sensor: Sensor): RaeVec3 { now = new Date(now); diff --git a/src/types/types.ts b/src/types/types.ts index deae82c..e55b9a0 100644 --- a/src/types/types.ts +++ b/src/types/types.ts @@ -8,11 +8,9 @@ import { Vector3D } from 'src/main'; * This type is used to create new types based on existing ones, but with a * unique identifier. This can be useful for creating types that are * semantically different but structurally the same. - * * @template T The base type from which the distinct type is created. * @template DistinctName A unique identifier for the distinct type. - * - * @property __TYPE__ A property that holds the unique identifier for the + * __TYPE__ A property that holds the unique identifier for the * distinct type. */ type Distinct = T & { __TYPE__: DistinctName }; @@ -97,14 +95,12 @@ export type Meters = Distinct; * This type is used to represent a point in space in terms of x, y, and z * coordinates. It is a generic type that allows for flexibility in the units of * measure used for each dimension. The default unit of measure is Kilometers. - * * @template Units The unit of measure used for the dimensions. This is * typically a type representing a distance, such as kilometers or meters. The * default is Kilometers. - * - * @property x The x dimension of the vector, representing the distance from the + * x The x dimension of the vector, representing the distance from the * origin to the point in the x direction. - * @property y The y dimension of the vector, representing the distance from the + * y The y dimension of the vector, representing the distance from the * origin to the point in the y direction. @property z The z dimension of the * vector, representing the distance from the origin to the point in the z * direction. @@ -122,10 +118,9 @@ export type Vec3 = { * This type is used to represent a point in space in terms of x, y, and z * coordinates. It is a generic type that allows for flexibility in the units of * measure used for each dimension. The default unit of measure is Kilometers. - * - * @property x The x dimension of the vector, representing the distance from the + * x The x dimension of the vector, representing the distance from the * origin to the point in the x direction. - * @property y The y dimension of the vector, representing the distance from the + * y The y dimension of the vector, representing the distance from the * origin to the point in the y direction. @property z The z dimension of the * vector, representing the distance from the origin to the point in the z * direction. @@ -149,10 +144,9 @@ export type EciVec3 = Vec3; * This type is used to represent a point in space in terms of x, y, and z * coordinates. It is a generic type that allows for flexibility in the units of * measure used for each dimension. The default unit of measure is Kilometers. - * - * @property x The x dimension of the vector, representing the distance from the + * x The x dimension of the vector, representing the distance from the * origin to the point in the x direction. - * @property y The y dimension of the vector, representing the distance from the + * y The y dimension of the vector, representing the distance from the * origin to the point in the y direction. @property z The z dimension of the * vector, representing the distance from the origin to the point in the z * direction. @@ -178,16 +172,13 @@ export type EcefVec3 = EcfVec3; * tangent to the Earth's surface fixed to a specific location and hence it is * sometimes known as a "Local Tangent" or "local geodetic" plane. By convention * the east axis is labeled x, the north y, and the up z. - * * @see https://en.wikipedia.org/wiki/Local_tangent_plane_coordinates - * * @template Units The unit of measure used for the dimensions. This is * typically a type representing a distance, such as kilometers or meters. The * default is Kilometers. - * - * @property e The east dimension of the vector, representing the distance from + * e The east dimension of the vector, representing the distance from * the origin to the point in the east direction. - * @property n The north dimension of the vector, representing the distance from + * n The north dimension of the vector, representing the distance from * the origin to the point in the north direction. @property u The up dimension * of the vector, representing the distance from the origin to the point in the * upward direction. @@ -200,11 +191,9 @@ export type EnuVec3 = Vec3; * This type is used to represent a point in space in terms of latitude, * longitude, and altitude. It is a generic type that allows for flexibility in * the units of measure used for each dimension. - * * @template A The unit of measure used for the latitude and longitude * dimensions. This is typically a type representing an angle, such as degrees * or radians. The default is Radians. - * * @template D The unit of measure used for the altitude dimension. This is * typically a type representing a distance, such as kilometers or meters. The * default is Kilometers. @@ -222,18 +211,15 @@ export type LlaVec3 = { * This type is used to represent a point in space in terms of range, azimuth, * and elevation. It is a generic type that allows for flexibility in the units * of measure used for each dimension. - * * @template DistanceUnit The unit of measure used for the altitude dimension. * This is typically a type representing a distance, such as kilometers or * meters. The default is Kilometers. - * * @template AngleUnit The unit of measure used for the latitude and longitude * dimensions. This is typically a type representing an angle, such as degrees * or radians. The default is Radians. - * - * @property rng The range dimension of the vector, representing the distance + * rng The range dimension of the vector, representing the distance * from the origin to the point. - * @property az The azimuth dimension of the vector, representing the angle in + * az The azimuth dimension of the vector, representing the angle in * the horizontal plane from a reference direction. @property el The elevation * dimension of the vector, representing the angle from the horizontal plane to * the point. @@ -251,9 +237,8 @@ export type RaeVec3 = { * This type is used to represent a point in space in terms of south, east, and * zenith. It is a generic type that allows for flexibility in the units of * measure used for each dimension. - * - * @property s The south dimension of the vector - * @property e The east dimension of the vector @property z The zenith dimension + * s The south dimension of the vector + * e The east dimension of the vector @property z The zenith dimension * of the vector */ export type SezVec3 = { @@ -263,9 +248,7 @@ export type SezVec3 = { }; /** - * @interface SatelliteRecord contains all of the orbital parameters necessary - * for running SGP4. It is generated by Sgp4.createSatrec. - * + * SatelliteRecord contains all of the orbital parameters necessary for running SGP4. It is generated by Sgp4. */ export interface SatelliteRecord { Om: number; @@ -429,12 +412,10 @@ export type PosVel = { * the radar. The U-axis is in the horizontal plane and points to the right of * the boresight. The V-axis is in the vertical plane and points down from the * boresight. - * * @template DistanceUnit The unit of measure used for the altitude dimension. * This is typically a type representing a distance, such as kilometers or * meters. The default is Kilometers. - * - * * @template AngleUnit The unit of measure used for the latitude and longitude + * @template AngleUnit The unit of measure used for the latitude and longitude * dimensions. This is typically a type representing an angle, such as degrees * or radians. The default is Radians. */ @@ -500,12 +481,12 @@ export type TleLine2 = Distinct; * - satNum: The satellite number. * - satNumRaw: The raw string representation of the satellite number. * - classification: The classification of the satellite (e.g., "U" for - * unclassified). + * unclassified). * - intlDes: The international designator for the satellite. * - intlDesYear: The year of the international designator. * - intlDesLaunchNum: The launch number of the international designator. * - intlDesLaunchPiece: The piece of the launch of the international - * designator. + * designator. * - epochYear: The last two digits of the year of the epoch. * - epochYearFull: The full four-digit year of the epoch. * - epochDay: The day of the year of the epoch. @@ -515,7 +496,6 @@ export type TleLine2 = Distinct; * - ephemerisType: The type of ephemeris used. * - elsetNum: The element set number. * - checksum1: The checksum of the first line of the TLE. - * * @see https://en.wikipedia.org/wiki/Two-line_element_set */ export type Line1Data = { @@ -556,7 +536,6 @@ export type Line1Data = { * - revNum: The revolution number at epoch. * - checksum2: The checksum of the second line of the TLE. * - period: The period of the satellite's orbit, derived from the mean motion. - * * @see https://en.wikipedia.org/wiki/Two-line_element_set */ export type Line2Data = { @@ -624,14 +603,12 @@ export type GreenwichMeanSiderealTime = Distinct = { @@ -651,10 +628,9 @@ export type RaDec = { /** * Represents the solar noon and nadir times. - * - * @property solarNoon The time at which the sun is at its highest point in the + * solarNoon The time at which the sun is at its highest point in the * sky (directly above the observer's head). This is the midpoint of the day. - * @property nadir The time at which the sun is at its lowest point, directly + * nadir The time at which the sun is at its lowest point, directly * below the observer. This is the midpoint of the night. */ export type SunTime = { diff --git a/src/utils/functions.ts b/src/utils/functions.ts index 35fd84d..101a100 100644 --- a/src/utils/functions.ts +++ b/src/utils/functions.ts @@ -1,5 +1,4 @@ /* eslint-disable require-jsdoc */ -/* eslint-disable func-style */ import { AngularDiameterMethod } from '../enums/AngularDiameterMethod'; import { AngularDistanceMethod } from '../enums/AngularDistanceMethod'; import { DifferentiableFunction, EcfVec3, Kilometers, Radians, SpaceObjectType } from '../types/types'; @@ -30,108 +29,26 @@ export function log10(x: number): number { return Math.log(x) / Math.LN10; } -/** - * Calculates the cube root of a number. - * - * @param n - The number to calculate the cube root of. - * @returns The cube root of the given number. - */ -export function cbrt(n: number): number { - return n ** (1 / 3); -} - -/** - * Calculates the hyperbolic sine of a number. - * @param x - The number to calculate the hyperbolic sine of. - * @returns The hyperbolic sine of the given number. - */ -export function sinh(x: number): number { - return 0.5 * (Math.exp(x) - Math.exp(-x)); -} - -/** - * Calculates the hyperbolic cosine of a number. - * - * @param x - The number for which to calculate the hyperbolic cosine. - * @returns The hyperbolic cosine of the given number. - */ -export function cosh(x: number): number { - return 0.5 * (Math.exp(x) + Math.exp(-x)); -} - -/** - * Calculates the hyperbolic tangent of a number. - * - * @param x - The number to calculate the hyperbolic tangent of. - * @returns The hyperbolic tangent of the given number. - */ -export function tanh(x: number): number { - return sinh(x) / cosh(x); -} - -/** - * Calculates the hyperbolic cotangent of a number. - * - * @param x - The number for which to calculate the hyperbolic cotangent. - * @returns The hyperbolic cotangent of the given number. - */ -export function coth(x: number): number { - return cosh(x) / sinh(x); -} - /** * Calculates the hyperbolic secant of a number. - * * @param x - The number to calculate the hyperbolic secant of. * @returns The hyperbolic secant of the given number. */ export function sech(x: number): number { - return 1 / cosh(x); + return 1 / Math.cosh(x); } /** * Calculates the hyperbolic cosecant of a number. - * * @param x - The number for which to calculate the hyperbolic cosecant. * @returns The hyperbolic cosecant of the given number. */ export function csch(x: number): number { - return 1 / sinh(x); -} - -/** - * Calculates the inverse hyperbolic sine of a number. - * - * @param x - The number to calculate the inverse hyperbolic sine of. - * @returns The inverse hyperbolic sine of the given number. - */ -export function asinh(x: number): number { - return Math.log(x + Math.sqrt(x * x + 1)); -} - -/** - * Calculates the inverse hyperbolic cosine (acosh) of a number. - * - * @param x - The number to calculate the acosh for. - * @returns The acosh value of the given number. - */ -export function acosh(x: number): number { - return Math.log(x + Math.sqrt(x * x - 1)); -} - -/** - * Calculates the inverse hyperbolic tangent of a number. - * - * @param x - The number to calculate the inverse hyperbolic tangent of. - * @returns The inverse hyperbolic tangent of the given number. - */ -export function atanh(x: number): number { - return 0.5 * Math.log((1 + x) / (1 - x)); + return 1 / Math.sinh(x); } /** * Returns the inverse hyperbolic cosecant of a number. - * * @param x - The number to calculate the inverse hyperbolic cosecant of. * @returns The inverse hyperbolic cosecant of the given number. */ @@ -141,7 +58,6 @@ export function acsch(x: number): number { /** * Calculates the inverse hyperbolic secant (asech) of a number. - * * @param x - The number to calculate the inverse hyperbolic secant of. * @returns The inverse hyperbolic secant of the given number. */ @@ -151,7 +67,6 @@ export function asech(x: number): number { /** * Calculates the inverse hyperbolic cotangent (acoth) of a number. - * * @param x - The number to calculate the acoth of. * @returns The inverse hyperbolic cotangent of the given number. */ @@ -171,7 +86,6 @@ export function copySign(mag: number, sgn: number): number { /** * Evaluates a polynomial function at a given value. - * * @param x - The value at which to evaluate the polynomial. * @param coeffs - The coefficients of the polynomial. * @returns The result of evaluating the polynomial at the given value. @@ -188,7 +102,6 @@ export function evalPoly(x: number, coeffs: Float64Array): number { /** * Concatenates two Float64Arrays into a new Float64Array. - * * @param a - The first Float64Array. * @param b - The second Float64Array. * @returns A new Float64Array containing the concatenated values of `a` and `b`. @@ -222,19 +135,18 @@ export function matchHalfPlane(angle: number, match: number): number { * @param theta - The angle to wrap. * @returns The wrapped angle. */ -export function wrapAngle(theta: number): number { +export function wrapAngle(theta: Radians): Radians { const result = ((theta + Math.PI) % (2 * Math.PI)) - Math.PI; if (result === -Math.PI) { - return Math.PI; + return Math.PI as Radians; } - return result; + return result as Radians; } /** * Calculates the angular distance between two points on a sphere using the cosine formula. - * * @param lam1 - The longitude of the first point in radians. * @param phi1 - The latitude of the first point in radians. * @param lam2 - The longitude of the second point in radians. @@ -250,7 +162,6 @@ function angularDistanceCosine_(lam1: number, phi1: number, lam2: number, phi2: /** * Calculates the angular distance between two points on a sphere using the Haversine formula. - * * @param lam1 - The longitude of the first point in radians. * @param phi1 - The latitude of the first point in radians. * @param lam2 - The longitude of the second point in radians. @@ -269,7 +180,6 @@ function angularDistanceHaversine_(lam1: number, phi1: number, lam2: number, phi /** * Calculates the angular distance between two points on a sphere. - * * @param lam1 The longitude of the first point. * @param phi1 The latitude of the first point. * @param lam2 The longitude of the second point. @@ -297,7 +207,6 @@ export function angularDistance( /** * Calculates the angular diameter of an object. - * * @param diameter - The diameter of the object. * @param distance - The distance to the object. * @param method - The method used to calculate the angular diameter. Defaults to AngularDiameterMethod.Sphere. @@ -334,7 +243,6 @@ export function linearInterpolate(x: number, x0: number, y0: number, x1: number, /** * Calculates the mean value of an array of numbers. - * * @param values - The array of numbers. * @returns The mean value of the numbers. */ @@ -351,7 +259,6 @@ export function mean(values: number[]): number { /** * Calculates the standard deviation of an array of numbers. - * * @param values - The array of numbers. * @param isSample - Optional. Specifies whether the array represents a sample. Default is false. * @returns The standard deviation of the array. @@ -373,7 +280,6 @@ export function std(values: number[], isSample = false): number { /** * Calculates the covariance between two arrays. - * * @param a - The first array. * @param b - The second array. * @param isSample - Optional. Specifies whether the arrays represent a sample. Default is false. @@ -400,6 +306,10 @@ export function covariance(a: number[], b: number[], isSample = false): number { * @returns The derivative function. */ export function derivative(f: DifferentiableFunction, h = 1e-3): DifferentiableFunction { + /** + * @param x The value at which to calculate the derivative. + * @returns The derivative of the function at the given value. + */ function df(x: number): number { const hh = h * 0.5; @@ -421,7 +331,6 @@ export function gamma(n: number): number { /** * Calculates the eccentric anomaly (e0) and true anomaly (nu) using Newton's method * for a given eccentricity (ecc) and mean anomaly (m). - * * @param ecc - The eccentricity of the orbit. * @param m - The mean anomaly. * @returns An object containing the eccentric anomaly (e0) and true anomaly (nu). @@ -461,7 +370,6 @@ export function newtonM(ecc: number, m: number): { e0: number; nu: number } { /** * Calculates the eccentric anomaly (e0) and mean anomaly (m) using Newton's method * for a given eccentricity (ecc) and true anomaly (nu). - * * @param ecc - The eccentricity of the orbit. * @param nu - The true anomaly. * @returns An object containing the calculated eccentric anomaly (e0) and mean anomaly (m). @@ -494,12 +402,11 @@ export function newtonNu(ecc: number, nu: number): { e0: number; m: Radians } { /** * Creates a 2D array with the specified number of rows and columns, filled with the same given value. - * * @template T The type of elements in the array. - * @param {number} rows The number of rows in the 2D array. - * @param {number} columns The number of columns in the 2D array. - * @param {T} value The value to fill the array with. - * @returns {T[][]} The 2D array with the specified number of rows and columns, filled with the given value. + * @param rows The number of rows in the 2D array. + * @param columns The number of columns in the 2D array. + * @param value The value to fill the array with. + * @returns The 2D array with the specified number of rows and columns, filled with the given value. */ export function array2d(rows: number, columns: number, value: T): T[][] { const output: T[][] = []; @@ -543,7 +450,6 @@ export function isLeapYear(dateIn: Date): boolean { * * This is sometimes referred to as the Jday, but is * very different from the Julian day used in astronomy. - * * @param date - The date for which to calculate the day of the year. * @returns The day of the year as a number. */ @@ -625,7 +531,6 @@ export const spaceObjType2Str = (spaceObjType: SpaceObjectType): string => * Calculates the Doppler factor for a given location, position, and velocity. * The Doppler factor is a measure of the change in frequency or wavelength of a wave * as observed by an observer moving relative to the source of the wave. - * * @param location - The location vector of the observer. * @param position - The position vector of the source. * @param velocity - The velocity vector of the source. @@ -655,7 +560,6 @@ export const dopplerFactor = ( /** * Creates an array of numbers from start to stop (inclusive) with the specified step. - * * @param start The starting number. * @param stop The ending number. * @param step The step value. diff --git a/src/utils/jacobian.ts b/src/utils/jacobian.ts index fb4dc67..83f8bb1 100644 --- a/src/utils/jacobian.ts +++ b/src/utils/jacobian.ts @@ -5,7 +5,6 @@ import { array2d } from './functions'; /** * Calculates the Jacobian matrix of a given Jacobian function. - * * @param f The Jacobian function. * @param m The number of rows in the Jacobian matrix. * @param x0 The initial values of the variables. diff --git a/test/objects/GroundObject.test.ts b/test/objects/GroundObject.test.ts new file mode 100644 index 0000000..b7011b2 --- /dev/null +++ b/test/objects/GroundObject.test.ts @@ -0,0 +1,57 @@ +import { exampleDate } from '../lib/mockData'; +import { Degrees, Geodetic, GroundObject, Kilometers, Radians } from '../../src/main'; + +describe('GroundObject', () => { + let groundObject: GroundObject; + let geodetic: Geodetic; + + beforeEach(() => { + groundObject = new GroundObject({ + lat: 0 as Degrees, + lon: 0 as Degrees, + alt: 0 as Kilometers, + }); + + geodetic = new Geodetic( + 0 as Radians, + 0 as Radians, + 0 as Kilometers, + ); + }); + + it('should be defined', () => { + expect(groundObject).toBeDefined(); + }); + + it('should have a name', () => { + expect(groundObject.name).toBeDefined(); + }); + + it('should have a latitude', () => { + expect(groundObject.lat).toBeDefined(); + }); + + it('should have a longitude', () => { + expect(groundObject.lon).toBeDefined(); + }); + + it('should calculate ecf', () => { + expect(groundObject.ecf()).toMatchSnapshot(); + }); + + it('should calculate eci', () => { + expect(groundObject.eci(exampleDate)).toMatchSnapshot(); + }); + + it('should calculate llaRad', () => { + expect(groundObject.llaRad()).toMatchSnapshot(); + }); + + it('should create from geodetic', () => { + expect(GroundObject.fromGeodetic(geodetic)).toMatchSnapshot(); + }); + + it('should convert to geodetic', () => { + expect(groundObject.toGeodetic()).toMatchSnapshot(); + }); +}); diff --git a/test/objects/__snapshots__/GroundObject.test.ts.snap b/test/objects/__snapshots__/GroundObject.test.ts.snap new file mode 100644 index 0000000..8f96319 --- /dev/null +++ b/test/objects/__snapshots__/GroundObject.test.ts.snap @@ -0,0 +1,56 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`GroundObject should calculate ecf 1`] = ` +Object { + "x": 6378.137, + "y": 0, + "z": 0, +} +`; + +exports[`GroundObject should calculate eci 1`] = ` +Object { + "x": -4444.532338535956, + "y": 4564.633188736234, + "z": 0, +} +`; + +exports[`GroundObject should calculate llaRad 1`] = ` +Object { + "alt": 0, + "lat": 0, + "lon": 0, +} +`; + +exports[`GroundObject should convert to geodetic 1`] = ` +Geodetic { + "alt": 0, + "lat": 0, + "lon": 0, +} +`; + +exports[`GroundObject should create from geodetic 1`] = ` +GroundObject { + "active": true, + "alt": 0, + "id": undefined, + "lat": 0, + "lon": 0, + "name": "Unknown Ground Position", + "position": Object { + "x": 0, + "y": 0, + "z": 0, + }, + "totalVelocity": 0, + "type": 0, + "velocity": Object { + "x": 0, + "y": 0, + "z": 0, + }, +} +`; diff --git a/test/utils/__snapshots__/functions.test.ts.snap b/test/utils/__snapshots__/functions.test.ts.snap new file mode 100644 index 0000000..e2dc6c5 --- /dev/null +++ b/test/utils/__snapshots__/functions.test.ts.snap @@ -0,0 +1,38 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`functions should be calculate acotch 1`] = `Infinity`; + +exports[`functions should be calculate acsch 1`] = `0.8813735870195429`; + +exports[`functions should be calculate asech 1`] = `0`; + +exports[`functions should be calculate concat 1`] = ` +Float64Array [ + 1, + 2, + 3, + 4, + 5, + 6, +] +`; + +exports[`functions should be calculate copySign 1`] = `1`; + +exports[`functions should be calculate copySign 2`] = `1`; + +exports[`functions should be calculate copySign 3`] = `-1`; + +exports[`functions should be calculate copySign 4`] = `-1`; + +exports[`functions should be calculate csch 1`] = `0.8509181282393216`; + +exports[`functions should be calculate log10 1`] = `2`; + +exports[`functions should be calculate sech 1`] = `0.6480542736638855`; + +exports[`functions should be calculate wrapAngle 1`] = `1`; + +exports[`functions should be calculate wrapAngle 2`] = `-1.2831853071795862`; + +exports[`functions should be calculate wrapAngle 3`] = `-5`; diff --git a/test/utils/functions.test.ts b/test/utils/functions.test.ts new file mode 100644 index 0000000..7728b65 --- /dev/null +++ b/test/utils/functions.test.ts @@ -0,0 +1,53 @@ +import { Radians, acoth, acsch, asech, concat, copySign, csch, log10, sech, wrapAngle } from '../../src/main'; + +describe('functions', () => { + it('should be calculate log10', () => { + expect(log10(100)).toMatchSnapshot(); + }); + + // sech + it('should be calculate sech', () => { + expect(sech(1)).toMatchSnapshot(); + }); + + // csch + it('should be calculate csch', () => { + expect(csch(1)).toMatchSnapshot(); + }); + + // acsch + it('should be calculate acsch', () => { + expect(acsch(1)).toMatchSnapshot(); + }); + + // asech + it('should be calculate asech', () => { + expect(asech(1)).toMatchSnapshot(); + }); + + // acotch + it('should be calculate acotch', () => { + expect(acoth(1)).toMatchSnapshot(); + }); + + // copySign + it('should be calculate copySign', () => { + expect(copySign(1, 1)).toMatchSnapshot(); + expect(copySign(-1, 1)).toMatchSnapshot(); + expect(copySign(1, -1)).toMatchSnapshot(); + expect(copySign(-1, -1)).toMatchSnapshot(); + }); + + // concat + it('should be calculate concat', () => { + expect(concat(new Float64Array([1, 2, 3]), new Float64Array([4, 5, 6]))).toMatchSnapshot(); + }); + + // wrapAngle + it('should be calculate wrapAngle', () => { + expect(wrapAngle(1 as Radians)).toMatchSnapshot(); + expect(wrapAngle(5 as Radians)).toMatchSnapshot(); + expect(wrapAngle(-5 as Radians)).toMatchSnapshot(); + }); + +});