@interstellar-tools/equations 1.0.0 → 1.2.0
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/dist/categories/anomalies/asymptote-true-anomaly.d.ts +50 -0
- package/dist/categories/anomalies/asymptote-true-anomaly.d.ts.map +1 -0
- package/dist/categories/anomalies/asymptote-true-anomaly.js +55 -0
- package/dist/categories/anomalies/asymptote-true-anomaly.js.map +1 -0
- package/dist/categories/anomalies/hyperbolic-to-true-anomaly.d.ts +38 -0
- package/dist/categories/anomalies/hyperbolic-to-true-anomaly.d.ts.map +1 -0
- package/dist/categories/anomalies/hyperbolic-to-true-anomaly.js +49 -0
- package/dist/categories/anomalies/hyperbolic-to-true-anomaly.js.map +1 -0
- package/dist/categories/anomalies/true-to-hyperbolic-anomaly.d.ts +40 -0
- package/dist/categories/anomalies/true-to-hyperbolic-anomaly.d.ts.map +1 -0
- package/dist/categories/anomalies/true-to-hyperbolic-anomaly.js +54 -0
- package/dist/categories/anomalies/true-to-hyperbolic-anomaly.js.map +1 -0
- package/dist/categories/helpers/misc.d.ts +18 -0
- package/dist/categories/helpers/misc.d.ts.map +1 -1
- package/dist/categories/helpers/misc.js +24 -0
- package/dist/categories/helpers/misc.js.map +1 -1
- package/dist/categories/kepler/solve-kepler-hyperbolic.d.ts +49 -0
- package/dist/categories/kepler/solve-kepler-hyperbolic.d.ts.map +1 -0
- package/dist/categories/kepler/solve-kepler-hyperbolic.js +90 -0
- package/dist/categories/kepler/solve-kepler-hyperbolic.js.map +1 -0
- package/dist/categories/manoeuvres/burn-time.d.ts +63 -0
- package/dist/categories/manoeuvres/burn-time.d.ts.map +1 -0
- package/dist/categories/manoeuvres/burn-time.js +87 -0
- package/dist/categories/manoeuvres/burn-time.js.map +1 -0
- package/dist/categories/manoeuvres/gravity-loss.d.ts +48 -0
- package/dist/categories/manoeuvres/gravity-loss.d.ts.map +1 -0
- package/dist/categories/manoeuvres/gravity-loss.js +74 -0
- package/dist/categories/manoeuvres/gravity-loss.js.map +1 -0
- package/dist/categories/manoeuvres/initial-mass-for-delta-v.d.ts +60 -0
- package/dist/categories/manoeuvres/initial-mass-for-delta-v.d.ts.map +1 -0
- package/dist/categories/manoeuvres/initial-mass-for-delta-v.js +79 -0
- package/dist/categories/manoeuvres/initial-mass-for-delta-v.js.map +1 -0
- package/dist/categories/manoeuvres/mass-flow-rate.d.ts +57 -0
- package/dist/categories/manoeuvres/mass-flow-rate.d.ts.map +1 -0
- package/dist/categories/manoeuvres/mass-flow-rate.js +73 -0
- package/dist/categories/manoeuvres/mass-flow-rate.js.map +1 -0
- package/dist/categories/manoeuvres/rocket-thrust.d.ts +48 -0
- package/dist/categories/manoeuvres/rocket-thrust.d.ts.map +1 -0
- package/dist/categories/manoeuvres/rocket-thrust.js +62 -0
- package/dist/categories/manoeuvres/rocket-thrust.js.map +1 -0
- package/dist/categories/manoeuvres/thrust-to-weight.d.ts +57 -0
- package/dist/categories/manoeuvres/thrust-to-weight.d.ts.map +1 -0
- package/dist/categories/manoeuvres/thrust-to-weight.js +73 -0
- package/dist/categories/manoeuvres/thrust-to-weight.js.map +1 -0
- package/dist/categories/orbits/elements-to-state.d.ts +61 -0
- package/dist/categories/orbits/elements-to-state.d.ts.map +1 -0
- package/dist/categories/orbits/elements-to-state.js +107 -0
- package/dist/categories/orbits/elements-to-state.js.map +1 -0
- package/dist/categories/orbits/hyperbolic-eccentricity.d.ts +56 -0
- package/dist/categories/orbits/hyperbolic-eccentricity.d.ts.map +1 -0
- package/dist/categories/orbits/hyperbolic-eccentricity.js +72 -0
- package/dist/categories/orbits/hyperbolic-eccentricity.js.map +1 -0
- package/dist/categories/orbits/hyperbolic-semi-major-axis.d.ts +53 -0
- package/dist/categories/orbits/hyperbolic-semi-major-axis.d.ts.map +1 -0
- package/dist/categories/orbits/hyperbolic-semi-major-axis.js +66 -0
- package/dist/categories/orbits/hyperbolic-semi-major-axis.js.map +1 -0
- package/dist/categories/orbits/hyperbolic-time-of-flight.d.ts +64 -0
- package/dist/categories/orbits/hyperbolic-time-of-flight.d.ts.map +1 -0
- package/dist/categories/orbits/hyperbolic-time-of-flight.js +86 -0
- package/dist/categories/orbits/hyperbolic-time-of-flight.js.map +1 -0
- package/dist/categories/orbits/inclination-from-launch-azimuth.d.ts +64 -0
- package/dist/categories/orbits/inclination-from-launch-azimuth.d.ts.map +1 -0
- package/dist/categories/orbits/inclination-from-launch-azimuth.js +76 -0
- package/dist/categories/orbits/inclination-from-launch-azimuth.js.map +1 -0
- package/dist/categories/orbits/launch-azimuth-for-inclination.d.ts +71 -0
- package/dist/categories/orbits/launch-azimuth-for-inclination.d.ts.map +1 -0
- package/dist/categories/orbits/launch-azimuth-for-inclination.js +87 -0
- package/dist/categories/orbits/launch-azimuth-for-inclination.js.map +1 -0
- package/dist/categories/orbits/rotating-launch-azimuth.d.ts +49 -0
- package/dist/categories/orbits/rotating-launch-azimuth.d.ts.map +1 -0
- package/dist/categories/orbits/rotating-launch-azimuth.js +65 -0
- package/dist/categories/orbits/rotating-launch-azimuth.js.map +1 -0
- package/dist/categories/orbits/state-to-elements.d.ts +82 -0
- package/dist/categories/orbits/state-to-elements.d.ts.map +1 -0
- package/dist/categories/orbits/state-to-elements.js +131 -0
- package/dist/categories/orbits/state-to-elements.js.map +1 -0
- package/dist/categories/orbits/surface-rotation-speed.d.ts +61 -0
- package/dist/categories/orbits/surface-rotation-speed.d.ts.map +1 -0
- package/dist/categories/orbits/surface-rotation-speed.js +74 -0
- package/dist/categories/orbits/surface-rotation-speed.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compute the **thrust-to-weight ratio** of a vehicle in a gravity field.
|
|
3
|
+
*
|
|
4
|
+
* $$
|
|
5
|
+
* \frac{T}{W} = \frac{F}{m\, g}
|
|
6
|
+
* $$
|
|
7
|
+
*
|
|
8
|
+
* Where:
|
|
9
|
+
* - $ F $ is the thrust (N)
|
|
10
|
+
* - $ m $ is the vehicle's mass (kg)
|
|
11
|
+
* - $ g $ is the local gravitational acceleration (m/s²)
|
|
12
|
+
*
|
|
13
|
+
* **Units**
|
|
14
|
+
* - Inputs: `F` in **N**, `m` in **kg**, `g` in **m/s²**.
|
|
15
|
+
* - Output: dimensionless ratio.
|
|
16
|
+
*
|
|
17
|
+
* ::: info Notes
|
|
18
|
+
*
|
|
19
|
+
* - A vehicle can only lift off vertically when $ T/W > 1 $.
|
|
20
|
+
* - Use the local $ g $, e.g. $ \mu / r^2 $ for the body you're on, not standard gravity.
|
|
21
|
+
* - The ratio grows during a burn as propellant is used up; pass the current mass.
|
|
22
|
+
*
|
|
23
|
+
* :::
|
|
24
|
+
*
|
|
25
|
+
* ::: practice Apollo 11's lunar module, leaving the Moon
|
|
26
|
+
*
|
|
27
|
+
* **1.94**
|
|
28
|
+
*
|
|
29
|
+
* _Ascent stage at liftoff, in the Moon's 1.62 m/s² gravity_
|
|
30
|
+
*
|
|
31
|
+
* On Earth the same stage would manage only 0.32: too little to lift off.
|
|
32
|
+
*
|
|
33
|
+
* ```ts
|
|
34
|
+
* thrustToWeight(15_409, 4888, 1.624); // ≈ 1.94
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* :::
|
|
38
|
+
*
|
|
39
|
+
* @param F - Thrust $ F $ in **N** (finite, >= 0).
|
|
40
|
+
* @param m - Mass $ m $ in **kg** (finite, > 0).
|
|
41
|
+
* @param g - Local gravitational acceleration $ g $ in **m/s²** (finite, > 0).
|
|
42
|
+
* @returns Thrust-to-weight ratio (dimensionless).
|
|
43
|
+
* @throws {TypeError} If any input is not a finite number.
|
|
44
|
+
* @throws {RangeError} If `F < 0`, `m <= 0` or `g <= 0`.
|
|
45
|
+
* @group Manoeuvres
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```ts
|
|
49
|
+
* // A 2000 kg lander with a 45 kN engine on Mars (g ≈ 3.71 m/s²)
|
|
50
|
+
* const tw = thrustToWeight(45_000, 2000, 3.71);
|
|
51
|
+
* // tw ≈ 6.06
|
|
52
|
+
* ```
|
|
53
|
+
*
|
|
54
|
+
* @see {@link massFlowRate}
|
|
55
|
+
*/
|
|
56
|
+
export declare const thrustToWeight: (F: number, m: number, g: number) => number;
|
|
57
|
+
//# sourceMappingURL=thrust-to-weight.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"thrust-to-weight.d.ts","sourceRoot":"","sources":["../../../src/categories/manoeuvres/thrust-to-weight.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,eAAO,MAAM,cAAc,GAAI,GAAG,MAAM,EAAE,GAAG,MAAM,EAAE,GAAG,MAAM,KAAG,MAiBhE,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compute the **thrust-to-weight ratio** of a vehicle in a gravity field.
|
|
3
|
+
*
|
|
4
|
+
* $$
|
|
5
|
+
* \frac{T}{W} = \frac{F}{m\, g}
|
|
6
|
+
* $$
|
|
7
|
+
*
|
|
8
|
+
* Where:
|
|
9
|
+
* - $ F $ is the thrust (N)
|
|
10
|
+
* - $ m $ is the vehicle's mass (kg)
|
|
11
|
+
* - $ g $ is the local gravitational acceleration (m/s²)
|
|
12
|
+
*
|
|
13
|
+
* **Units**
|
|
14
|
+
* - Inputs: `F` in **N**, `m` in **kg**, `g` in **m/s²**.
|
|
15
|
+
* - Output: dimensionless ratio.
|
|
16
|
+
*
|
|
17
|
+
* ::: info Notes
|
|
18
|
+
*
|
|
19
|
+
* - A vehicle can only lift off vertically when $ T/W > 1 $.
|
|
20
|
+
* - Use the local $ g $, e.g. $ \mu / r^2 $ for the body you're on, not standard gravity.
|
|
21
|
+
* - The ratio grows during a burn as propellant is used up; pass the current mass.
|
|
22
|
+
*
|
|
23
|
+
* :::
|
|
24
|
+
*
|
|
25
|
+
* ::: practice Apollo 11's lunar module, leaving the Moon
|
|
26
|
+
*
|
|
27
|
+
* **1.94**
|
|
28
|
+
*
|
|
29
|
+
* _Ascent stage at liftoff, in the Moon's 1.62 m/s² gravity_
|
|
30
|
+
*
|
|
31
|
+
* On Earth the same stage would manage only 0.32: too little to lift off.
|
|
32
|
+
*
|
|
33
|
+
* ```ts
|
|
34
|
+
* thrustToWeight(15_409, 4888, 1.624); // ≈ 1.94
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* :::
|
|
38
|
+
*
|
|
39
|
+
* @param F - Thrust $ F $ in **N** (finite, >= 0).
|
|
40
|
+
* @param m - Mass $ m $ in **kg** (finite, > 0).
|
|
41
|
+
* @param g - Local gravitational acceleration $ g $ in **m/s²** (finite, > 0).
|
|
42
|
+
* @returns Thrust-to-weight ratio (dimensionless).
|
|
43
|
+
* @throws {TypeError} If any input is not a finite number.
|
|
44
|
+
* @throws {RangeError} If `F < 0`, `m <= 0` or `g <= 0`.
|
|
45
|
+
* @group Manoeuvres
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```ts
|
|
49
|
+
* // A 2000 kg lander with a 45 kN engine on Mars (g ≈ 3.71 m/s²)
|
|
50
|
+
* const tw = thrustToWeight(45_000, 2000, 3.71);
|
|
51
|
+
* // tw ≈ 6.06
|
|
52
|
+
* ```
|
|
53
|
+
*
|
|
54
|
+
* @see {@link massFlowRate}
|
|
55
|
+
*/
|
|
56
|
+
export const thrustToWeight = (F, m, g) => {
|
|
57
|
+
for (const [name, v] of [
|
|
58
|
+
['F', F],
|
|
59
|
+
['m', m],
|
|
60
|
+
['g', g]
|
|
61
|
+
]) {
|
|
62
|
+
if (!Number.isFinite(v))
|
|
63
|
+
throw new TypeError(`${name} must be a finite number. Received: ${v}`);
|
|
64
|
+
}
|
|
65
|
+
if (F < 0)
|
|
66
|
+
throw new RangeError(`F must be >= 0. Received: ${F}`);
|
|
67
|
+
if (m <= 0)
|
|
68
|
+
throw new RangeError(`m must be > 0. Received: ${m}`);
|
|
69
|
+
if (g <= 0)
|
|
70
|
+
throw new RangeError(`g must be > 0. Received: ${g}`);
|
|
71
|
+
return F / (m * g);
|
|
72
|
+
};
|
|
73
|
+
//# sourceMappingURL=thrust-to-weight.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"thrust-to-weight.js","sourceRoot":"","sources":["../../../src/categories/manoeuvres/thrust-to-weight.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAS,EAAE,CAAS,EAAE,CAAS,EAAU,EAAE;IACxE,KAAK,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI;QACtB,CAAC,GAAG,EAAE,CAAC,CAAC;QACR,CAAC,GAAG,EAAE,CAAC,CAAC;QACR,CAAC,GAAG,EAAE,CAAC,CAAC;KACA,EAAE,CAAC;QACX,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;YACrB,MAAM,IAAI,SAAS,CAAC,GAAG,IAAI,uCAAuC,CAAC,EAAE,CAAC,CAAC;IAC3E,CAAC;IAED,IAAI,CAAC,GAAG,CAAC;QAAE,MAAM,IAAI,UAAU,CAAC,6BAA6B,CAAC,EAAE,CAAC,CAAC;IAElE,IAAI,CAAC,IAAI,CAAC;QAAE,MAAM,IAAI,UAAU,CAAC,4BAA4B,CAAC,EAAE,CAAC,CAAC;IAElE,IAAI,CAAC,IAAI,CAAC;QAAE,MAAM,IAAI,UAAU,CAAC,4BAA4B,CAAC,EAAE,CAAC,CAAC;IAElE,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;AACrB,CAAC,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { ClassicalElementsInterface, StateVectorInterface } from '@interstellar-tools/types';
|
|
2
|
+
/**
|
|
3
|
+
* Convert the six **classical orbital elements** to a **state vector** (position and velocity).
|
|
4
|
+
*
|
|
5
|
+
* In the perifocal frame, with $ p = a(1 - e^2) $:
|
|
6
|
+
*
|
|
7
|
+
* $$
|
|
8
|
+
* \mathbf r_{PQW} = \frac{p}{1 + e\cos\nu}\begin{pmatrix}\cos\nu \\ \sin\nu \\ 0\end{pmatrix}, \quad
|
|
9
|
+
* \mathbf v_{PQW} = \sqrt{\frac{\mu}{p}}\begin{pmatrix}-\sin\nu \\ e + \cos\nu \\ 0\end{pmatrix}
|
|
10
|
+
* $$
|
|
11
|
+
*
|
|
12
|
+
* then rotated into the inertial frame:
|
|
13
|
+
*
|
|
14
|
+
* $$
|
|
15
|
+
* \mathbf r = R_3(\Omega)\,R_1(i)\,R_3(\omega)\,\mathbf r_{PQW}, \quad
|
|
16
|
+
* \mathbf v = R_3(\Omega)\,R_1(i)\,R_3(\omega)\,\mathbf v_{PQW}
|
|
17
|
+
* $$
|
|
18
|
+
*
|
|
19
|
+
* **Units**
|
|
20
|
+
* - Inputs: `a` in **m**, `e` dimensionless, angles in **radians**, `mu` in **m³/s²**.
|
|
21
|
+
* - Output: `r` in **m**, `v` in **m/s**.
|
|
22
|
+
*
|
|
23
|
+
* ::: info Notes
|
|
24
|
+
*
|
|
25
|
+
* - The inverse of {@link stateToElements}, including its conventions for circular and equatorial orbits.
|
|
26
|
+
* - Elliptic orbits need $ a > 0 $ and hyperbolic ones $ a < 0 $. A parabolic orbit ($ e = 1 $) has no finite $ a $, so it isn't supported.
|
|
27
|
+
* - On a hyperbola, only true anomalies with $ 1 + e\cos\nu > 0 $ exist: the body never reaches the asymptotes.
|
|
28
|
+
*
|
|
29
|
+
* :::
|
|
30
|
+
*
|
|
31
|
+
* @param elements - The classical orbital elements.
|
|
32
|
+
* @param mu - Gravitational parameter $ \mu $ in **m³/s²** (finite, > 0).
|
|
33
|
+
* @returns The position `r` in **m** and velocity `v` in **m/s**.
|
|
34
|
+
* @throws {TypeError} If any input is not a finite number.
|
|
35
|
+
* @throws {RangeError} If `mu <= 0`, `e < 0`, `e = 1`, `i` is outside [0, π], `a` has the wrong sign for `e`, or `nu` is beyond a hyperbola's asymptotes.
|
|
36
|
+
* @group Orbits
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```ts
|
|
40
|
+
* import type { Radians } from '@interstellar-tools/types';
|
|
41
|
+
*
|
|
42
|
+
* // A circular, equatorial orbit at 7000 km, a quarter of the way round
|
|
43
|
+
* const { r, v } = elementsToState(
|
|
44
|
+
* {
|
|
45
|
+
* a: 7_000_000,
|
|
46
|
+
* e: 0,
|
|
47
|
+
* i: 0 as Radians,
|
|
48
|
+
* raan: 0 as Radians,
|
|
49
|
+
* argp: 0 as Radians,
|
|
50
|
+
* nu: (Math.PI / 2) as Radians
|
|
51
|
+
* },
|
|
52
|
+
* 3.986004418e14
|
|
53
|
+
* );
|
|
54
|
+
* // r ≈ [0, 7 000 000, 0] m, v ≈ [-7546, 0, 0] m/s
|
|
55
|
+
* ```
|
|
56
|
+
*
|
|
57
|
+
* @see {@link stateToElements}
|
|
58
|
+
* @see https://en.wikipedia.org/wiki/Perifocal_coordinate_system Perifocal coordinate system
|
|
59
|
+
*/
|
|
60
|
+
export declare const elementsToState: (elements: ClassicalElementsInterface, mu: number) => StateVectorInterface;
|
|
61
|
+
//# sourceMappingURL=elements-to-state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"elements-to-state.d.ts","sourceRoot":"","sources":["../../../src/categories/orbits/elements-to-state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,0BAA0B,EAC1B,oBAAoB,EAErB,MAAM,2BAA2B,CAAC;AAOnC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyDG;AACH,eAAO,MAAM,eAAe,GAC1B,UAAU,0BAA0B,EACpC,IAAI,MAAM,KACT,oBA4DF,CAAC"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { applyMatrix3 } from '../helpers/apply-matrix-3.js';
|
|
2
|
+
import { matMul3 } from '../helpers/mat-mul3.js';
|
|
3
|
+
import { rot1 } from '../helpers/rot-1.js';
|
|
4
|
+
import { rot3 } from '../helpers/rot-3.js';
|
|
5
|
+
/**
|
|
6
|
+
* Convert the six **classical orbital elements** to a **state vector** (position and velocity).
|
|
7
|
+
*
|
|
8
|
+
* In the perifocal frame, with $ p = a(1 - e^2) $:
|
|
9
|
+
*
|
|
10
|
+
* $$
|
|
11
|
+
* \mathbf r_{PQW} = \frac{p}{1 + e\cos\nu}\begin{pmatrix}\cos\nu \\ \sin\nu \\ 0\end{pmatrix}, \quad
|
|
12
|
+
* \mathbf v_{PQW} = \sqrt{\frac{\mu}{p}}\begin{pmatrix}-\sin\nu \\ e + \cos\nu \\ 0\end{pmatrix}
|
|
13
|
+
* $$
|
|
14
|
+
*
|
|
15
|
+
* then rotated into the inertial frame:
|
|
16
|
+
*
|
|
17
|
+
* $$
|
|
18
|
+
* \mathbf r = R_3(\Omega)\,R_1(i)\,R_3(\omega)\,\mathbf r_{PQW}, \quad
|
|
19
|
+
* \mathbf v = R_3(\Omega)\,R_1(i)\,R_3(\omega)\,\mathbf v_{PQW}
|
|
20
|
+
* $$
|
|
21
|
+
*
|
|
22
|
+
* **Units**
|
|
23
|
+
* - Inputs: `a` in **m**, `e` dimensionless, angles in **radians**, `mu` in **m³/s²**.
|
|
24
|
+
* - Output: `r` in **m**, `v` in **m/s**.
|
|
25
|
+
*
|
|
26
|
+
* ::: info Notes
|
|
27
|
+
*
|
|
28
|
+
* - The inverse of {@link stateToElements}, including its conventions for circular and equatorial orbits.
|
|
29
|
+
* - Elliptic orbits need $ a > 0 $ and hyperbolic ones $ a < 0 $. A parabolic orbit ($ e = 1 $) has no finite $ a $, so it isn't supported.
|
|
30
|
+
* - On a hyperbola, only true anomalies with $ 1 + e\cos\nu > 0 $ exist: the body never reaches the asymptotes.
|
|
31
|
+
*
|
|
32
|
+
* :::
|
|
33
|
+
*
|
|
34
|
+
* @param elements - The classical orbital elements.
|
|
35
|
+
* @param mu - Gravitational parameter $ \mu $ in **m³/s²** (finite, > 0).
|
|
36
|
+
* @returns The position `r` in **m** and velocity `v` in **m/s**.
|
|
37
|
+
* @throws {TypeError} If any input is not a finite number.
|
|
38
|
+
* @throws {RangeError} If `mu <= 0`, `e < 0`, `e = 1`, `i` is outside [0, π], `a` has the wrong sign for `e`, or `nu` is beyond a hyperbola's asymptotes.
|
|
39
|
+
* @group Orbits
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```ts
|
|
43
|
+
* import type { Radians } from '@interstellar-tools/types';
|
|
44
|
+
*
|
|
45
|
+
* // A circular, equatorial orbit at 7000 km, a quarter of the way round
|
|
46
|
+
* const { r, v } = elementsToState(
|
|
47
|
+
* {
|
|
48
|
+
* a: 7_000_000,
|
|
49
|
+
* e: 0,
|
|
50
|
+
* i: 0 as Radians,
|
|
51
|
+
* raan: 0 as Radians,
|
|
52
|
+
* argp: 0 as Radians,
|
|
53
|
+
* nu: (Math.PI / 2) as Radians
|
|
54
|
+
* },
|
|
55
|
+
* 3.986004418e14
|
|
56
|
+
* );
|
|
57
|
+
* // r ≈ [0, 7 000 000, 0] m, v ≈ [-7546, 0, 0] m/s
|
|
58
|
+
* ```
|
|
59
|
+
*
|
|
60
|
+
* @see {@link stateToElements}
|
|
61
|
+
* @see https://en.wikipedia.org/wiki/Perifocal_coordinate_system Perifocal coordinate system
|
|
62
|
+
*/
|
|
63
|
+
export const elementsToState = (elements, mu) => {
|
|
64
|
+
const { a, e, i, raan, argp, nu } = elements;
|
|
65
|
+
for (const [name, x] of [
|
|
66
|
+
['a', a],
|
|
67
|
+
['e', e],
|
|
68
|
+
['i', i],
|
|
69
|
+
['raan', raan],
|
|
70
|
+
['argp', argp],
|
|
71
|
+
['nu', nu],
|
|
72
|
+
['mu', mu]
|
|
73
|
+
]) {
|
|
74
|
+
if (!Number.isFinite(x))
|
|
75
|
+
throw new TypeError(`${name} must be a finite number. Received: ${x}`);
|
|
76
|
+
}
|
|
77
|
+
if (mu <= 0)
|
|
78
|
+
throw new RangeError(`mu must be > 0. Received: ${mu}`);
|
|
79
|
+
if (e < 0)
|
|
80
|
+
throw new RangeError(`e must be >= 0. Received: ${e}`);
|
|
81
|
+
if (Math.abs(e - 1) < 1e-12)
|
|
82
|
+
throw new RangeError('Parabolic orbits (e = 1) are not supported: they have no finite semi-major axis.');
|
|
83
|
+
if (i < 0 || i > Math.PI)
|
|
84
|
+
throw new RangeError(`i must be in [0, π]. Received: ${i}`);
|
|
85
|
+
if (e < 1 && a <= 0)
|
|
86
|
+
throw new RangeError(`a must be > 0 for an elliptic orbit. Received: a=${a}, e=${e}`);
|
|
87
|
+
if (e > 1 && a >= 0)
|
|
88
|
+
throw new RangeError(`a must be < 0 for a hyperbolic orbit. Received: a=${a}, e=${e}`);
|
|
89
|
+
const p = a * (1 - e * e);
|
|
90
|
+
const denominator = 1 + e * Math.cos(nu);
|
|
91
|
+
if (denominator <= 0)
|
|
92
|
+
throw new RangeError(`nu is beyond the hyperbola's asymptotes (1 + e cos nu <= 0). Received: nu=${nu}, e=${e}`);
|
|
93
|
+
const rPqw = [
|
|
94
|
+
(p * Math.cos(nu)) / denominator,
|
|
95
|
+
(p * Math.sin(nu)) / denominator,
|
|
96
|
+
0
|
|
97
|
+
];
|
|
98
|
+
const speed = Math.sqrt(mu / p);
|
|
99
|
+
const vPqw = [
|
|
100
|
+
-speed * Math.sin(nu),
|
|
101
|
+
speed * (e + Math.cos(nu)),
|
|
102
|
+
0
|
|
103
|
+
];
|
|
104
|
+
const Q = matMul3(matMul3(rot3(raan), rot1(i)), rot3(argp));
|
|
105
|
+
return { r: applyMatrix3(Q, rPqw), v: applyMatrix3(Q, vPqw) };
|
|
106
|
+
};
|
|
107
|
+
//# sourceMappingURL=elements-to-state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"elements-to-state.js","sourceRoot":"","sources":["../../../src/categories/orbits/elements-to-state.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compute the **eccentricity of a hyperbola** from the excess speed and the periapsis distance.
|
|
3
|
+
*
|
|
4
|
+
* $$
|
|
5
|
+
* e = 1 + \frac{r_p\, v_\infty^2}{\mu}
|
|
6
|
+
* $$
|
|
7
|
+
*
|
|
8
|
+
* Where:
|
|
9
|
+
* - $ r_p $ is the periapsis distance from the body's centre (m)
|
|
10
|
+
* - $ v_\infty $ is the hyperbolic excess speed (m/s)
|
|
11
|
+
* - $ \mu $ is the body's gravitational parameter (m³/s²)
|
|
12
|
+
*
|
|
13
|
+
* **Units**
|
|
14
|
+
* - Inputs: `vInfinity` in **m/s**, `rp` in **m**, `mu` in **m³/s²**.
|
|
15
|
+
* - Output: $ e $ dimensionless, > 1.
|
|
16
|
+
*
|
|
17
|
+
* ::: info Notes
|
|
18
|
+
*
|
|
19
|
+
* - From $ r_p = a(1 - e) $ with $ a = -\mu / v_\infty^2 $.
|
|
20
|
+
* - A slow, close pass gives $ e $ just above 1, a nearly parabolic swing; a fast, distant one gives a large $ e $ and a nearly straight path.
|
|
21
|
+
* - The trajectory turns through $ 2\arcsin(1/e) $; see `gravityAssistTurningAngle`.
|
|
22
|
+
*
|
|
23
|
+
* :::
|
|
24
|
+
*
|
|
25
|
+
* ::: practice Apollo 11, arriving at the Moon
|
|
26
|
+
*
|
|
27
|
+
* **1.44**
|
|
28
|
+
*
|
|
29
|
+
* _Approach hyperbola: 1.08 km/s excess speed, closest approach 113.9 km above the surface_
|
|
30
|
+
*
|
|
31
|
+
* ```ts
|
|
32
|
+
* hyperbolicEccentricity(1080, 1_737_400 + 113_900, 4.902800118e12); // ≈ 1.440
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* :::
|
|
36
|
+
*
|
|
37
|
+
* @param vInfinity - Hyperbolic excess speed $ v_\infty $ in **m/s** (finite, > 0).
|
|
38
|
+
* @param rp - Periapsis distance $ r_p $ in **m** (finite, > 0).
|
|
39
|
+
* @param mu - Gravitational parameter $ \mu $ in **m³/s²** (finite, > 0).
|
|
40
|
+
* @returns Eccentricity $ e $ (> 1).
|
|
41
|
+
* @throws {TypeError} If any input is not a finite number.
|
|
42
|
+
* @throws {RangeError} If `vInfinity <= 0`, `rp <= 0` or `mu <= 0`.
|
|
43
|
+
* @group Orbits
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```ts
|
|
47
|
+
* // A Jupiter flyby: v∞ = 6 km/s, periapsis at 5 Jupiter radii
|
|
48
|
+
* const e = hyperbolicEccentricity(6000, 5 * 71_492e3, 1.26686534e17);
|
|
49
|
+
* // e ≈ 1.102
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* @see {@link hyperbolicSemiMajorAxis}
|
|
53
|
+
* @see {@link asymptoteTrueAnomaly}
|
|
54
|
+
*/
|
|
55
|
+
export declare const hyperbolicEccentricity: (vInfinity: number, rp: number, mu: number) => number;
|
|
56
|
+
//# sourceMappingURL=hyperbolic-eccentricity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hyperbolic-eccentricity.d.ts","sourceRoot":"","sources":["../../../src/categories/orbits/hyperbolic-eccentricity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AACH,eAAO,MAAM,sBAAsB,GACjC,WAAW,MAAM,EACjB,IAAI,MAAM,EACV,IAAI,MAAM,KACT,MAkBF,CAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compute the **eccentricity of a hyperbola** from the excess speed and the periapsis distance.
|
|
3
|
+
*
|
|
4
|
+
* $$
|
|
5
|
+
* e = 1 + \frac{r_p\, v_\infty^2}{\mu}
|
|
6
|
+
* $$
|
|
7
|
+
*
|
|
8
|
+
* Where:
|
|
9
|
+
* - $ r_p $ is the periapsis distance from the body's centre (m)
|
|
10
|
+
* - $ v_\infty $ is the hyperbolic excess speed (m/s)
|
|
11
|
+
* - $ \mu $ is the body's gravitational parameter (m³/s²)
|
|
12
|
+
*
|
|
13
|
+
* **Units**
|
|
14
|
+
* - Inputs: `vInfinity` in **m/s**, `rp` in **m**, `mu` in **m³/s²**.
|
|
15
|
+
* - Output: $ e $ dimensionless, > 1.
|
|
16
|
+
*
|
|
17
|
+
* ::: info Notes
|
|
18
|
+
*
|
|
19
|
+
* - From $ r_p = a(1 - e) $ with $ a = -\mu / v_\infty^2 $.
|
|
20
|
+
* - A slow, close pass gives $ e $ just above 1, a nearly parabolic swing; a fast, distant one gives a large $ e $ and a nearly straight path.
|
|
21
|
+
* - The trajectory turns through $ 2\arcsin(1/e) $; see `gravityAssistTurningAngle`.
|
|
22
|
+
*
|
|
23
|
+
* :::
|
|
24
|
+
*
|
|
25
|
+
* ::: practice Apollo 11, arriving at the Moon
|
|
26
|
+
*
|
|
27
|
+
* **1.44**
|
|
28
|
+
*
|
|
29
|
+
* _Approach hyperbola: 1.08 km/s excess speed, closest approach 113.9 km above the surface_
|
|
30
|
+
*
|
|
31
|
+
* ```ts
|
|
32
|
+
* hyperbolicEccentricity(1080, 1_737_400 + 113_900, 4.902800118e12); // ≈ 1.440
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* :::
|
|
36
|
+
*
|
|
37
|
+
* @param vInfinity - Hyperbolic excess speed $ v_\infty $ in **m/s** (finite, > 0).
|
|
38
|
+
* @param rp - Periapsis distance $ r_p $ in **m** (finite, > 0).
|
|
39
|
+
* @param mu - Gravitational parameter $ \mu $ in **m³/s²** (finite, > 0).
|
|
40
|
+
* @returns Eccentricity $ e $ (> 1).
|
|
41
|
+
* @throws {TypeError} If any input is not a finite number.
|
|
42
|
+
* @throws {RangeError} If `vInfinity <= 0`, `rp <= 0` or `mu <= 0`.
|
|
43
|
+
* @group Orbits
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```ts
|
|
47
|
+
* // A Jupiter flyby: v∞ = 6 km/s, periapsis at 5 Jupiter radii
|
|
48
|
+
* const e = hyperbolicEccentricity(6000, 5 * 71_492e3, 1.26686534e17);
|
|
49
|
+
* // e ≈ 1.102
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* @see {@link hyperbolicSemiMajorAxis}
|
|
53
|
+
* @see {@link asymptoteTrueAnomaly}
|
|
54
|
+
*/
|
|
55
|
+
export const hyperbolicEccentricity = (vInfinity, rp, mu) => {
|
|
56
|
+
for (const [name, x] of [
|
|
57
|
+
['vInfinity', vInfinity],
|
|
58
|
+
['rp', rp],
|
|
59
|
+
['mu', mu]
|
|
60
|
+
]) {
|
|
61
|
+
if (!Number.isFinite(x))
|
|
62
|
+
throw new TypeError(`${name} must be a finite number. Received: ${x}`);
|
|
63
|
+
}
|
|
64
|
+
if (vInfinity <= 0)
|
|
65
|
+
throw new RangeError(`vInfinity must be > 0. Received: ${vInfinity}`);
|
|
66
|
+
if (rp <= 0)
|
|
67
|
+
throw new RangeError(`rp must be > 0. Received: ${rp}`);
|
|
68
|
+
if (mu <= 0)
|
|
69
|
+
throw new RangeError(`mu must be > 0. Received: ${mu}`);
|
|
70
|
+
return 1 + (rp * vInfinity * vInfinity) / mu;
|
|
71
|
+
};
|
|
72
|
+
//# sourceMappingURL=hyperbolic-eccentricity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hyperbolic-eccentricity.js","sourceRoot":"","sources":["../../../src/categories/orbits/hyperbolic-eccentricity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CACpC,SAAiB,EACjB,EAAU,EACV,EAAU,EACF,EAAE;IACV,KAAK,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI;QACtB,CAAC,WAAW,EAAE,SAAS,CAAC;QACxB,CAAC,IAAI,EAAE,EAAE,CAAC;QACV,CAAC,IAAI,EAAE,EAAE,CAAC;KACF,EAAE,CAAC;QACX,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;YACrB,MAAM,IAAI,SAAS,CAAC,GAAG,IAAI,uCAAuC,CAAC,EAAE,CAAC,CAAC;IAC3E,CAAC;IAED,IAAI,SAAS,IAAI,CAAC;QAChB,MAAM,IAAI,UAAU,CAAC,oCAAoC,SAAS,EAAE,CAAC,CAAC;IAExE,IAAI,EAAE,IAAI,CAAC;QAAE,MAAM,IAAI,UAAU,CAAC,6BAA6B,EAAE,EAAE,CAAC,CAAC;IAErE,IAAI,EAAE,IAAI,CAAC;QAAE,MAAM,IAAI,UAAU,CAAC,6BAA6B,EAAE,EAAE,CAAC,CAAC;IAErE,OAAO,CAAC,GAAG,CAAC,EAAE,GAAG,SAAS,GAAG,SAAS,CAAC,GAAG,EAAE,CAAC;AAC/C,CAAC,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compute the **semi-major axis of a hyperbola** from the hyperbolic excess speed.
|
|
3
|
+
*
|
|
4
|
+
* $$
|
|
5
|
+
* a = -\frac{\mu}{v_\infty^2}
|
|
6
|
+
* $$
|
|
7
|
+
*
|
|
8
|
+
* Where:
|
|
9
|
+
* - $ v_\infty $ is the hyperbolic excess speed: the speed left over far from the body (m/s)
|
|
10
|
+
* - $ \mu $ is the body's gravitational parameter (m³/s²)
|
|
11
|
+
*
|
|
12
|
+
* **Units**
|
|
13
|
+
* - Inputs: `vInfinity` in **m/s**, `mu` in **m³/s²**.
|
|
14
|
+
* - Output: $ a $ in **m**, negative.
|
|
15
|
+
*
|
|
16
|
+
* ::: info Notes
|
|
17
|
+
*
|
|
18
|
+
* - Negative by convention, so that vis-viva $ v^2 = \mu(2/r - 1/a) $ holds for hyperbolas too.
|
|
19
|
+
* - $ v_\infty $ comes from a speed $ v $ at distance $ r $ by energy: $ v_\infty^2 = v^2 - 2\mu/r $, or from {@link characteristicEnergyC3} as $ \sqrt{C_3} $.
|
|
20
|
+
*
|
|
21
|
+
* :::
|
|
22
|
+
*
|
|
23
|
+
* ::: practice Apollo 11, arriving at the Moon
|
|
24
|
+
*
|
|
25
|
+
* **−4 203 km**
|
|
26
|
+
*
|
|
27
|
+
* _Approach hyperbola, with 1.08 km/s left over far from the Moon_
|
|
28
|
+
*
|
|
29
|
+
* ```ts
|
|
30
|
+
* hyperbolicSemiMajorAxis(1080, 4.902800118e12); // ≈ -4 203 361 m
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* :::
|
|
34
|
+
*
|
|
35
|
+
* @param vInfinity - Hyperbolic excess speed $ v_\infty $ in **m/s** (finite, > 0).
|
|
36
|
+
* @param mu - Gravitational parameter $ \mu $ in **m³/s²** (finite, > 0).
|
|
37
|
+
* @returns Semi-major axis $ a $ in **m** (negative).
|
|
38
|
+
* @throws {TypeError} If any input is not a finite number.
|
|
39
|
+
* @throws {RangeError} If `vInfinity <= 0` or `mu <= 0`.
|
|
40
|
+
* @group Orbits
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```ts
|
|
44
|
+
* // Leaving Earth for Mars with v∞ ≈ 2.95 km/s
|
|
45
|
+
* const a = hyperbolicSemiMajorAxis(2950, 3.986004418e14);
|
|
46
|
+
* // a ≈ -45 803 km
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* @see {@link hyperbolicEccentricity}
|
|
50
|
+
* @see {@link hyperbolicPeriapsisSpeed}
|
|
51
|
+
*/
|
|
52
|
+
export declare const hyperbolicSemiMajorAxis: (vInfinity: number, mu: number) => number;
|
|
53
|
+
//# sourceMappingURL=hyperbolic-semi-major-axis.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hyperbolic-semi-major-axis.d.ts","sourceRoot":"","sources":["../../../src/categories/orbits/hyperbolic-semi-major-axis.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AACH,eAAO,MAAM,uBAAuB,GAClC,WAAW,MAAM,EACjB,IAAI,MAAM,KACT,MAeF,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compute the **semi-major axis of a hyperbola** from the hyperbolic excess speed.
|
|
3
|
+
*
|
|
4
|
+
* $$
|
|
5
|
+
* a = -\frac{\mu}{v_\infty^2}
|
|
6
|
+
* $$
|
|
7
|
+
*
|
|
8
|
+
* Where:
|
|
9
|
+
* - $ v_\infty $ is the hyperbolic excess speed: the speed left over far from the body (m/s)
|
|
10
|
+
* - $ \mu $ is the body's gravitational parameter (m³/s²)
|
|
11
|
+
*
|
|
12
|
+
* **Units**
|
|
13
|
+
* - Inputs: `vInfinity` in **m/s**, `mu` in **m³/s²**.
|
|
14
|
+
* - Output: $ a $ in **m**, negative.
|
|
15
|
+
*
|
|
16
|
+
* ::: info Notes
|
|
17
|
+
*
|
|
18
|
+
* - Negative by convention, so that vis-viva $ v^2 = \mu(2/r - 1/a) $ holds for hyperbolas too.
|
|
19
|
+
* - $ v_\infty $ comes from a speed $ v $ at distance $ r $ by energy: $ v_\infty^2 = v^2 - 2\mu/r $, or from {@link characteristicEnergyC3} as $ \sqrt{C_3} $.
|
|
20
|
+
*
|
|
21
|
+
* :::
|
|
22
|
+
*
|
|
23
|
+
* ::: practice Apollo 11, arriving at the Moon
|
|
24
|
+
*
|
|
25
|
+
* **−4 203 km**
|
|
26
|
+
*
|
|
27
|
+
* _Approach hyperbola, with 1.08 km/s left over far from the Moon_
|
|
28
|
+
*
|
|
29
|
+
* ```ts
|
|
30
|
+
* hyperbolicSemiMajorAxis(1080, 4.902800118e12); // ≈ -4 203 361 m
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* :::
|
|
34
|
+
*
|
|
35
|
+
* @param vInfinity - Hyperbolic excess speed $ v_\infty $ in **m/s** (finite, > 0).
|
|
36
|
+
* @param mu - Gravitational parameter $ \mu $ in **m³/s²** (finite, > 0).
|
|
37
|
+
* @returns Semi-major axis $ a $ in **m** (negative).
|
|
38
|
+
* @throws {TypeError} If any input is not a finite number.
|
|
39
|
+
* @throws {RangeError} If `vInfinity <= 0` or `mu <= 0`.
|
|
40
|
+
* @group Orbits
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```ts
|
|
44
|
+
* // Leaving Earth for Mars with v∞ ≈ 2.95 km/s
|
|
45
|
+
* const a = hyperbolicSemiMajorAxis(2950, 3.986004418e14);
|
|
46
|
+
* // a ≈ -45 803 km
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* @see {@link hyperbolicEccentricity}
|
|
50
|
+
* @see {@link hyperbolicPeriapsisSpeed}
|
|
51
|
+
*/
|
|
52
|
+
export const hyperbolicSemiMajorAxis = (vInfinity, mu) => {
|
|
53
|
+
for (const [name, x] of [
|
|
54
|
+
['vInfinity', vInfinity],
|
|
55
|
+
['mu', mu]
|
|
56
|
+
]) {
|
|
57
|
+
if (!Number.isFinite(x))
|
|
58
|
+
throw new TypeError(`${name} must be a finite number. Received: ${x}`);
|
|
59
|
+
}
|
|
60
|
+
if (vInfinity <= 0)
|
|
61
|
+
throw new RangeError(`vInfinity must be > 0. Received: ${vInfinity}`);
|
|
62
|
+
if (mu <= 0)
|
|
63
|
+
throw new RangeError(`mu must be > 0. Received: ${mu}`);
|
|
64
|
+
return -mu / (vInfinity * vInfinity);
|
|
65
|
+
};
|
|
66
|
+
//# sourceMappingURL=hyperbolic-semi-major-axis.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hyperbolic-semi-major-axis.js","sourceRoot":"","sources":["../../../src/categories/orbits/hyperbolic-semi-major-axis.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CACrC,SAAiB,EACjB,EAAU,EACF,EAAE;IACV,KAAK,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI;QACtB,CAAC,WAAW,EAAE,SAAS,CAAC;QACxB,CAAC,IAAI,EAAE,EAAE,CAAC;KACF,EAAE,CAAC;QACX,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;YACrB,MAAM,IAAI,SAAS,CAAC,GAAG,IAAI,uCAAuC,CAAC,EAAE,CAAC,CAAC;IAC3E,CAAC;IAED,IAAI,SAAS,IAAI,CAAC;QAChB,MAAM,IAAI,UAAU,CAAC,oCAAoC,SAAS,EAAE,CAAC,CAAC;IAExE,IAAI,EAAE,IAAI,CAAC;QAAE,MAAM,IAAI,UAAU,CAAC,6BAA6B,EAAE,EAAE,CAAC,CAAC;IAErE,OAAO,CAAC,EAAE,GAAG,CAAC,SAAS,GAAG,SAAS,CAAC,CAAC;AACvC,CAAC,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { Radians } from '@interstellar-tools/types';
|
|
2
|
+
/**
|
|
3
|
+
* Compute the **time of flight between two points on a hyperbola**, given by their true anomalies.
|
|
4
|
+
*
|
|
5
|
+
* $$
|
|
6
|
+
* t_2 - t_1 = \sqrt{\frac{-a^3}{\mu}}\,\Big[(e\sinh F_2 - F_2) - (e\sinh F_1 - F_1)\Big]
|
|
7
|
+
* $$
|
|
8
|
+
*
|
|
9
|
+
* with each hyperbolic anomaly $ F $ from {@link trueToHyperbolicAnomaly}.
|
|
10
|
+
*
|
|
11
|
+
* **Units**
|
|
12
|
+
* - Inputs: `nu1`, `nu2` in **radians**, `e` dimensionless, `a` in **m** (negative), `mu` in **m³/s²**.
|
|
13
|
+
* - Output: time in **s**, negative if `nu2` comes before `nu1`.
|
|
14
|
+
*
|
|
15
|
+
* ::: info Notes
|
|
16
|
+
*
|
|
17
|
+
* - Both points must lie inside the asymptotes. The incoming branch can be given as negative angles or just below 2π.
|
|
18
|
+
* - Crossing periapsis needs no special handling: $ F $ changes sign there.
|
|
19
|
+
* - To go from a time to a position, solve $ M_h = e\sinh F - F $ with {@link solveKeplerHyperbolic}, then use {@link hyperbolicToTrueAnomaly}.
|
|
20
|
+
*
|
|
21
|
+
* :::
|
|
22
|
+
*
|
|
23
|
+
* ::: practice Apollo 11, falling towards the Moon
|
|
24
|
+
*
|
|
25
|
+
* **13.8 h**
|
|
26
|
+
*
|
|
27
|
+
* _From the edge of the Moon's sphere of influence, 62 640 km out, to closest approach_
|
|
28
|
+
*
|
|
29
|
+
* The flight took 14 h 10 min from crossing into the sphere to lighting the engine for lunar orbit insertion. Patched conics leave out Earth's pull inside the sphere, one reason the two differ.
|
|
30
|
+
*
|
|
31
|
+
* ```ts
|
|
32
|
+
* const e = 1.44; // approach hyperbola
|
|
33
|
+
* const a = -4_203_000; // m
|
|
34
|
+
* const p = a * (1 - e * e);
|
|
35
|
+
* const nuSoi = -Math.acos((p / 62_640_000 - 1) / e) as Radians; // incoming
|
|
36
|
+
* hyperbolicTimeOfFlight(nuSoi, 0 as Radians, e, a, 4.902800118e12); // ≈ 49 600 s
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* :::
|
|
40
|
+
*
|
|
41
|
+
* @param nu1 - True anomaly at the start $ \nu_1 $ in **radians** (finite, inside the asymptotes).
|
|
42
|
+
* @param nu2 - True anomaly at the end $ \nu_2 $ in **radians** (finite, inside the asymptotes).
|
|
43
|
+
* @param e - Eccentricity $ e $ (finite, > 1).
|
|
44
|
+
* @param a - Semi-major axis $ a $ in **m** (finite, < 0).
|
|
45
|
+
* @param mu - Gravitational parameter $ \mu $ in **m³/s²** (finite, > 0).
|
|
46
|
+
* @returns Time of flight in **s** from `nu1` to `nu2`.
|
|
47
|
+
* @throws {TypeError} If any input is not a finite number.
|
|
48
|
+
* @throws {RangeError} If `e <= 1`, `a >= 0`, `mu <= 0`, or either true anomaly is at or beyond the asymptotes.
|
|
49
|
+
* @group Orbits
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```ts
|
|
53
|
+
* import type { Radians } from '@interstellar-tools/types';
|
|
54
|
+
*
|
|
55
|
+
* // From periapsis to 90° on a hyperbola with e = 2, a = -10 000 km, around Earth
|
|
56
|
+
* const t = hyperbolicTimeOfFlight(0 as Radians, (Math.PI / 2) as Radians, 2, -10_000e3, 3.986004418e14);
|
|
57
|
+
* // t ≈ 3 401 s
|
|
58
|
+
* ```
|
|
59
|
+
*
|
|
60
|
+
* @see {@link solveKeplerHyperbolic}
|
|
61
|
+
* @see https://en.wikipedia.org/wiki/Hyperbolic_trajectory Hyperbolic trajectory
|
|
62
|
+
*/
|
|
63
|
+
export declare const hyperbolicTimeOfFlight: (nu1: Radians, nu2: Radians, e: number, a: number, mu: number) => number;
|
|
64
|
+
//# sourceMappingURL=hyperbolic-time-of-flight.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hyperbolic-time-of-flight.d.ts","sourceRoot":"","sources":["../../../src/categories/orbits/hyperbolic-time-of-flight.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAIzD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AACH,eAAO,MAAM,sBAAsB,GACjC,KAAK,OAAO,EACZ,KAAK,OAAO,EACZ,GAAG,MAAM,EACT,GAAG,MAAM,EACT,IAAI,MAAM,KACT,MA0BF,CAAC"}
|