ootk 3.0.0 → 4.0.0-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +235 -10
- package/README.md +27 -40
- package/dist/coordinate/Hill.d.ts +49 -0
- package/dist/coordinate/Hill.js +222 -0
- package/dist/coordinate/Hill.js.map +1 -0
- package/dist/coordinate/index.d.ts +1 -0
- package/dist/coordinate/index.js +2 -0
- package/dist/coordinate/index.js.map +1 -0
- package/dist/covariance/CovarianceSample.d.ts +43 -0
- package/dist/covariance/CovarianceSample.js +147 -0
- package/dist/covariance/CovarianceSample.js.map +1 -0
- package/dist/covariance/StateCovariance.d.ts +42 -0
- package/dist/covariance/StateCovariance.js +65 -0
- package/dist/covariance/StateCovariance.js.map +1 -0
- package/dist/force/AtmosphericDrag.d.ts +31 -0
- package/dist/force/AtmosphericDrag.js +73 -0
- package/dist/force/AtmosphericDrag.js.map +1 -0
- package/dist/force/EarthGravity.d.ts +27 -0
- package/dist/force/EarthGravity.js +117 -0
- package/dist/force/EarthGravity.js.map +1 -0
- package/{lib/ootk.d.ts → dist/force/Force.d.ts} +12 -11
- package/dist/force/Force.js +31 -0
- package/dist/force/Force.js.map +1 -0
- package/dist/force/ForceModel.d.ts +37 -0
- package/dist/force/ForceModel.js +75 -0
- package/dist/force/ForceModel.js.map +1 -0
- package/dist/force/Gravity.d.ts +38 -0
- package/dist/force/Gravity.js +47 -0
- package/dist/force/Gravity.js.map +1 -0
- package/dist/{ootk.d.ts → force/SolarRadiationPressure.d.ts} +12 -11
- package/dist/force/SolarRadiationPressure.js +44 -0
- package/dist/force/SolarRadiationPressure.js.map +1 -0
- package/dist/force/ThirdBodyGravity.d.ts +26 -0
- package/dist/force/ThirdBodyGravity.js +57 -0
- package/dist/force/ThirdBodyGravity.js.map +1 -0
- package/dist/force/Thrust.d.ts +34 -0
- package/dist/force/Thrust.js +58 -0
- package/dist/force/Thrust.js.map +1 -0
- package/dist/interfaces/RfSensorParams.d.ts +28 -0
- package/dist/interfaces/RfSensorParams.js +24 -0
- package/dist/interfaces/RfSensorParams.js.map +1 -0
- package/dist/interfaces/index.d.ts +1 -0
- package/dist/interfaces/index.js +2 -0
- package/dist/interfaces/index.js.map +1 -0
- package/dist/interpolator/ChebyshevCoefficients.d.ts +50 -0
- package/dist/interpolator/ChebyshevCoefficients.js +94 -0
- package/dist/interpolator/ChebyshevCoefficients.js.map +1 -0
- package/dist/interpolator/ChebyshevInterpolator.d.ts +38 -0
- package/dist/interpolator/ChebyshevInterpolator.js +71 -0
- package/dist/interpolator/ChebyshevInterpolator.js.map +1 -0
- package/dist/interpolator/CubicSpline.d.ts +35 -0
- package/dist/interpolator/CubicSpline.js +69 -0
- package/dist/interpolator/CubicSpline.js.map +1 -0
- package/dist/interpolator/CubicSplineInterpolator.d.ts +36 -0
- package/dist/interpolator/CubicSplineInterpolator.js +80 -0
- package/dist/interpolator/CubicSplineInterpolator.js.map +1 -0
- package/dist/interpolator/FieldInterpolator.d.ts +28 -0
- package/dist/interpolator/FieldInterpolator.js +34 -0
- package/dist/interpolator/FieldInterpolator.js.map +1 -0
- package/dist/interpolator/Interpolator.d.ts +22 -0
- package/dist/interpolator/Interpolator.js +47 -0
- package/dist/interpolator/Interpolator.js.map +1 -0
- package/dist/interpolator/LagrangeInterpolator.d.ts +40 -0
- package/dist/interpolator/LagrangeInterpolator.js +159 -0
- package/dist/interpolator/LagrangeInterpolator.js.map +1 -0
- package/dist/interpolator/StateInterpolator.d.ts +27 -0
- package/dist/interpolator/StateInterpolator.js +35 -0
- package/dist/interpolator/StateInterpolator.js.map +1 -0
- package/dist/interpolator/VerletBlendInterpolator.d.ts +43 -0
- package/dist/interpolator/VerletBlendInterpolator.js +118 -0
- package/dist/interpolator/VerletBlendInterpolator.js.map +1 -0
- package/{lib/ootk.js → dist/main.d.ts} +13 -10
- package/dist/{objects/space-object.d.ts → main.js} +17 -23
- package/dist/main.js.map +1 -0
- package/dist/maneuver/TwoBurnOrbitTransfer.d.ts +41 -0
- package/dist/maneuver/TwoBurnOrbitTransfer.js +65 -0
- package/dist/maneuver/TwoBurnOrbitTransfer.js.map +1 -0
- package/dist/maneuver/Waypoint.d.ts +91 -0
- package/dist/maneuver/Waypoint.js +179 -0
- package/dist/maneuver/Waypoint.js.map +1 -0
- package/{lib/objects/detailed-sat.d.ts → dist/objects/DetailedSatellite.d.ts} +40 -36
- package/dist/objects/DetailedSatellite.js +136 -0
- package/dist/objects/DetailedSatellite.js.map +1 -0
- package/dist/objects/DetailedSensor.d.ts +42 -0
- package/dist/objects/DetailedSensor.js +65 -0
- package/dist/objects/DetailedSensor.js.map +1 -0
- package/dist/objects/LandObject.d.ts +33 -0
- package/dist/objects/LandObject.js +34 -0
- package/dist/objects/LandObject.js.map +1 -0
- package/dist/objects/Marker.d.ts +20 -0
- package/dist/objects/Marker.js +24 -0
- package/dist/objects/Marker.js.map +1 -0
- package/dist/objects/RfSensor.d.ts +41 -0
- package/dist/objects/RfSensor.js +67 -0
- package/dist/objects/RfSensor.js.map +1 -0
- package/dist/objects/index.d.ts +5 -4
- package/dist/objects/index.js +6 -0
- package/dist/objects/index.js.map +1 -0
- package/dist/observation/Observation.d.ts +89 -0
- package/dist/observation/Observation.js +102 -0
- package/dist/observation/Observation.js.map +1 -0
- package/dist/observation/ObservationOptical.d.ts +48 -0
- package/dist/observation/ObservationOptical.js +105 -0
- package/dist/observation/ObservationOptical.js.map +1 -0
- package/dist/observation/ObservationRadar.d.ts +46 -0
- package/dist/observation/ObservationRadar.js +96 -0
- package/dist/observation/ObservationRadar.js.map +1 -0
- package/dist/observation/ObservationUtils.d.ts +20 -0
- package/dist/observation/ObservationUtils.js +32 -0
- package/dist/observation/ObservationUtils.js.map +1 -0
- package/dist/observation/PropagatorPairs.d.ts +32 -0
- package/dist/observation/PropagatorPairs.js +43 -0
- package/dist/observation/PropagatorPairs.js.map +1 -0
- package/dist/operations/BoxMuller.d.ts +46 -0
- package/dist/operations/BoxMuller.js +77 -0
- package/dist/operations/BoxMuller.js.map +1 -0
- package/dist/operations/EulerAngles.d.ts +105 -0
- package/dist/operations/EulerAngles.js +161 -0
- package/dist/operations/EulerAngles.js.map +1 -0
- package/dist/operations/Quaternion.d.ts +56 -0
- package/dist/operations/Quaternion.js +167 -0
- package/dist/operations/Quaternion.js.map +1 -0
- package/dist/operations/RandomGaussianSource.d.ts +24 -0
- package/dist/operations/RandomGaussianSource.js +43 -0
- package/dist/operations/RandomGaussianSource.js.map +1 -0
- package/dist/operations/index.d.ts +4 -0
- package/dist/operations/index.js +5 -0
- package/dist/operations/index.js.map +1 -0
- package/dist/optimize/ChebyshevCompressor.d.ts +32 -0
- package/dist/optimize/ChebyshevCompressor.js +83 -0
- package/dist/optimize/ChebyshevCompressor.js.map +1 -0
- package/dist/optimize/DownhillSimplex.d.ts +64 -0
- package/dist/optimize/DownhillSimplex.js +182 -0
- package/dist/optimize/DownhillSimplex.js.map +1 -0
- package/dist/optimize/GoldenSection.d.ts +39 -0
- package/dist/optimize/GoldenSection.js +55 -0
- package/dist/optimize/GoldenSection.js.map +1 -0
- package/dist/optimize/PolynomialRegression.d.ts +49 -0
- package/dist/optimize/PolynomialRegression.js +83 -0
- package/dist/optimize/PolynomialRegression.js.map +1 -0
- package/dist/optimize/PolynomicalRegressionResult.d.ts +31 -0
- package/dist/optimize/PolynomicalRegressionResult.js +38 -0
- package/dist/optimize/PolynomicalRegressionResult.js.map +1 -0
- package/dist/optimize/SimpleLinearRegression.d.ts +44 -0
- package/dist/optimize/SimpleLinearRegression.js +112 -0
- package/dist/optimize/SimpleLinearRegression.js.map +1 -0
- package/dist/optimize/SimplexEntry.d.ts +32 -0
- package/dist/optimize/SimplexEntry.js +42 -0
- package/dist/optimize/SimplexEntry.js.map +1 -0
- package/dist/orbit_determination/BatchLeastSquaresOD.d.ts +65 -0
- package/dist/orbit_determination/BatchLeastSquaresOD.js +143 -0
- package/dist/orbit_determination/BatchLeastSquaresOD.js.map +1 -0
- package/dist/orbit_determination/BatchLeastSquaresResult.d.ts +31 -0
- package/{lib/objects/space-object.d.ts → dist/orbit_determination/BatchLeastSquaresResult.js} +21 -23
- package/dist/orbit_determination/BatchLeastSquaresResult.js.map +1 -0
- package/dist/orbit_determination/GibbsIOD.d.ts +38 -0
- package/dist/orbit_determination/GibbsIOD.js +76 -0
- package/dist/orbit_determination/GibbsIOD.js.map +1 -0
- package/dist/orbit_determination/GoodingIOD.d.ts +51 -0
- package/dist/orbit_determination/GoodingIOD.js +247 -0
- package/dist/orbit_determination/GoodingIOD.js.map +1 -0
- package/dist/orbit_determination/HerrickGibbsIOD.d.ts +33 -0
- package/dist/orbit_determination/HerrickGibbsIOD.js +50 -0
- package/dist/orbit_determination/HerrickGibbsIOD.js.map +1 -0
- package/dist/orbit_determination/LambertIOD.d.ts +59 -0
- package/dist/orbit_determination/LambertIOD.js +213 -0
- package/dist/orbit_determination/LambertIOD.js.map +1 -0
- package/dist/orbit_determination/ModifiedGoodingIOD.d.ts +40 -0
- package/dist/orbit_determination/ModifiedGoodingIOD.js +83 -0
- package/dist/orbit_determination/ModifiedGoodingIOD.js.map +1 -0
- package/dist/propagator/DormandPrince54Propagator.d.ts +28 -0
- package/dist/propagator/DormandPrince54Propagator.js +64 -0
- package/dist/propagator/DormandPrince54Propagator.js.map +1 -0
- package/dist/propagator/KeplerPropagator.d.ts +35 -0
- package/dist/propagator/KeplerPropagator.js +84 -0
- package/dist/propagator/KeplerPropagator.js.map +1 -0
- package/dist/propagator/Propagator.d.ts +34 -0
- package/dist/propagator/Propagator.js +162 -0
- package/dist/propagator/Propagator.js.map +1 -0
- package/dist/propagator/RkCheckpoint.d.ts +22 -0
- package/dist/propagator/RkCheckpoint.js +27 -0
- package/dist/propagator/RkCheckpoint.js.map +1 -0
- package/dist/propagator/RkResult.d.ts +23 -0
- package/dist/propagator/RkResult.js +30 -0
- package/dist/propagator/RkResult.js.map +1 -0
- package/dist/propagator/RungeKutta4Propagator.d.ts +50 -0
- package/dist/propagator/RungeKutta4Propagator.js +141 -0
- package/dist/propagator/RungeKutta4Propagator.js.map +1 -0
- package/dist/propagator/RungeKutta89Propagator.d.ts +28 -0
- package/dist/propagator/RungeKutta89Propagator.js +126 -0
- package/dist/propagator/RungeKutta89Propagator.js.map +1 -0
- package/dist/propagator/RungeKuttaAdaptive.d.ts +54 -0
- package/dist/propagator/RungeKuttaAdaptive.js +159 -0
- package/dist/propagator/RungeKuttaAdaptive.js.map +1 -0
- package/dist/propagator/Sgp4Propagator.d.ts +34 -0
- package/dist/propagator/Sgp4Propagator.js +56 -0
- package/dist/propagator/Sgp4Propagator.js.map +1 -0
- package/dist/smoothing/ExponentialSmoothing.d.ts +23 -0
- package/dist/smoothing/ExponentialSmoothing.js +81 -0
- package/dist/smoothing/ExponentialSmoothing.js.map +1 -0
- package/dist/transforms/index.d.ts +1 -0
- package/dist/transforms/index.js +2 -0
- package/dist/transforms/index.js.map +1 -0
- package/dist/transforms/transforms.d.ts +56 -92
- package/dist/transforms/transforms.js +94 -0
- package/dist/transforms/transforms.js.map +1 -0
- package/dist/types/types.d.ts +105 -584
- package/dist/types/types.js +23 -0
- package/dist/types/types.js.map +1 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +2 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/jacobian.d.ts +11 -0
- package/dist/utils/jacobian.js +29 -0
- package/dist/utils/jacobian.js.map +1 -0
- package/package.json +34 -42
- package/src/coordinate/Hill.ts +326 -0
- package/src/coordinate/index.ts +1 -0
- package/src/covariance/CovarianceSample.ts +194 -0
- package/src/covariance/StateCovariance.ts +69 -0
- package/src/force/AtmosphericDrag.ts +101 -0
- package/src/force/EarthGravity.ts +157 -0
- package/src/force/Force.ts +33 -0
- package/src/force/ForceModel.ts +91 -0
- package/src/force/Gravity.ts +53 -0
- package/src/force/SolarRadiationPressure.ts +42 -0
- package/src/force/ThirdBodyGravity.ts +62 -0
- package/src/force/Thrust.ts +83 -0
- package/src/interfaces/RfSensorParams.ts +30 -0
- package/src/interfaces/index.ts +1 -0
- package/src/interpolator/ChebyshevCoefficients.ts +109 -0
- package/src/interpolator/ChebyshevInterpolator.ts +87 -0
- package/src/interpolator/CubicSpline.ts +72 -0
- package/src/interpolator/CubicSplineInterpolator.ts +90 -0
- package/src/interpolator/FieldInterpolator.ts +37 -0
- package/src/interpolator/Interpolator.ts +56 -0
- package/src/interpolator/LagrangeInterpolator.ts +192 -0
- package/src/interpolator/StateInterpolator.ts +39 -0
- package/src/interpolator/VerletBlendInterpolator.ts +146 -0
- package/src/main.ts +32 -0
- package/src/maneuver/TwoBurnOrbitTransfer.ts +79 -0
- package/src/maneuver/Waypoint.ts +267 -0
- package/src/objects/DetailedSatellite.ts +159 -0
- package/src/objects/DetailedSensor.ts +68 -0
- package/src/objects/LandObject.ts +46 -0
- package/src/objects/Marker.ts +25 -0
- package/src/objects/RfSensor.ts +78 -0
- package/src/objects/index.ts +5 -0
- package/src/observation/Observation.ts +125 -0
- package/src/observation/ObservationOptical.ts +146 -0
- package/src/observation/ObservationRadar.ts +131 -0
- package/src/observation/ObservationUtils.ts +40 -0
- package/src/observation/PropagatorPairs.ts +45 -0
- package/src/operations/BoxMuller.ts +87 -0
- package/src/operations/EulerAngles.ts +183 -0
- package/src/operations/Quaternion.ts +222 -0
- package/src/operations/RandomGaussianSource.ts +51 -0
- package/src/operations/index.ts +4 -0
- package/src/optimize/ChebyshevCompressor.ts +96 -0
- package/src/optimize/DownhillSimplex.ts +212 -0
- package/src/optimize/GoldenSection.ts +71 -0
- package/src/optimize/PolynomialRegression.ts +109 -0
- package/src/optimize/PolynomicalRegressionResult.ts +32 -0
- package/src/optimize/SimpleLinearRegression.ts +127 -0
- package/src/optimize/SimplexEntry.ts +50 -0
- package/src/orbit_determination/BatchLeastSquaresOD.ts +174 -0
- package/src/orbit_determination/BatchLeastSquaresResult.ts +33 -0
- package/src/orbit_determination/GibbsIOD.ts +95 -0
- package/src/orbit_determination/GoodingIOD.ts +380 -0
- package/src/orbit_determination/HerrickGibbsIOD.ts +51 -0
- package/src/orbit_determination/LambertIOD.ts +260 -0
- package/src/orbit_determination/ModifiedGoodingIOD.ts +133 -0
- package/src/propagator/DormandPrince54Propagator.ts +73 -0
- package/src/propagator/KeplerPropagator.ts +102 -0
- package/src/propagator/Propagator.ts +253 -0
- package/src/propagator/RkCheckpoint.ts +25 -0
- package/src/propagator/RkResult.ts +26 -0
- package/src/propagator/RungeKutta4Propagator.ts +179 -0
- package/src/propagator/RungeKutta89Propagator.ts +132 -0
- package/src/propagator/RungeKuttaAdaptive.ts +232 -0
- package/src/propagator/Sgp4Propagator.ts +71 -0
- package/src/smoothing/ExponentialSmoothing.ts +90 -0
- package/src/transforms/index.ts +1 -0
- package/src/transforms/transforms.ts +117 -0
- package/src/types/types.ts +135 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/jacobian.ts +38 -0
- package/.eslintrc.json +0 -244
- package/.prettierrc +0 -17
- package/babel.config.js +0 -16
- package/codecov.yml +0 -21
- package/dist/objects/base-object.d.ts +0 -40
- package/dist/objects/detailed-sat.d.ts +0 -66
- package/dist/objects/sat.d.ts +0 -92
- package/dist/objects/sensor.d.ts +0 -93
- package/dist/objects/star.d.ts +0 -46
- package/dist/ootk.js +0 -2
- package/dist/ootk.js.LICENSE.txt +0 -77
- package/dist/sgp4/sgp4.d.ts +0 -82
- package/dist/tle/tle-format-data.d.ts +0 -6
- package/dist/tle/tle.d.ts +0 -375
- package/dist/utils/constants.d.ts +0 -34
- package/dist/utils/moon-math.d.ts +0 -113
- package/dist/utils/sun-math.d.ts +0 -230
- package/dist/utils/utils.d.ts +0 -39
- package/jest.config.ts +0 -30
- package/lib/objects/base-object.d.ts +0 -40
- package/lib/objects/base-object.js +0 -79
- package/lib/objects/base-object.js.map +0 -1
- package/lib/objects/detailed-sat.js +0 -149
- package/lib/objects/detailed-sat.js.map +0 -1
- package/lib/objects/index.d.ts +0 -4
- package/lib/objects/index.js +0 -5
- package/lib/objects/index.js.map +0 -1
- package/lib/objects/sat.d.ts +0 -92
- package/lib/objects/sat.js +0 -188
- package/lib/objects/sat.js.map +0 -1
- package/lib/objects/sensor.d.ts +0 -93
- package/lib/objects/sensor.js +0 -273
- package/lib/objects/sensor.js.map +0 -1
- package/lib/objects/space-object.js +0 -60
- package/lib/objects/space-object.js.map +0 -1
- package/lib/objects/star.d.ts +0 -46
- package/lib/objects/star.js +0 -91
- package/lib/objects/star.js.map +0 -1
- package/lib/ootk.js.map +0 -1
- package/lib/sgp4/sgp4.d.ts +0 -82
- package/lib/sgp4/sgp4.js +0 -3262
- package/lib/sgp4/sgp4.js.map +0 -1
- package/lib/tle/tle-format-data.d.ts +0 -6
- package/lib/tle/tle-format-data.js +0 -10
- package/lib/tle/tle-format-data.js.map +0 -1
- package/lib/tle/tle.d.ts +0 -375
- package/lib/tle/tle.js +0 -611
- package/lib/tle/tle.js.map +0 -1
- package/lib/transforms/transforms.d.ts +0 -94
- package/lib/transforms/transforms.js +0 -308
- package/lib/transforms/transforms.js.map +0 -1
- package/lib/types/types.d.ts +0 -605
- package/lib/types/types.js +0 -36
- package/lib/types/types.js.map +0 -1
- package/lib/utils/constants.d.ts +0 -34
- package/lib/utils/constants.js +0 -35
- package/lib/utils/constants.js.map +0 -1
- package/lib/utils/moon-math.d.ts +0 -113
- package/lib/utils/moon-math.js +0 -387
- package/lib/utils/moon-math.js.map +0 -1
- package/lib/utils/sun-math.d.ts +0 -230
- package/lib/utils/sun-math.js +0 -422
- package/lib/utils/sun-math.js.map +0 -1
- package/lib/utils/utils.d.ts +0 -39
- package/lib/utils/utils.js +0 -102
- package/lib/utils/utils.js.map +0 -1
- package/sandbox.html +0 -8
- package/tsconfig.base.json +0 -31
- package/tsconfig.build.json +0 -14
- /package/{LICENSE.MD → LICENSE.md} +0 -0
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author @thkruz Theodore Kruczek
|
|
3
|
+
* @license AGPL-3.0-or-later
|
|
4
|
+
* @copyright (c) 2020-2024 Theodore Kruczek
|
|
5
|
+
*
|
|
6
|
+
* Orbital Object ToolKit is free software: you can redistribute it and/or modify it under the
|
|
7
|
+
* terms of the GNU Affero General Public License as published by the Free Software
|
|
8
|
+
* Foundation, either version 3 of the License, or (at your option) any later version.
|
|
9
|
+
*
|
|
10
|
+
* Orbital Object ToolKit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
11
|
+
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
12
|
+
* See the GNU Affero General Public License for more details.
|
|
13
|
+
*
|
|
14
|
+
* You should have received a copy of the GNU Affero General Public License along with
|
|
15
|
+
* Orbital Object ToolKit. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { DEG2RAD, Degrees, Matrix, RAD2DEG, Radians, Vector3D } from 'ootk-core';
|
|
19
|
+
|
|
20
|
+
// / Class containing Euler angles.
|
|
21
|
+
export class EulerAngles {
|
|
22
|
+
// / Roll component _(rad)_.
|
|
23
|
+
roll: number;
|
|
24
|
+
|
|
25
|
+
// / Pitch component _(rad)_.
|
|
26
|
+
pitch: number;
|
|
27
|
+
|
|
28
|
+
// / Yaw component _(rad)_.
|
|
29
|
+
yaw: number;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Create a new EulerAngles object from roll, pitch, and yaw angles in radians.
|
|
33
|
+
* @param roll Roll angle in radians.
|
|
34
|
+
* @param pitch Pitch angle in radians.
|
|
35
|
+
* @param yaw Yaw angle in radians.
|
|
36
|
+
*/
|
|
37
|
+
constructor(roll: Radians, pitch: Radians, yaw: Radians) {
|
|
38
|
+
this.roll = roll;
|
|
39
|
+
this.pitch = pitch;
|
|
40
|
+
this.yaw = yaw;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Create a new EulerAngles object from roll, pitch, and yaw angles.
|
|
45
|
+
* @param rollDeg Roll angle in degrees.
|
|
46
|
+
* @param pitchDeg Pitch angle in degrees.
|
|
47
|
+
* @param yawDeg Yaw angle in degrees.
|
|
48
|
+
* @returns EulerAngles object.
|
|
49
|
+
*/
|
|
50
|
+
static fromDegrees(rollDeg: Degrees, pitchDeg: Degrees, yawDeg: Degrees): EulerAngles {
|
|
51
|
+
const roll = rollDeg * DEG2RAD as Radians;
|
|
52
|
+
const pitch = pitchDeg * DEG2RAD as Radians;
|
|
53
|
+
const yaw = yawDeg * DEG2RAD as Radians;
|
|
54
|
+
|
|
55
|
+
return new EulerAngles(roll, pitch, yaw);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Create a new EulerAngles object from 3-2-1 ordered direction cosine matrix c.
|
|
60
|
+
* @param c 3-2-1 ordered direction cosine matrix.
|
|
61
|
+
* @returns EulerAngles object.
|
|
62
|
+
*/
|
|
63
|
+
static fromDcm321(c: Matrix): EulerAngles {
|
|
64
|
+
const roll = Math.atan(c.elements[1][2] / c.elements[2][2]) as Radians;
|
|
65
|
+
const pitch = -Math.asin(c.elements[0][2]) as Radians;
|
|
66
|
+
const yaw = Math.atan(c.elements[0][1] / c.elements[0][0]) as Radians;
|
|
67
|
+
|
|
68
|
+
return new EulerAngles(roll, pitch, yaw);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Gets the roll angle in degrees.
|
|
73
|
+
* @returns The roll angle in degrees.
|
|
74
|
+
*/
|
|
75
|
+
get rollDegrees(): Degrees {
|
|
76
|
+
return this.roll * RAD2DEG as Degrees;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Gets the pitch angle in degrees.
|
|
81
|
+
* @returns The pitch angle in degrees.
|
|
82
|
+
*/
|
|
83
|
+
get pitchDegrees(): Degrees {
|
|
84
|
+
return this.pitch * RAD2DEG as Degrees;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Gets the yaw angle in degrees.
|
|
89
|
+
* @returns The yaw angle in degrees.
|
|
90
|
+
*/
|
|
91
|
+
get yawDegrees(): Degrees {
|
|
92
|
+
return this.yaw * RAD2DEG as Degrees;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Gets the roll angle in radians.
|
|
97
|
+
* @returns The roll angle in radians.
|
|
98
|
+
*/
|
|
99
|
+
get phi(): Radians {
|
|
100
|
+
return this.roll as Radians;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Gets the pitch angle in radians.
|
|
105
|
+
* @returns The pitch angle in radians.
|
|
106
|
+
*/
|
|
107
|
+
get theta(): Radians {
|
|
108
|
+
return this.pitch as Radians;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Gets the yaw angle in radians.
|
|
113
|
+
* @returns The yaw angle in radians.
|
|
114
|
+
*/
|
|
115
|
+
get psi(): Radians {
|
|
116
|
+
return this.yaw as Radians;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Gets the roll component in degrees.
|
|
121
|
+
* @returns The roll component in degrees.
|
|
122
|
+
*/
|
|
123
|
+
get phiDegrees(): Degrees {
|
|
124
|
+
return this.phi * RAD2DEG as Degrees;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Gets the pitch component in degrees.
|
|
129
|
+
* @returns The pitch component in degrees.
|
|
130
|
+
*/
|
|
131
|
+
get thetaDegrees(): Degrees {
|
|
132
|
+
return this.theta * RAD2DEG as Degrees;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Gets the yaw component in degrees.
|
|
137
|
+
* @returns The yaw component in degrees.
|
|
138
|
+
*/
|
|
139
|
+
get psiDegrees(): Degrees {
|
|
140
|
+
return this.psi * RAD2DEG as Degrees;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Returns a string representation of the Euler angles.
|
|
145
|
+
* @param precision The number of decimal places to include in the string representation. Default is 6.
|
|
146
|
+
* @returns A string representation of the Euler angles.
|
|
147
|
+
*/
|
|
148
|
+
toString(precision = 6): string {
|
|
149
|
+
const rollStr = this.rollDegrees.toFixed(precision);
|
|
150
|
+
const pitchStr = this.pitchDegrees.toFixed(precision);
|
|
151
|
+
const yawStr = this.yawDegrees.toFixed(precision);
|
|
152
|
+
|
|
153
|
+
return `Euler(roll: ${rollStr}°, pitch: ${pitchStr}°, yaw: ${yawStr}°)`;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Calculates the Direction Cosine Matrix (DCM) using the 3-2-1 Euler angles convention.
|
|
158
|
+
* @returns The calculated DCM as a Matrix object.
|
|
159
|
+
*/
|
|
160
|
+
dcm321(): Matrix {
|
|
161
|
+
const sPhi = Math.sin(this.phi);
|
|
162
|
+
const cPhi = Math.cos(this.phi);
|
|
163
|
+
const sTheta = Math.sin(this.theta);
|
|
164
|
+
const cTheta = Math.cos(this.theta);
|
|
165
|
+
const sPsi = Math.sin(this.psi);
|
|
166
|
+
const cPsi = Math.cos(this.psi);
|
|
167
|
+
|
|
168
|
+
return new Matrix([
|
|
169
|
+
[cTheta * cPsi, cTheta * sPsi, -sTheta],
|
|
170
|
+
[sPhi * sTheta * cPsi - cPhi * sPsi, sPhi * sTheta * sPsi + cPhi * cPsi, sPhi * cTheta],
|
|
171
|
+
[cPhi * sTheta * cPsi + sPhi * sPsi, cPhi * sTheta * sPsi - sPhi * cPsi, cPhi * cTheta],
|
|
172
|
+
]);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Rotates a 3D vector using a 3-2-1 Euler angle sequence.
|
|
177
|
+
* @param v The vector to rotate.
|
|
178
|
+
* @returns The rotated vector.
|
|
179
|
+
*/
|
|
180
|
+
rotateVector321(v: Vector3D): Vector3D {
|
|
181
|
+
return this.dcm321().multiplyVector3D(v);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author @thkruz Theodore Kruczek
|
|
3
|
+
* @license AGPL-3.0-or-later
|
|
4
|
+
* @copyright (c) 2020-2024 Theodore Kruczek
|
|
5
|
+
*
|
|
6
|
+
* Orbital Object ToolKit is free software: you can redistribute it and/or modify it under the
|
|
7
|
+
* terms of the GNU Affero General Public License as published by the Free Software
|
|
8
|
+
* Foundation, either version 3 of the License, or (at your option) any later version.
|
|
9
|
+
*
|
|
10
|
+
* Orbital Object ToolKit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
11
|
+
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
12
|
+
* See the GNU Affero General Public License for more details.
|
|
13
|
+
*
|
|
14
|
+
* You should have received a copy of the GNU Affero General Public License along with
|
|
15
|
+
* Orbital Object ToolKit. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { Matrix, Radians, RadiansPerSecond, Vector, Vector3D, wrapAngle } from 'ootk-core';
|
|
19
|
+
|
|
20
|
+
export class Quaternion {
|
|
21
|
+
x: number;
|
|
22
|
+
y: number;
|
|
23
|
+
z: number;
|
|
24
|
+
w: number;
|
|
25
|
+
|
|
26
|
+
constructor(x: number, y: number, z: number, w: number) {
|
|
27
|
+
this.x = x;
|
|
28
|
+
this.y = y;
|
|
29
|
+
this.z = z;
|
|
30
|
+
this.w = w;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
static zero = new Quaternion(0, 0, 0, 0);
|
|
34
|
+
static one = new Quaternion(0, 0, 0, 1);
|
|
35
|
+
static xAxis = new Quaternion(1, 0, 0, 0);
|
|
36
|
+
static yAxis = new Quaternion(0, 1, 0, 0);
|
|
37
|
+
static zAxis = new Quaternion(0, 0, 1, 0);
|
|
38
|
+
|
|
39
|
+
toString(precision = 8): string {
|
|
40
|
+
const xStr = this.x.toFixed(precision);
|
|
41
|
+
const yStr = this.y.toFixed(precision);
|
|
42
|
+
const zStr = this.z.toFixed(precision);
|
|
43
|
+
const wStr = this.w.toFixed(precision);
|
|
44
|
+
|
|
45
|
+
return `Q(x: ${xStr}, y: ${yStr}, z: ${zStr}, w: ${wStr})`;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
positivePolar(): Quaternion {
|
|
49
|
+
return this.w >= 0 ? this.normalize() : this.negate().normalize();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
magnitudeSquared(): number {
|
|
53
|
+
return this.w * this.w + this.x * this.x + this.y * this.y + this.z * this.z;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
magnitude(): number {
|
|
57
|
+
return Math.sqrt(this.magnitudeSquared());
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
scale(n: number): Quaternion {
|
|
61
|
+
return new Quaternion(n * this.x, n * this.y, n * this.z, n * this.w);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
negate(): Quaternion {
|
|
65
|
+
return this.scale(-1);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
normalize(): Quaternion {
|
|
69
|
+
const m = this.magnitude();
|
|
70
|
+
|
|
71
|
+
if (m === 0) {
|
|
72
|
+
return Quaternion.zero;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return this.scale(1 / m);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
conjugate(): Quaternion {
|
|
79
|
+
return new Quaternion(-this.x, -this.y, -this.z, this.w);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
inverse(): Quaternion {
|
|
83
|
+
return this.conjugate().scale(1 / this.magnitudeSquared());
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
add(q: Quaternion): Quaternion {
|
|
87
|
+
return new Quaternion(this.x + q.x, this.y + q.y, this.z + q.z, this.w + q.w);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
subtract(q: Quaternion): Quaternion {
|
|
91
|
+
return new Quaternion(this.x - q.x, this.y - q.y, this.z - q.z, this.w - q.w);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
addReal(n: number): Quaternion {
|
|
95
|
+
return new Quaternion(this.x, this.y, this.z, this.w + n);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
multiply(q: Quaternion): Quaternion {
|
|
99
|
+
const mx = this.w * q.x + this.x * q.w + this.y * q.z - this.z * q.y;
|
|
100
|
+
const my = this.w * q.y - this.x * q.z + this.y * q.w + this.z * q.x;
|
|
101
|
+
const mz = this.w * q.z + this.x * q.y - this.y * q.x + this.z * q.w;
|
|
102
|
+
const mw = this.w * q.w - this.x * q.x - this.y * q.y - this.z * q.z;
|
|
103
|
+
|
|
104
|
+
return new Quaternion(mx, my, mz, mw);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
dot(q: Quaternion): number {
|
|
108
|
+
return this.x * q.x + this.y * q.y + this.z * q.z + this.w * q.w;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
rotateVector(v: Vector): Vector {
|
|
112
|
+
const q = this.multiply(new Quaternion(v.x, v.y, v.z, 0)).multiply(this.conjugate());
|
|
113
|
+
|
|
114
|
+
return new Vector([q.x, q.y, q.z]);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
rotateVector3D(v: Vector3D): Vector3D {
|
|
118
|
+
const q = this.multiply(new Quaternion(v.x, v.y, v.z, 0)).multiply(this.conjugate());
|
|
119
|
+
|
|
120
|
+
return new Vector3D(q.x, q.y, q.z);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
lerp(q: Quaternion, t: number): Quaternion {
|
|
124
|
+
const f = 1.0 - t;
|
|
125
|
+
|
|
126
|
+
return new Quaternion(
|
|
127
|
+
f * this.x + t * q.x,
|
|
128
|
+
f * this.y + t * q.y,
|
|
129
|
+
f * this.z + t * q.z,
|
|
130
|
+
f * this.w + t * q.w,
|
|
131
|
+
).positivePolar();
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
slerp(q: Quaternion, t: number): Quaternion {
|
|
135
|
+
let qp = q;
|
|
136
|
+
let dotP = this.dot(qp);
|
|
137
|
+
|
|
138
|
+
if (dotP < 0) {
|
|
139
|
+
dotP = -dotP;
|
|
140
|
+
qp = qp.negate();
|
|
141
|
+
}
|
|
142
|
+
if (dotP > 0.9995) {
|
|
143
|
+
return this.lerp(qp, t);
|
|
144
|
+
}
|
|
145
|
+
const theta = Math.acos(dotP);
|
|
146
|
+
const sinTheta = Math.sin(theta);
|
|
147
|
+
const f1 = Math.sin((1.0 - t) * theta) / sinTheta;
|
|
148
|
+
const f2 = Math.sin(t * theta) / sinTheta;
|
|
149
|
+
|
|
150
|
+
return new Quaternion(
|
|
151
|
+
f1 * this.x + f2 * qp.x,
|
|
152
|
+
f1 * this.y + f2 * qp.y,
|
|
153
|
+
f1 * this.z + f2 * qp.z,
|
|
154
|
+
f1 * this.w + f2 * qp.w,
|
|
155
|
+
).positivePolar();
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
toVector3D(): Vector3D {
|
|
159
|
+
return new Vector3D(this.x, this.y, this.z);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
angle(q: Quaternion): Radians {
|
|
163
|
+
const c = this.multiply(q.conjugate()).normalize();
|
|
164
|
+
|
|
165
|
+
return 2 * Math.atan2(c.toVector3D().magnitude(), c.w) as Radians;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
geodesicAngle(q: Quaternion): Radians {
|
|
169
|
+
const p = this.dot(q);
|
|
170
|
+
|
|
171
|
+
return wrapAngle(Math.acos(2 * p * p - 1.0) as Radians);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
distance(q: Quaternion): number {
|
|
175
|
+
const m01 = this.subtract(q).magnitude();
|
|
176
|
+
const p01 = this.add(q).magnitude();
|
|
177
|
+
|
|
178
|
+
return m01 < p01 ? m01 : p01;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
delta(qTo: Quaternion): Quaternion {
|
|
182
|
+
return this.inverse().multiply(qTo);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
toDirectionCosineMatrix(): Matrix {
|
|
186
|
+
const w2 = this.w * this.w;
|
|
187
|
+
const x2 = this.x * this.x;
|
|
188
|
+
const y2 = this.y * this.y;
|
|
189
|
+
const z2 = this.z * this.z;
|
|
190
|
+
const m = [
|
|
191
|
+
[w2 + x2 - y2 - z2, 2.0 * (this.x * this.y + this.z * this.w), 2.0 * (this.x * this.z - this.y * this.w)],
|
|
192
|
+
[2.0 * (this.x * this.y - this.z * this.w), w2 - x2 + y2 - z2, 2.0 * (this.y * this.z + this.x * this.w)],
|
|
193
|
+
[2.0 * (this.x * this.z + this.y * this.w), 2.0 * (this.y * this.z - this.x * this.w), w2 - x2 - y2 + z2],
|
|
194
|
+
];
|
|
195
|
+
|
|
196
|
+
return new Matrix(m);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
toRotationMatrix(): Matrix {
|
|
200
|
+
return this.toDirectionCosineMatrix().transpose();
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
vectorAngle(observer: Vector3D, target: Vector3D, forward: Vector3D): number {
|
|
204
|
+
const delta = target.subtract(observer);
|
|
205
|
+
const transform = this.toDirectionCosineMatrix().multiplyVector3D(delta);
|
|
206
|
+
|
|
207
|
+
return forward.angle(transform);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
kinematics(angularVelocity: Vector3D<RadiansPerSecond>): Quaternion {
|
|
211
|
+
const wPrime = new Vector([0, angularVelocity.x, angularVelocity.y, angularVelocity.z]);
|
|
212
|
+
const qMat = new Matrix([
|
|
213
|
+
[this.x, this.w, -this.z, this.y],
|
|
214
|
+
[this.y, this.z, this.w, -this.x],
|
|
215
|
+
[this.z, -this.y, this.x, this.w],
|
|
216
|
+
[this.w, -this.x, -this.y, -this.z],
|
|
217
|
+
]);
|
|
218
|
+
const result = qMat.multiplyVector(wPrime).scale(0.5).elements;
|
|
219
|
+
|
|
220
|
+
return new Quaternion(result[0], result[1], result[2], result[3]);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author @thkruz Theodore Kruczek
|
|
3
|
+
* @license AGPL-3.0-or-later
|
|
4
|
+
* @copyright (c) 2020-2024 Theodore Kruczek
|
|
5
|
+
*
|
|
6
|
+
* Orbital Object ToolKit is free software: you can redistribute it and/or modify it under the
|
|
7
|
+
* terms of the GNU Affero General Public License as published by the Free Software
|
|
8
|
+
* Foundation, either version 3 of the License, or (at your option) any later version.
|
|
9
|
+
*
|
|
10
|
+
* Orbital Object ToolKit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
11
|
+
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
12
|
+
* See the GNU Affero General Public License for more details.
|
|
13
|
+
*
|
|
14
|
+
* You should have received a copy of the GNU Affero General Public License along with
|
|
15
|
+
* Orbital Object ToolKit. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { Vector, Vector3D } from 'ootk-core';
|
|
19
|
+
import { BoxMuller } from './BoxMuller';
|
|
20
|
+
|
|
21
|
+
export class RandomGaussianSource {
|
|
22
|
+
private _boxMuller: BoxMuller;
|
|
23
|
+
|
|
24
|
+
constructor(seed = 0) {
|
|
25
|
+
this._boxMuller = new BoxMuller(0, 1, seed);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
nextGauss(): number {
|
|
29
|
+
return this._boxMuller.nextGauss();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
gaussVector(n: number): Vector {
|
|
33
|
+
if (n < 1) {
|
|
34
|
+
throw new Error('n must be greater than 0');
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const result = new Vector([this.nextGauss()]);
|
|
38
|
+
|
|
39
|
+
for (let i = 0; i < n; i++) {
|
|
40
|
+
if (i > 0) {
|
|
41
|
+
result.add(new Vector([this.nextGauss()]));
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return result;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
gaussSphere(radius = 1.0): Vector3D {
|
|
49
|
+
return this.gaussVector(3).toVector3D(0).normalize().scale(radius);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author @thkruz Theodore Kruczek
|
|
3
|
+
* @license AGPL-3.0-or-later
|
|
4
|
+
* @copyright (c) 2020-2024 Theodore Kruczek
|
|
5
|
+
*
|
|
6
|
+
* Orbital Object ToolKit is free software: you can redistribute it and/or modify it under the
|
|
7
|
+
* terms of the GNU Affero General Public License as published by the Free Software
|
|
8
|
+
* Foundation, either version 3 of the License, or (at your option) any later version.
|
|
9
|
+
*
|
|
10
|
+
* Orbital Object ToolKit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
11
|
+
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
12
|
+
* See the GNU Affero General Public License for more details.
|
|
13
|
+
*
|
|
14
|
+
* You should have received a copy of the GNU Affero General Public License along with
|
|
15
|
+
* Orbital Object ToolKit. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { EpochUTC, Seconds, Vector3D } from 'ootk-core';
|
|
19
|
+
import { StateInterpolator } from '../interpolator/StateInterpolator';
|
|
20
|
+
import { ChebyshevCoefficients } from './../interpolator/ChebyshevCoefficients';
|
|
21
|
+
import { ChebyshevInterpolator } from './../interpolator/ChebyshevInterpolator';
|
|
22
|
+
|
|
23
|
+
// / Ephemeris compressor.
|
|
24
|
+
export class ChebyshevCompressor {
|
|
25
|
+
// / Create a new [ChebyshevCompressor] object from an [Interpolator].
|
|
26
|
+
constructor(private _interpolator: StateInterpolator) {
|
|
27
|
+
// Do nothing.
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// / Return the cosine of π times [x].
|
|
31
|
+
private static _cosPi(x: number): number {
|
|
32
|
+
return Math.cos(Math.PI * x);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
private _fitCoefficient(j: number, n: number, a: number, b: number): Vector3D {
|
|
36
|
+
let sumX = 0.0;
|
|
37
|
+
let sumY = 0.0;
|
|
38
|
+
let sumZ = 0.0;
|
|
39
|
+
const h = 0.5;
|
|
40
|
+
|
|
41
|
+
for (let i = 0; i < n; i++) {
|
|
42
|
+
const x = ChebyshevCompressor._cosPi((i + h) / n);
|
|
43
|
+
const seconds = x * (h * (b - a)) + h * (b + a) as Seconds;
|
|
44
|
+
const state = this._interpolator.interpolate(new EpochUTC(seconds))!;
|
|
45
|
+
const fx = state.position.x;
|
|
46
|
+
const fy = state.position.y;
|
|
47
|
+
const fz = state.position.z;
|
|
48
|
+
const nFac = ChebyshevCompressor._cosPi((j * (i + h)) / n);
|
|
49
|
+
|
|
50
|
+
sumX += fx * nFac;
|
|
51
|
+
sumY += fy * nFac;
|
|
52
|
+
sumZ += fz * nFac;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return new Vector3D(sumX * (2 / n), sumY * (2 / n), sumZ * (2 / n));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
private _fitWindow(coeffs: number, a: Seconds, b: Seconds): ChebyshevCoefficients {
|
|
59
|
+
const cx = new Float64Array();
|
|
60
|
+
const cy = new Float64Array();
|
|
61
|
+
const cz = new Float64Array();
|
|
62
|
+
|
|
63
|
+
for (let j = 0; j < coeffs; j++) {
|
|
64
|
+
const result = this._fitCoefficient(j, coeffs, a, b);
|
|
65
|
+
|
|
66
|
+
cx[j] = result.x;
|
|
67
|
+
cy[j] = result.y;
|
|
68
|
+
cz[j] = result.z;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return new ChebyshevCoefficients(a, b, cx, cy, cz);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Compress this object's interpolater, using the provided coefficients
|
|
76
|
+
* per revolution [cpr].
|
|
77
|
+
* @param cpr Coefficients per revolution.
|
|
78
|
+
* @returns A new [ChebyshevInterpolator] object.
|
|
79
|
+
*/
|
|
80
|
+
compress(cpr = 21): ChebyshevInterpolator {
|
|
81
|
+
const { start, end } = this._interpolator.window();
|
|
82
|
+
const period = this._interpolator.interpolate(start)!.period;
|
|
83
|
+
const coefficients: ChebyshevCoefficients[] = [];
|
|
84
|
+
let current = start;
|
|
85
|
+
|
|
86
|
+
while (current < end) {
|
|
87
|
+
const step = Math.min(period, end.posix - current.posix) as Seconds;
|
|
88
|
+
const segment = current.roll(step);
|
|
89
|
+
|
|
90
|
+
coefficients.push(this._fitWindow(cpr, current.posix, segment.posix));
|
|
91
|
+
current = segment;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return new ChebyshevInterpolator(coefficients);
|
|
95
|
+
}
|
|
96
|
+
}
|