@interstellar-tools/equations 1.2.0 → 1.4.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/entry/ballistic-coefficient.d.ts +44 -0
- package/dist/categories/entry/ballistic-coefficient.d.ts.map +1 -0
- package/dist/categories/entry/ballistic-coefficient.js +54 -0
- package/dist/categories/entry/ballistic-coefficient.js.map +1 -0
- package/dist/categories/entry/ballistic-entry-speed.d.ts +52 -0
- package/dist/categories/entry/ballistic-entry-speed.d.ts.map +1 -0
- package/dist/categories/entry/ballistic-entry-speed.js +71 -0
- package/dist/categories/entry/ballistic-entry-speed.js.map +1 -0
- package/dist/categories/entry/ballistic-peak-deceleration-altitude.d.ts +47 -0
- package/dist/categories/entry/ballistic-peak-deceleration-altitude.d.ts.map +1 -0
- package/dist/categories/entry/ballistic-peak-deceleration-altitude.js +62 -0
- package/dist/categories/entry/ballistic-peak-deceleration-altitude.js.map +1 -0
- package/dist/categories/entry/ballistic-peak-deceleration.d.ts +63 -0
- package/dist/categories/entry/ballistic-peak-deceleration.d.ts.map +1 -0
- package/dist/categories/entry/ballistic-peak-deceleration.js +76 -0
- package/dist/categories/entry/ballistic-peak-deceleration.js.map +1 -0
- package/dist/categories/entry/stagnation-heat-flux.d.ts +46 -0
- package/dist/categories/entry/stagnation-heat-flux.d.ts.map +1 -0
- package/dist/categories/entry/stagnation-heat-flux.js +57 -0
- package/dist/categories/entry/stagnation-heat-flux.js.map +1 -0
- package/dist/categories/entry/terminal-velocity.d.ts +48 -0
- package/dist/categories/entry/terminal-velocity.d.ts.map +1 -0
- package/dist/categories/entry/terminal-velocity.js +60 -0
- package/dist/categories/entry/terminal-velocity.js.map +1 -0
- package/dist/categories/entry/validate.d.ts +7 -0
- package/dist/categories/entry/validate.d.ts.map +1 -0
- package/dist/categories/entry/validate.js +20 -0
- package/dist/categories/entry/validate.js.map +1 -0
- package/dist/categories/manoeuvres/cw-two-impulse-transfer.d.ts +58 -0
- package/dist/categories/manoeuvres/cw-two-impulse-transfer.d.ts.map +1 -0
- package/dist/categories/manoeuvres/cw-two-impulse-transfer.js +104 -0
- package/dist/categories/manoeuvres/cw-two-impulse-transfer.js.map +1 -0
- package/dist/categories/manoeuvres/phasing-wait-time.d.ts +55 -0
- package/dist/categories/manoeuvres/phasing-wait-time.d.ts.map +1 -0
- package/dist/categories/manoeuvres/phasing-wait-time.js +77 -0
- package/dist/categories/manoeuvres/phasing-wait-time.js.map +1 -0
- package/dist/categories/orbits/cw-propagate.d.ts +48 -0
- package/dist/categories/orbits/cw-propagate.d.ts.map +1 -0
- package/dist/categories/orbits/cw-propagate.js +68 -0
- package/dist/categories/orbits/cw-propagate.js.map +1 -0
- package/dist/categories/orbits/cw-state-transition.d.ts +65 -0
- package/dist/categories/orbits/cw-state-transition.d.ts.map +1 -0
- package/dist/categories/orbits/cw-state-transition.js +83 -0
- package/dist/categories/orbits/cw-state-transition.js.map +1 -0
- package/dist/categories/orbits/synodic-period.d.ts +59 -0
- package/dist/categories/orbits/synodic-period.d.ts.map +1 -0
- package/dist/categories/orbits/synodic-period.js +72 -0
- package/dist/categories/orbits/synodic-period.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compute the **terminal speed** of a falling body: where drag balances its weight.
|
|
3
|
+
*
|
|
4
|
+
* $$
|
|
5
|
+
* v_t = \sqrt{\frac{2\,m\,g}{\rho\, C_D\, A}}
|
|
6
|
+
* $$
|
|
7
|
+
*
|
|
8
|
+
* Where:
|
|
9
|
+
* - $ m $ is the mass (kg)
|
|
10
|
+
* - $ g $ is the local gravitational acceleration (m/s²)
|
|
11
|
+
* - $ \rho $ is the air density (kg/m³)
|
|
12
|
+
* - $ C_D $ is the drag coefficient (dimensionless)
|
|
13
|
+
* - $ A $ is the reference area (m²)
|
|
14
|
+
*
|
|
15
|
+
* **Units**
|
|
16
|
+
* - Inputs: `m` in **kg**, `g` in **m/s²**, `rho` in **kg/m³**, `Cd` dimensionless, `A` in **m²**.
|
|
17
|
+
* - Output: $ v_t $ in **m/s**.
|
|
18
|
+
*
|
|
19
|
+
* ::: info Notes
|
|
20
|
+
*
|
|
21
|
+
* - For a parachute, $ C_D $ and $ A $ are the canopy's. For a cluster, $ A $ is the total canopy area, and real clusters lose a little drag to interference between the canopies.
|
|
22
|
+
* - The density rises as the body descends, so the terminal speed falls: evaluate it at the altitude you care about, e.g. sea level for splashdown.
|
|
23
|
+
* - At $ v_t $, `atmosphericDragAcceleration` equals $ g $.
|
|
24
|
+
*
|
|
25
|
+
* :::
|
|
26
|
+
*
|
|
27
|
+
* @param m - Mass $ m $ in **kg** (finite, > 0).
|
|
28
|
+
* @param g - Gravitational acceleration $ g $ in **m/s²** (finite, > 0).
|
|
29
|
+
* @param rho - Air density $ \rho $ in **kg/m³** (finite, > 0).
|
|
30
|
+
* @param Cd - Drag coefficient $ C_D $ (finite, > 0).
|
|
31
|
+
* @param A - Reference area $ A $ in **m²** (finite, > 0).
|
|
32
|
+
* @returns Terminal speed $ v_t $ in **m/s**.
|
|
33
|
+
* @throws {TypeError} If any input is not a finite number.
|
|
34
|
+
* @throws {RangeError} If any input is `<= 0`.
|
|
35
|
+
* @group Entry
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```ts
|
|
39
|
+
* // A 4.9 t capsule under three 25.5 m canopies (Cd ≈ 0.8) at sea level
|
|
40
|
+
* const v = terminalVelocity(4932, 9.80665, 1.225, 0.8, 3 * Math.PI * 12.75 ** 2);
|
|
41
|
+
* // v ≈ 8.0 m/s
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* @see {@link ballisticCoefficient}
|
|
45
|
+
* @see https://en.wikipedia.org/wiki/Terminal_velocity Terminal velocity
|
|
46
|
+
*/
|
|
47
|
+
export declare const terminalVelocity: (m: number, g: number, rho: number, Cd: number, A: number) => number;
|
|
48
|
+
//# sourceMappingURL=terminal-velocity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"terminal-velocity.d.ts","sourceRoot":"","sources":["../../../src/categories/entry/terminal-velocity.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,eAAO,MAAM,gBAAgB,GAC3B,GAAG,MAAM,EACT,GAAG,MAAM,EACT,KAAK,MAAM,EACX,IAAI,MAAM,EACV,GAAG,MAAM,KACR,MAaF,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { assertFinite, assertPositive } from './validate.js';
|
|
2
|
+
/**
|
|
3
|
+
* Compute the **terminal speed** of a falling body: where drag balances its weight.
|
|
4
|
+
*
|
|
5
|
+
* $$
|
|
6
|
+
* v_t = \sqrt{\frac{2\,m\,g}{\rho\, C_D\, A}}
|
|
7
|
+
* $$
|
|
8
|
+
*
|
|
9
|
+
* Where:
|
|
10
|
+
* - $ m $ is the mass (kg)
|
|
11
|
+
* - $ g $ is the local gravitational acceleration (m/s²)
|
|
12
|
+
* - $ \rho $ is the air density (kg/m³)
|
|
13
|
+
* - $ C_D $ is the drag coefficient (dimensionless)
|
|
14
|
+
* - $ A $ is the reference area (m²)
|
|
15
|
+
*
|
|
16
|
+
* **Units**
|
|
17
|
+
* - Inputs: `m` in **kg**, `g` in **m/s²**, `rho` in **kg/m³**, `Cd` dimensionless, `A` in **m²**.
|
|
18
|
+
* - Output: $ v_t $ in **m/s**.
|
|
19
|
+
*
|
|
20
|
+
* ::: info Notes
|
|
21
|
+
*
|
|
22
|
+
* - For a parachute, $ C_D $ and $ A $ are the canopy's. For a cluster, $ A $ is the total canopy area, and real clusters lose a little drag to interference between the canopies.
|
|
23
|
+
* - The density rises as the body descends, so the terminal speed falls: evaluate it at the altitude you care about, e.g. sea level for splashdown.
|
|
24
|
+
* - At $ v_t $, `atmosphericDragAcceleration` equals $ g $.
|
|
25
|
+
*
|
|
26
|
+
* :::
|
|
27
|
+
*
|
|
28
|
+
* @param m - Mass $ m $ in **kg** (finite, > 0).
|
|
29
|
+
* @param g - Gravitational acceleration $ g $ in **m/s²** (finite, > 0).
|
|
30
|
+
* @param rho - Air density $ \rho $ in **kg/m³** (finite, > 0).
|
|
31
|
+
* @param Cd - Drag coefficient $ C_D $ (finite, > 0).
|
|
32
|
+
* @param A - Reference area $ A $ in **m²** (finite, > 0).
|
|
33
|
+
* @returns Terminal speed $ v_t $ in **m/s**.
|
|
34
|
+
* @throws {TypeError} If any input is not a finite number.
|
|
35
|
+
* @throws {RangeError} If any input is `<= 0`.
|
|
36
|
+
* @group Entry
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```ts
|
|
40
|
+
* // A 4.9 t capsule under three 25.5 m canopies (Cd ≈ 0.8) at sea level
|
|
41
|
+
* const v = terminalVelocity(4932, 9.80665, 1.225, 0.8, 3 * Math.PI * 12.75 ** 2);
|
|
42
|
+
* // v ≈ 8.0 m/s
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* @see {@link ballisticCoefficient}
|
|
46
|
+
* @see https://en.wikipedia.org/wiki/Terminal_velocity Terminal velocity
|
|
47
|
+
*/
|
|
48
|
+
export const terminalVelocity = (m, g, rho, Cd, A) => {
|
|
49
|
+
const inputs = [
|
|
50
|
+
['m', m],
|
|
51
|
+
['g', g],
|
|
52
|
+
['rho', rho],
|
|
53
|
+
['Cd', Cd],
|
|
54
|
+
['A', A]
|
|
55
|
+
];
|
|
56
|
+
assertFinite(inputs);
|
|
57
|
+
assertPositive(inputs);
|
|
58
|
+
return Math.sqrt((2 * m * g) / (rho * Cd * A));
|
|
59
|
+
};
|
|
60
|
+
//# sourceMappingURL=terminal-velocity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"terminal-velocity.js","sourceRoot":"","sources":["../../../src/categories/entry/terminal-velocity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,CAAS,EACT,CAAS,EACT,GAAW,EACX,EAAU,EACV,CAAS,EACD,EAAE;IACV,MAAM,MAAM,GAAG;QACb,CAAC,GAAG,EAAE,CAAC,CAAC;QACR,CAAC,GAAG,EAAE,CAAC,CAAC;QACR,CAAC,KAAK,EAAE,GAAG,CAAC;QACZ,CAAC,IAAI,EAAE,EAAE,CAAC;QACV,CAAC,GAAG,EAAE,CAAC,CAAC;KACA,CAAC;IAEX,YAAY,CAAC,MAAM,CAAC,CAAC;IACrB,cAAc,CAAC,MAAM,CAAC,CAAC;IAEvB,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;AACjD,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Throw a TypeError for each non-finite input, named as in the caller's signature. */
|
|
2
|
+
export declare const assertFinite: (inputs: readonly (readonly [string, number])[]) => void;
|
|
3
|
+
/** Throw a RangeError for each input that isn't strictly positive. */
|
|
4
|
+
export declare const assertPositive: (inputs: readonly (readonly [string, number])[]) => void;
|
|
5
|
+
/** Throw a RangeError unless the flight-path angle is a descent or climb, not level or past vertical. */
|
|
6
|
+
export declare const assertFlightPathAngle: (gamma: number) => void;
|
|
7
|
+
//# sourceMappingURL=validate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../../src/categories/entry/validate.ts"],"names":[],"mappings":"AAAA,uFAAuF;AACvF,eAAO,MAAM,YAAY,GACvB,QAAQ,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,SAM/C,CAAC;AAEF,sEAAsE;AACtE,eAAO,MAAM,cAAc,GACzB,QAAQ,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,SAK/C,CAAC;AAEF,yGAAyG;AACzG,eAAO,MAAM,qBAAqB,GAAI,OAAO,MAAM,SAKlD,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** Throw a TypeError for each non-finite input, named as in the caller's signature. */
|
|
2
|
+
export const assertFinite = (inputs) => {
|
|
3
|
+
for (const [name, x] of inputs) {
|
|
4
|
+
if (!Number.isFinite(x))
|
|
5
|
+
throw new TypeError(`${name} must be a finite number. Received: ${x}`);
|
|
6
|
+
}
|
|
7
|
+
};
|
|
8
|
+
/** Throw a RangeError for each input that isn't strictly positive. */
|
|
9
|
+
export const assertPositive = (inputs) => {
|
|
10
|
+
for (const [name, x] of inputs) {
|
|
11
|
+
if (x <= 0)
|
|
12
|
+
throw new RangeError(`${name} must be > 0. Received: ${x}`);
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
/** Throw a RangeError unless the flight-path angle is a descent or climb, not level or past vertical. */
|
|
16
|
+
export const assertFlightPathAngle = (gamma) => {
|
|
17
|
+
if (gamma === 0 || Math.abs(gamma) > Math.PI / 2)
|
|
18
|
+
throw new RangeError(`gamma must be non-zero and within [-π/2, π/2]. Received: ${gamma}`);
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=validate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../../src/categories/entry/validate.ts"],"names":[],"mappings":"AAAA,uFAAuF;AACvF,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,MAA8C,EAC9C,EAAE;IACF,KAAK,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,MAAM,EAAE,CAAC;QAC/B,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;YACrB,MAAM,IAAI,SAAS,CAAC,GAAG,IAAI,uCAAuC,CAAC,EAAE,CAAC,CAAC;IAC3E,CAAC;AACH,CAAC,CAAC;AAEF,sEAAsE;AACtE,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,MAA8C,EAC9C,EAAE;IACF,KAAK,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,MAAM,EAAE,CAAC;QAC/B,IAAI,CAAC,IAAI,CAAC;YAAE,MAAM,IAAI,UAAU,CAAC,GAAG,IAAI,2BAA2B,CAAC,EAAE,CAAC,CAAC;IAC1E,CAAC;AACH,CAAC,CAAC;AAEF,yGAAyG;AACzG,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,KAAa,EAAE,EAAE;IACrD,IAAI,KAAK,KAAK,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,EAAE,GAAG,CAAC;QAC9C,MAAM,IAAI,UAAU,CAClB,4DAA4D,KAAK,EAAE,CACpE,CAAC;AACN,CAAC,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { CwState, Vector3DTupleType } from '@interstellar-tools/types';
|
|
2
|
+
export interface CwTwoImpulseTransferInterface {
|
|
3
|
+
/** First burn, at the start, in m/s (LVLH). */
|
|
4
|
+
dv1: Vector3DTupleType;
|
|
5
|
+
/** Second burn, on arrival, in m/s (LVLH). */
|
|
6
|
+
dv2: Vector3DTupleType;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Compute the **two burns of a Clohessy–Wiltshire rendezvous**: from a relative state to a target state in a given time.
|
|
10
|
+
*
|
|
11
|
+
* $$
|
|
12
|
+
* \mathbf v_0^+ = \Phi_{rv}^{-1}\left(\mathbf r_f - \Phi_{rr}\,\mathbf r_0\right), \quad
|
|
13
|
+
* \Delta\mathbf v_1 = \mathbf v_0^+ - \mathbf v_0, \quad
|
|
14
|
+
* \Delta\mathbf v_2 = \mathbf v_f - \left(\Phi_{vr}\,\mathbf r_0 + \Phi_{vv}\,\mathbf v_0^+\right)
|
|
15
|
+
* $$
|
|
16
|
+
*
|
|
17
|
+
* with the blocks of $ \Phi(t) $ from {@link cwStateTransition}.
|
|
18
|
+
*
|
|
19
|
+
* **Units**
|
|
20
|
+
* - Inputs: states in **m** and **m/s**, `n` in **rad/s**, `t` in **s**.
|
|
21
|
+
* - Output: both burns in **m/s**, as vectors in the LVLH frame.
|
|
22
|
+
*
|
|
23
|
+
* ::: info Notes
|
|
24
|
+
*
|
|
25
|
+
* - The first burn puts the deputy on a path that reaches the target position after `t`; the second matches the target velocity there. For a rendezvous with the chief, the target state is all zeros.
|
|
26
|
+
* - Some transfer times can't be targeted: in the orbital plane, every whole number of orbits ($ nt = 2\pi k $), and out of plane, every half orbit, where the cross-track motion returns to $ \pm z_0 $ whatever the burn. At a half orbit the cross-track burn is zero if the target is already on that path, and otherwise the function throws.
|
|
27
|
+
* - Valid near a circular reference orbit, for small separations.
|
|
28
|
+
*
|
|
29
|
+
* :::
|
|
30
|
+
*
|
|
31
|
+
* @param state0 - Deputy's relative state before the first burn `[x, y, z, xDot, yDot, zDot]` (finite).
|
|
32
|
+
* @param target - State to arrive at `[x, y, z, xDot, yDot, zDot]` (finite); all zeros to rendezvous with the chief.
|
|
33
|
+
* @param n - Mean motion of the circular reference orbit in **rad/s** (finite, > 0).
|
|
34
|
+
* @param t - Transfer time in **s** (finite, > 0).
|
|
35
|
+
* @returns The two burns `dv1` and `dv2` in **m/s**.
|
|
36
|
+
* @throws {TypeError} If any input is not a finite number.
|
|
37
|
+
* @throws {RangeError} If `n <= 0`, `t <= 0`, or the transfer time can't be targeted.
|
|
38
|
+
* @group Manoeuvres
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```ts
|
|
42
|
+
* import type { CwState } from '@interstellar-tools/types';
|
|
43
|
+
*
|
|
44
|
+
* // 1 km behind the chief, at rest: rendezvous in a quarter of an orbit
|
|
45
|
+
* const n = 0.00113;
|
|
46
|
+
* const { dv1, dv2 } = cwTwoImpulseTransfer(
|
|
47
|
+
* [0, -1000, 0, 0, 0, 0],
|
|
48
|
+
* [0, 0, 0, 0, 0, 0],
|
|
49
|
+
* n,
|
|
50
|
+
* Math.PI / 2 / n
|
|
51
|
+
* );
|
|
52
|
+
* ```
|
|
53
|
+
*
|
|
54
|
+
* @see {@link cwPropagate}
|
|
55
|
+
* @see https://en.wikipedia.org/wiki/Clohessy%E2%80%93Wiltshire_equations Clohessy–Wiltshire equations
|
|
56
|
+
*/
|
|
57
|
+
export declare const cwTwoImpulseTransfer: (state0: CwState, target: CwState, n: number, t: number) => CwTwoImpulseTransferInterface;
|
|
58
|
+
//# sourceMappingURL=cw-two-impulse-transfer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cw-two-impulse-transfer.d.ts","sourceRoot":"","sources":["../../../src/categories/manoeuvres/cw-two-impulse-transfer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAK5E,MAAM,WAAW,6BAA6B;IAC5C,+CAA+C;IAC/C,GAAG,EAAE,iBAAiB,CAAC;IACvB,8CAA8C;IAC9C,GAAG,EAAE,iBAAiB,CAAC;CACxB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,eAAO,MAAM,oBAAoB,GAC/B,QAAQ,OAAO,EACf,QAAQ,OAAO,EACf,GAAG,MAAM,EACT,GAAG,MAAM,KACR,6BA+DF,CAAC"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { applyMatrix3 } from '../helpers/apply-matrix-3.js';
|
|
2
|
+
import { cwStateTransition } from '../orbits/cw-state-transition.js';
|
|
3
|
+
/**
|
|
4
|
+
* Compute the **two burns of a Clohessy–Wiltshire rendezvous**: from a relative state to a target state in a given time.
|
|
5
|
+
*
|
|
6
|
+
* $$
|
|
7
|
+
* \mathbf v_0^+ = \Phi_{rv}^{-1}\left(\mathbf r_f - \Phi_{rr}\,\mathbf r_0\right), \quad
|
|
8
|
+
* \Delta\mathbf v_1 = \mathbf v_0^+ - \mathbf v_0, \quad
|
|
9
|
+
* \Delta\mathbf v_2 = \mathbf v_f - \left(\Phi_{vr}\,\mathbf r_0 + \Phi_{vv}\,\mathbf v_0^+\right)
|
|
10
|
+
* $$
|
|
11
|
+
*
|
|
12
|
+
* with the blocks of $ \Phi(t) $ from {@link cwStateTransition}.
|
|
13
|
+
*
|
|
14
|
+
* **Units**
|
|
15
|
+
* - Inputs: states in **m** and **m/s**, `n` in **rad/s**, `t` in **s**.
|
|
16
|
+
* - Output: both burns in **m/s**, as vectors in the LVLH frame.
|
|
17
|
+
*
|
|
18
|
+
* ::: info Notes
|
|
19
|
+
*
|
|
20
|
+
* - The first burn puts the deputy on a path that reaches the target position after `t`; the second matches the target velocity there. For a rendezvous with the chief, the target state is all zeros.
|
|
21
|
+
* - Some transfer times can't be targeted: in the orbital plane, every whole number of orbits ($ nt = 2\pi k $), and out of plane, every half orbit, where the cross-track motion returns to $ \pm z_0 $ whatever the burn. At a half orbit the cross-track burn is zero if the target is already on that path, and otherwise the function throws.
|
|
22
|
+
* - Valid near a circular reference orbit, for small separations.
|
|
23
|
+
*
|
|
24
|
+
* :::
|
|
25
|
+
*
|
|
26
|
+
* @param state0 - Deputy's relative state before the first burn `[x, y, z, xDot, yDot, zDot]` (finite).
|
|
27
|
+
* @param target - State to arrive at `[x, y, z, xDot, yDot, zDot]` (finite); all zeros to rendezvous with the chief.
|
|
28
|
+
* @param n - Mean motion of the circular reference orbit in **rad/s** (finite, > 0).
|
|
29
|
+
* @param t - Transfer time in **s** (finite, > 0).
|
|
30
|
+
* @returns The two burns `dv1` and `dv2` in **m/s**.
|
|
31
|
+
* @throws {TypeError} If any input is not a finite number.
|
|
32
|
+
* @throws {RangeError} If `n <= 0`, `t <= 0`, or the transfer time can't be targeted.
|
|
33
|
+
* @group Manoeuvres
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```ts
|
|
37
|
+
* import type { CwState } from '@interstellar-tools/types';
|
|
38
|
+
*
|
|
39
|
+
* // 1 km behind the chief, at rest: rendezvous in a quarter of an orbit
|
|
40
|
+
* const n = 0.00113;
|
|
41
|
+
* const { dv1, dv2 } = cwTwoImpulseTransfer(
|
|
42
|
+
* [0, -1000, 0, 0, 0, 0],
|
|
43
|
+
* [0, 0, 0, 0, 0, 0],
|
|
44
|
+
* n,
|
|
45
|
+
* Math.PI / 2 / n
|
|
46
|
+
* );
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* @see {@link cwPropagate}
|
|
50
|
+
* @see https://en.wikipedia.org/wiki/Clohessy%E2%80%93Wiltshire_equations Clohessy–Wiltshire equations
|
|
51
|
+
*/
|
|
52
|
+
export const cwTwoImpulseTransfer = (state0, target, n, t) => {
|
|
53
|
+
for (const [name, state] of [
|
|
54
|
+
['state0', state0],
|
|
55
|
+
['target', target]
|
|
56
|
+
]) {
|
|
57
|
+
for (const x of state)
|
|
58
|
+
if (!Number.isFinite(x))
|
|
59
|
+
throw new TypeError(`${name} must have finite components. Received: ${x}`);
|
|
60
|
+
}
|
|
61
|
+
if (!Number.isFinite(t))
|
|
62
|
+
throw new TypeError(`t must be a finite number. Received: ${t}`);
|
|
63
|
+
if (t <= 0)
|
|
64
|
+
throw new RangeError(`t must be > 0. Received: ${t}`);
|
|
65
|
+
const { rr, rv, vr, vv } = cwStateTransition(n, t);
|
|
66
|
+
const r0 = [state0[0], state0[1], state0[2]];
|
|
67
|
+
const v0 = [state0[3], state0[4], state0[5]];
|
|
68
|
+
const fromR0 = applyMatrix3(rr, r0);
|
|
69
|
+
// Position the first burn's velocity has to cover
|
|
70
|
+
const dx = target[0] - fromR0[0];
|
|
71
|
+
const dy = target[1] - fromR0[1];
|
|
72
|
+
const dz = target[2] - fromR0[2];
|
|
73
|
+
// In-plane: invert the 2×2 block of Φrv
|
|
74
|
+
const [[a, b], [c, d]] = rv;
|
|
75
|
+
const det = a * d - b * c;
|
|
76
|
+
if (Math.abs(det) * n * n <= 1e-10)
|
|
77
|
+
throw new RangeError(`The transfer time is a whole number of orbits (nt = 2πk), which can't be targeted in the orbital plane. Received: nt=${n * t}`);
|
|
78
|
+
const xDot = (d * dx - b * dy) / det;
|
|
79
|
+
const yDot = (-c * dx + a * dy) / det;
|
|
80
|
+
// Out of plane: z(t) = c z0 + (s / n) zDot0
|
|
81
|
+
const sOverN = rv[2][2];
|
|
82
|
+
let zDot;
|
|
83
|
+
if (Math.abs(sOverN) * n > 1e-10) {
|
|
84
|
+
zDot = dz / sOverN;
|
|
85
|
+
}
|
|
86
|
+
else if (Math.abs(dz) <= 1e-9 * Math.max(1, Math.abs(target[2]))) {
|
|
87
|
+
zDot = v0[2];
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
throw new RangeError(`At a half orbit (nt = πk) the cross-track position can't be changed. Received: nt=${n * t}`);
|
|
91
|
+
}
|
|
92
|
+
const v0Plus = [xDot, yDot, zDot];
|
|
93
|
+
const fromR = applyMatrix3(vr, r0);
|
|
94
|
+
const fromV = applyMatrix3(vv, v0Plus);
|
|
95
|
+
return {
|
|
96
|
+
dv1: [xDot - v0[0], yDot - v0[1], zDot - v0[2]],
|
|
97
|
+
dv2: [
|
|
98
|
+
target[3] - (fromR[0] + fromV[0]),
|
|
99
|
+
target[4] - (fromR[1] + fromV[1]),
|
|
100
|
+
target[5] - (fromR[2] + fromV[2])
|
|
101
|
+
]
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
//# sourceMappingURL=cw-two-impulse-transfer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cw-two-impulse-transfer.js","sourceRoot":"","sources":["../../../src/categories/manoeuvres/cw-two-impulse-transfer.ts"],"names":[],"mappings":"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,CAAC,CAAC,EAAE,CAAC;QACnE,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;IACf,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,UAAU,CAClB,qFAAqF,CAAC,GAAG,CAAC,EAAE,CAC7F,CAAC;IACJ,CAAC;IAED,MAAM,MAAM,GAAsB,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IACrD,MAAM,KAAK,GAAG,YAAY,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;IACnC,MAAM,KAAK,GAAG,YAAY,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;IAEvC,OAAO;QACL,GAAG,EAAE,CAAC,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;QAC/C,GAAG,EAAE;YACH,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;YACjC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;YACjC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;SAClC;KACF,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { Radians } from '@interstellar-tools/types';
|
|
2
|
+
/**
|
|
3
|
+
* Compute how long to **wait for a phase angle**: when a target, leading a chaser on another circular orbit, will be at the angle a manoeuvre needs.
|
|
4
|
+
*
|
|
5
|
+
* The phase angle $ \theta $ is how far the target is ahead of the chaser, and it changes at the difference in mean motions:
|
|
6
|
+
*
|
|
7
|
+
* $$
|
|
8
|
+
* \dot\theta = n_\text{target} - n_\text{chaser}, \qquad
|
|
9
|
+
* t_\text{wait} = \frac{\theta_\text{required} - \theta_\text{now}}{n_\text{target} - n_\text{chaser}} \pmod{T_\text{syn}}
|
|
10
|
+
* $$
|
|
11
|
+
*
|
|
12
|
+
* returning the first time that's not negative.
|
|
13
|
+
*
|
|
14
|
+
* **Units**
|
|
15
|
+
* - Inputs: angles in **radians**, mean motions in **rad/s**.
|
|
16
|
+
* - Output: $ t_\text{wait} $ in **s**, in $ [0, T_\text{syn}) $.
|
|
17
|
+
*
|
|
18
|
+
* ::: info Notes
|
|
19
|
+
*
|
|
20
|
+
* - A chaser in a lower, faster orbit closes the gap: the phase angle shrinks.
|
|
21
|
+
* - For a Hohmann transfer to a target on a circular orbit, the required angle is $ \theta = \pi - n_\text{target}\, t_\text{transfer} $.
|
|
22
|
+
* - If the required angle is just behind, the wait is almost a whole synodic period; see {@link synodicPeriod}.
|
|
23
|
+
*
|
|
24
|
+
* :::
|
|
25
|
+
*
|
|
26
|
+
* @param thetaNow - Current phase angle, target ahead of chaser, in **radians** (finite).
|
|
27
|
+
* @param thetaRequired - Phase angle wanted, in **radians** (finite).
|
|
28
|
+
* @param nChaser - Chaser's mean motion in **rad/s** (finite, > 0).
|
|
29
|
+
* @param nTarget - Target's mean motion in **rad/s** (finite, > 0, not equal to `nChaser`).
|
|
30
|
+
* @returns Waiting time in **s**, in [0, synodic period).
|
|
31
|
+
* @throws {TypeError} If any input is not a finite number.
|
|
32
|
+
* @throws {RangeError} If a mean motion is `<= 0`, or both are equal (the phase never changes).
|
|
33
|
+
* @group Manoeuvres
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```ts
|
|
37
|
+
* import type { Radians } from '@interstellar-tools/types';
|
|
38
|
+
*
|
|
39
|
+
* // Chaser 1° per orbit faster, target 10° ahead, burn when it's 4° ahead
|
|
40
|
+
* const nTarget = 0.00113;
|
|
41
|
+
* const nChaser = nTarget * (1 + 1 / 360);
|
|
42
|
+
* const t = phasingWaitTime(
|
|
43
|
+
* ((10 * Math.PI) / 180) as Radians,
|
|
44
|
+
* ((4 * Math.PI) / 180) as Radians,
|
|
45
|
+
* nChaser,
|
|
46
|
+
* nTarget
|
|
47
|
+
* );
|
|
48
|
+
* // t ≈ 6 orbits of the target
|
|
49
|
+
* ```
|
|
50
|
+
*
|
|
51
|
+
* @see {@link synodicPeriod}
|
|
52
|
+
* @see {@link hohmannTransferTime}
|
|
53
|
+
*/
|
|
54
|
+
export declare const phasingWaitTime: (thetaNow: Radians, thetaRequired: Radians, nChaser: number, nTarget: number) => number;
|
|
55
|
+
//# sourceMappingURL=phasing-wait-time.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"phasing-wait-time.d.ts","sourceRoot":"","sources":["../../../src/categories/manoeuvres/phasing-wait-time.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAEzD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,eAAO,MAAM,eAAe,GAC1B,UAAU,OAAO,EACjB,eAAe,OAAO,EACtB,SAAS,MAAM,EACf,SAAS,MAAM,KACd,MA4BF,CAAC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compute how long to **wait for a phase angle**: when a target, leading a chaser on another circular orbit, will be at the angle a manoeuvre needs.
|
|
3
|
+
*
|
|
4
|
+
* The phase angle $ \theta $ is how far the target is ahead of the chaser, and it changes at the difference in mean motions:
|
|
5
|
+
*
|
|
6
|
+
* $$
|
|
7
|
+
* \dot\theta = n_\text{target} - n_\text{chaser}, \qquad
|
|
8
|
+
* t_\text{wait} = \frac{\theta_\text{required} - \theta_\text{now}}{n_\text{target} - n_\text{chaser}} \pmod{T_\text{syn}}
|
|
9
|
+
* $$
|
|
10
|
+
*
|
|
11
|
+
* returning the first time that's not negative.
|
|
12
|
+
*
|
|
13
|
+
* **Units**
|
|
14
|
+
* - Inputs: angles in **radians**, mean motions in **rad/s**.
|
|
15
|
+
* - Output: $ t_\text{wait} $ in **s**, in $ [0, T_\text{syn}) $.
|
|
16
|
+
*
|
|
17
|
+
* ::: info Notes
|
|
18
|
+
*
|
|
19
|
+
* - A chaser in a lower, faster orbit closes the gap: the phase angle shrinks.
|
|
20
|
+
* - For a Hohmann transfer to a target on a circular orbit, the required angle is $ \theta = \pi - n_\text{target}\, t_\text{transfer} $.
|
|
21
|
+
* - If the required angle is just behind, the wait is almost a whole synodic period; see {@link synodicPeriod}.
|
|
22
|
+
*
|
|
23
|
+
* :::
|
|
24
|
+
*
|
|
25
|
+
* @param thetaNow - Current phase angle, target ahead of chaser, in **radians** (finite).
|
|
26
|
+
* @param thetaRequired - Phase angle wanted, in **radians** (finite).
|
|
27
|
+
* @param nChaser - Chaser's mean motion in **rad/s** (finite, > 0).
|
|
28
|
+
* @param nTarget - Target's mean motion in **rad/s** (finite, > 0, not equal to `nChaser`).
|
|
29
|
+
* @returns Waiting time in **s**, in [0, synodic period).
|
|
30
|
+
* @throws {TypeError} If any input is not a finite number.
|
|
31
|
+
* @throws {RangeError} If a mean motion is `<= 0`, or both are equal (the phase never changes).
|
|
32
|
+
* @group Manoeuvres
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```ts
|
|
36
|
+
* import type { Radians } from '@interstellar-tools/types';
|
|
37
|
+
*
|
|
38
|
+
* // Chaser 1° per orbit faster, target 10° ahead, burn when it's 4° ahead
|
|
39
|
+
* const nTarget = 0.00113;
|
|
40
|
+
* const nChaser = nTarget * (1 + 1 / 360);
|
|
41
|
+
* const t = phasingWaitTime(
|
|
42
|
+
* ((10 * Math.PI) / 180) as Radians,
|
|
43
|
+
* ((4 * Math.PI) / 180) as Radians,
|
|
44
|
+
* nChaser,
|
|
45
|
+
* nTarget
|
|
46
|
+
* );
|
|
47
|
+
* // t ≈ 6 orbits of the target
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* @see {@link synodicPeriod}
|
|
51
|
+
* @see {@link hohmannTransferTime}
|
|
52
|
+
*/
|
|
53
|
+
export const phasingWaitTime = (thetaNow, thetaRequired, nChaser, nTarget) => {
|
|
54
|
+
for (const [name, x] of [
|
|
55
|
+
['thetaNow', thetaNow],
|
|
56
|
+
['thetaRequired', thetaRequired],
|
|
57
|
+
['nChaser', nChaser],
|
|
58
|
+
['nTarget', nTarget]
|
|
59
|
+
]) {
|
|
60
|
+
if (!Number.isFinite(x))
|
|
61
|
+
throw new TypeError(`${name} must be a finite number. Received: ${x}`);
|
|
62
|
+
}
|
|
63
|
+
for (const [name, x] of [
|
|
64
|
+
['nChaser', nChaser],
|
|
65
|
+
['nTarget', nTarget]
|
|
66
|
+
]) {
|
|
67
|
+
if (x <= 0)
|
|
68
|
+
throw new RangeError(`${name} must be > 0. Received: ${x}`);
|
|
69
|
+
}
|
|
70
|
+
if (nChaser === nTarget)
|
|
71
|
+
throw new RangeError(`nChaser and nTarget must differ: the phase angle never changes. Received: ${nChaser}`);
|
|
72
|
+
const rate = nTarget - nChaser;
|
|
73
|
+
const synodic = (2 * Math.PI) / Math.abs(rate);
|
|
74
|
+
const t = (thetaRequired - thetaNow) / rate;
|
|
75
|
+
return ((t % synodic) + synodic) % synodic;
|
|
76
|
+
};
|
|
77
|
+
//# sourceMappingURL=phasing-wait-time.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"phasing-wait-time.js","sourceRoot":"","sources":["../../../src/categories/manoeuvres/phasing-wait-time.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAC7B,QAAiB,EACjB,aAAsB,EACtB,OAAe,EACf,OAAe,EACP,EAAE;IACV,KAAK,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI;QACtB,CAAC,UAAU,EAAE,QAAQ,CAAC;QACtB,CAAC,eAAe,EAAE,aAAa,CAAC;QAChC,CAAC,SAAS,EAAE,OAAO,CAAC;QACpB,CAAC,SAAS,EAAE,OAAO,CAAC;KACZ,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,KAAK,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI;QACtB,CAAC,SAAS,EAAE,OAAO,CAAC;QACpB,CAAC,SAAS,EAAE,OAAO,CAAC;KACZ,EAAE,CAAC;QACX,IAAI,CAAC,IAAI,CAAC;YAAE,MAAM,IAAI,UAAU,CAAC,GAAG,IAAI,2BAA2B,CAAC,EAAE,CAAC,CAAC;IAC1E,CAAC;IAED,IAAI,OAAO,KAAK,OAAO;QACrB,MAAM,IAAI,UAAU,CAClB,6EAA6E,OAAO,EAAE,CACvF,CAAC;IAEJ,MAAM,IAAI,GAAG,OAAO,GAAG,OAAO,CAAC;IAC/B,MAAM,OAAO,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC/C,MAAM,CAAC,GAAG,CAAC,aAAa,GAAG,QAAQ,CAAC,GAAG,IAAI,CAAC;IAE5C,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,GAAG,OAAO,CAAC,GAAG,OAAO,CAAC;AAC7C,CAAC,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { CwState } from '@interstellar-tools/types';
|
|
2
|
+
/**
|
|
3
|
+
* **Propagate** a Clohessy–Wiltshire / Hill relative state in closed form.
|
|
4
|
+
*
|
|
5
|
+
* $$
|
|
6
|
+
* \begin{pmatrix}\mathbf r \\ \mathbf v\end{pmatrix}(t) =
|
|
7
|
+
* \begin{bmatrix}\Phi_{rr} & \Phi_{rv} \\ \Phi_{vr} & \Phi_{vv}\end{bmatrix}
|
|
8
|
+
* \begin{pmatrix}\mathbf r_0 \\ \mathbf v_0\end{pmatrix}
|
|
9
|
+
* $$
|
|
10
|
+
*
|
|
11
|
+
* with $ \Phi(t) $ from {@link cwStateTransition}.
|
|
12
|
+
*
|
|
13
|
+
* **Units**
|
|
14
|
+
* - Inputs: `state` positions in **m** and velocities in **m/s**, `n` in **rad/s**, `t` in **s**.
|
|
15
|
+
* - Output: the state at `t`, in the same units.
|
|
16
|
+
*
|
|
17
|
+
* ::: info Notes
|
|
18
|
+
*
|
|
19
|
+
* - The exact solution of the equations {@link cwHillDerivatives} gives to a numerical integrator: no step size, no accumulated error.
|
|
20
|
+
* - Same LVLH frame and `CwState` layout as `cwHillDerivatives`: `[x, y, z, xDot, yDot, zDot]`, with $ x $ radial, $ y $ along-track, $ z $ cross-track.
|
|
21
|
+
* - A state with $ \dot y_0 = -2n x_0 $ has no along-track drift: it traces a closed ellipse around the chief.
|
|
22
|
+
*
|
|
23
|
+
* :::
|
|
24
|
+
*
|
|
25
|
+
* @param state - Relative state `[x, y, z, xDot, yDot, zDot]` (finite).
|
|
26
|
+
* @param n - Mean motion of the circular reference orbit in **rad/s** (finite, > 0).
|
|
27
|
+
* @param t - Time to propagate in **s** (finite; negative goes backwards).
|
|
28
|
+
* @returns The relative state at `t`.
|
|
29
|
+
* @throws {TypeError} If any input is not a finite number.
|
|
30
|
+
* @throws {RangeError} If `n <= 0`.
|
|
31
|
+
* @group Orbits
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```ts
|
|
35
|
+
* import type { CwState } from '@interstellar-tools/types';
|
|
36
|
+
*
|
|
37
|
+
* // 100 m below the chief with no drift: back where it started after one orbit
|
|
38
|
+
* const n = 0.00113;
|
|
39
|
+
* const start: CwState = [-100, 0, 0, 0, 2 * n * 100, 0];
|
|
40
|
+
* const later = cwPropagate(start, n, (2 * Math.PI) / n);
|
|
41
|
+
* // later ≈ start
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* @see {@link cwStateTransition}
|
|
45
|
+
* @see {@link cwTwoImpulseTransfer}
|
|
46
|
+
*/
|
|
47
|
+
export declare const cwPropagate: (state: CwState, n: number, t: number) => CwState;
|
|
48
|
+
//# sourceMappingURL=cw-propagate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cw-propagate.d.ts","sourceRoot":"","sources":["../../../src/categories/orbits/cw-propagate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAqB,MAAM,2BAA2B,CAAC;AAM5E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,eAAO,MAAM,WAAW,GAAI,OAAO,OAAO,EAAE,GAAG,MAAM,EAAE,GAAG,MAAM,KAAG,OAqBlE,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { applyMatrix3 } from '../helpers/apply-matrix-3.js';
|
|
2
|
+
import { cwStateTransition } from './cw-state-transition.js';
|
|
3
|
+
/**
|
|
4
|
+
* **Propagate** a Clohessy–Wiltshire / Hill relative state in closed form.
|
|
5
|
+
*
|
|
6
|
+
* $$
|
|
7
|
+
* \begin{pmatrix}\mathbf r \\ \mathbf v\end{pmatrix}(t) =
|
|
8
|
+
* \begin{bmatrix}\Phi_{rr} & \Phi_{rv} \\ \Phi_{vr} & \Phi_{vv}\end{bmatrix}
|
|
9
|
+
* \begin{pmatrix}\mathbf r_0 \\ \mathbf v_0\end{pmatrix}
|
|
10
|
+
* $$
|
|
11
|
+
*
|
|
12
|
+
* with $ \Phi(t) $ from {@link cwStateTransition}.
|
|
13
|
+
*
|
|
14
|
+
* **Units**
|
|
15
|
+
* - Inputs: `state` positions in **m** and velocities in **m/s**, `n` in **rad/s**, `t` in **s**.
|
|
16
|
+
* - Output: the state at `t`, in the same units.
|
|
17
|
+
*
|
|
18
|
+
* ::: info Notes
|
|
19
|
+
*
|
|
20
|
+
* - The exact solution of the equations {@link cwHillDerivatives} gives to a numerical integrator: no step size, no accumulated error.
|
|
21
|
+
* - Same LVLH frame and `CwState` layout as `cwHillDerivatives`: `[x, y, z, xDot, yDot, zDot]`, with $ x $ radial, $ y $ along-track, $ z $ cross-track.
|
|
22
|
+
* - A state with $ \dot y_0 = -2n x_0 $ has no along-track drift: it traces a closed ellipse around the chief.
|
|
23
|
+
*
|
|
24
|
+
* :::
|
|
25
|
+
*
|
|
26
|
+
* @param state - Relative state `[x, y, z, xDot, yDot, zDot]` (finite).
|
|
27
|
+
* @param n - Mean motion of the circular reference orbit in **rad/s** (finite, > 0).
|
|
28
|
+
* @param t - Time to propagate in **s** (finite; negative goes backwards).
|
|
29
|
+
* @returns The relative state at `t`.
|
|
30
|
+
* @throws {TypeError} If any input is not a finite number.
|
|
31
|
+
* @throws {RangeError} If `n <= 0`.
|
|
32
|
+
* @group Orbits
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```ts
|
|
36
|
+
* import type { CwState } from '@interstellar-tools/types';
|
|
37
|
+
*
|
|
38
|
+
* // 100 m below the chief with no drift: back where it started after one orbit
|
|
39
|
+
* const n = 0.00113;
|
|
40
|
+
* const start: CwState = [-100, 0, 0, 0, 2 * n * 100, 0];
|
|
41
|
+
* const later = cwPropagate(start, n, (2 * Math.PI) / n);
|
|
42
|
+
* // later ≈ start
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* @see {@link cwStateTransition}
|
|
46
|
+
* @see {@link cwTwoImpulseTransfer}
|
|
47
|
+
*/
|
|
48
|
+
export const cwPropagate = (state, n, t) => {
|
|
49
|
+
for (const x of state)
|
|
50
|
+
if (!Number.isFinite(x))
|
|
51
|
+
throw new TypeError(`state must have finite components. Received: ${x}`);
|
|
52
|
+
const { rr, rv, vr, vv } = cwStateTransition(n, t);
|
|
53
|
+
const r0 = [state[0], state[1], state[2]];
|
|
54
|
+
const v0 = [state[3], state[4], state[5]];
|
|
55
|
+
const rA = applyMatrix3(rr, r0);
|
|
56
|
+
const rB = applyMatrix3(rv, v0);
|
|
57
|
+
const vA = applyMatrix3(vr, r0);
|
|
58
|
+
const vB = applyMatrix3(vv, v0);
|
|
59
|
+
return [
|
|
60
|
+
rA[0] + rB[0],
|
|
61
|
+
rA[1] + rB[1],
|
|
62
|
+
rA[2] + rB[2],
|
|
63
|
+
vA[0] + vB[0],
|
|
64
|
+
vA[1] + vB[1],
|
|
65
|
+
vA[2] + vB[2]
|
|
66
|
+
];
|
|
67
|
+
};
|
|
68
|
+
//# sourceMappingURL=cw-propagate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cw-propagate.js","sourceRoot":"","sources":["../../../src/categories/orbits/cw-propagate.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAE5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAAc,EAAE,CAAS,EAAE,CAAS,EAAW,EAAE;IAC3E,KAAK,MAAM,CAAC,IAAI,KAAK;QACnB,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;YACrB,MAAM,IAAI,SAAS,CAAC,gDAAgD,CAAC,EAAE,CAAC,CAAC;IAE7E,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,iBAAiB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACnD,MAAM,EAAE,GAAsB,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7D,MAAM,EAAE,GAAsB,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,KAA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