@interstellar-tools/equations 0.1.2 → 0.3.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/__tests__/circular-speed.spec.d.ts +2 -0
- package/dist/__tests__/circular-speed.spec.d.ts.map +1 -0
- package/dist/__tests__/circular-speed.spec.js +69 -0
- package/dist/__tests__/circular-speed.spec.js.map +1 -0
- package/dist/__tests__/compute-angle.int.spec.js +2 -2
- package/dist/__tests__/compute-angle.int.spec.js.map +1 -1
- package/dist/__tests__/eccentric-to-true-anomaly.spec.js +1 -1
- package/dist/__tests__/eccentric-to-true-anomaly.spec.js.map +1 -1
- package/dist/__tests__/escape-speed.spec.d.ts +2 -0
- package/dist/__tests__/escape-speed.spec.d.ts.map +1 -0
- package/dist/__tests__/escape-speed.spec.js +79 -0
- package/dist/__tests__/escape-speed.spec.js.map +1 -0
- package/dist/__tests__/gravitational-acceleration-on1-by2.int.spec.d.ts +2 -0
- package/dist/__tests__/gravitational-acceleration-on1-by2.int.spec.d.ts.map +1 -0
- package/dist/__tests__/gravitational-acceleration-on1-by2.int.spec.js +86 -0
- package/dist/__tests__/gravitational-acceleration-on1-by2.int.spec.js.map +1 -0
- package/dist/__tests__/gravitational-force-on1-by2.int.spec.d.ts +2 -0
- package/dist/__tests__/gravitational-force-on1-by2.int.spec.d.ts.map +1 -0
- package/dist/__tests__/gravitational-force-on1-by2.int.spec.js +106 -0
- package/dist/__tests__/gravitational-force-on1-by2.int.spec.js.map +1 -0
- package/dist/__tests__/gravitational-force.spec.d.ts +2 -0
- package/dist/__tests__/gravitational-force.spec.d.ts.map +1 -0
- package/dist/__tests__/gravitational-force.spec.js +105 -0
- package/dist/__tests__/gravitational-force.spec.js.map +1 -0
- package/dist/__tests__/gravitational-parameters.spec.d.ts +2 -0
- package/dist/__tests__/gravitational-parameters.spec.d.ts.map +1 -0
- package/dist/__tests__/gravitational-parameters.spec.js +75 -0
- package/dist/__tests__/gravitational-parameters.spec.js.map +1 -0
- package/dist/__tests__/helpers/index.d.ts +9 -0
- package/dist/__tests__/helpers/index.d.ts.map +1 -0
- package/dist/__tests__/helpers/index.js +31 -0
- package/dist/__tests__/helpers/index.js.map +1 -0
- package/dist/__tests__/kepler-period.spec.d.ts +2 -0
- package/dist/__tests__/kepler-period.spec.d.ts.map +1 -0
- package/dist/__tests__/kepler-period.spec.js +72 -0
- package/dist/__tests__/kepler-period.spec.js.map +1 -0
- package/dist/__tests__/mean-to-eccentric-anomaly.spec.d.ts +2 -0
- package/dist/__tests__/mean-to-eccentric-anomaly.spec.d.ts.map +1 -0
- package/dist/__tests__/{compute-mean-anomaly.int.spec.js → mean-to-eccentric-anomaly.spec.js} +49 -27
- package/dist/__tests__/mean-to-eccentric-anomaly.spec.js.map +1 -0
- package/dist/__tests__/peri-apoapsis-radii.spec.d.ts +2 -0
- package/dist/__tests__/peri-apoapsis-radii.spec.d.ts.map +1 -0
- package/dist/__tests__/peri-apoapsis-radii.spec.js +74 -0
- package/dist/__tests__/peri-apoapsis-radii.spec.js.map +1 -0
- package/dist/__tests__/solve-kepler-bisection.spec.js +1 -1
- package/dist/__tests__/solve-kepler-bisection.spec.js.map +1 -1
- package/dist/__tests__/solve-kepler-high-eccentricity.spec.js +1 -1
- package/dist/__tests__/solve-kepler-high-eccentricity.spec.js.map +1 -1
- package/dist/__tests__/solve-kepler-newton-raphson.spec.js +1 -1
- package/dist/__tests__/solve-kepler-newton-raphson.spec.js.map +1 -1
- package/dist/__tests__/solve-kepler.int.spec.js +1 -1
- package/dist/__tests__/solve-kepler.int.spec.js.map +1 -1
- package/dist/__tests__/specific-angular-momentum-from-elements.spec.d.ts +2 -0
- package/dist/__tests__/specific-angular-momentum-from-elements.spec.d.ts.map +1 -0
- package/dist/__tests__/specific-angular-momentum-from-elements.spec.js +86 -0
- package/dist/__tests__/specific-angular-momentum-from-elements.spec.js.map +1 -0
- package/dist/__tests__/specific-angular-momentum.spec.d.ts +2 -0
- package/dist/__tests__/specific-angular-momentum.spec.d.ts.map +1 -0
- package/dist/__tests__/specific-angular-momentum.spec.js +84 -0
- package/dist/__tests__/specific-angular-momentum.spec.js.map +1 -0
- package/dist/__tests__/specific-mechanical-energy.spec.d.ts +2 -0
- package/dist/__tests__/specific-mechanical-energy.spec.d.ts.map +1 -0
- package/dist/__tests__/specific-mechanical-energy.spec.js +81 -0
- package/dist/__tests__/specific-mechanical-energy.spec.js.map +1 -0
- package/dist/__tests__/true-to-mean-anomaly.spec.d.ts +2 -0
- package/dist/__tests__/true-to-mean-anomaly.spec.d.ts.map +1 -0
- package/dist/__tests__/{true-anomaly-to-mean-anomaly.int.spec.js → true-to-mean-anomaly.spec.js} +13 -13
- package/dist/__tests__/true-to-mean-anomaly.spec.js.map +1 -0
- package/dist/__tests__/vis-viva-speed.spec.d.ts +2 -0
- package/dist/__tests__/vis-viva-speed.spec.d.ts.map +1 -0
- package/dist/__tests__/vis-viva-speed.spec.js +80 -0
- package/dist/__tests__/vis-viva-speed.spec.js.map +1 -0
- package/dist/__tests__/wrap-angle.spec.js +1 -1
- package/dist/__tests__/wrap-angle.spec.js.map +1 -1
- package/dist/{compute-angle.d.ts → categories/angle/compute-angle.d.ts} +1 -1
- package/dist/categories/angle/compute-angle.d.ts.map +1 -0
- package/dist/{compute-angle.js → categories/angle/compute-angle.js} +5 -5
- package/dist/categories/angle/compute-angle.js.map +1 -0
- package/dist/{wrap-angle.d.ts → categories/angle/wrap-angle.d.ts} +1 -1
- package/dist/categories/angle/wrap-angle.d.ts.map +1 -0
- package/dist/{wrap-angle.js → categories/angle/wrap-angle.js} +1 -1
- package/dist/categories/angle/wrap-angle.js.map +1 -0
- package/dist/{eccentric-to-true-anomaly.d.ts → categories/anomalies/eccentric-to-true-anomaly.d.ts} +2 -2
- package/dist/categories/anomalies/eccentric-to-true-anomaly.d.ts.map +1 -0
- package/dist/{eccentric-to-true-anomaly.js → categories/anomalies/eccentric-to-true-anomaly.js} +2 -2
- package/dist/categories/anomalies/eccentric-to-true-anomaly.js.map +1 -0
- package/dist/{compute-mean-anomaly.d.ts → categories/anomalies/mean-to-eccentric-anomaly.d.ts} +6 -6
- package/dist/categories/anomalies/mean-to-eccentric-anomaly.d.ts.map +1 -0
- package/dist/{compute-mean-anomaly.js → categories/anomalies/mean-to-eccentric-anomaly.js} +12 -21
- package/dist/categories/anomalies/mean-to-eccentric-anomaly.js.map +1 -0
- package/dist/{true-anomaly-to-mean-anomaly.d.ts → categories/anomalies/true-to-mean-anomaly.d.ts} +6 -6
- package/dist/categories/anomalies/true-to-mean-anomaly.d.ts.map +1 -0
- package/dist/{true-anomaly-to-mean-anomaly.js → categories/anomalies/true-to-mean-anomaly.js} +7 -7
- package/dist/categories/anomalies/true-to-mean-anomaly.js.map +1 -0
- package/dist/categories/anomalies/utils/are-equal.d.ts +10 -0
- package/dist/categories/anomalies/utils/are-equal.d.ts.map +1 -0
- package/dist/categories/anomalies/utils/are-equal.js +13 -0
- package/dist/categories/anomalies/utils/are-equal.js.map +1 -0
- package/dist/categories/gravity/acceleration-on1-by2.d.ts +66 -0
- package/dist/categories/gravity/acceleration-on1-by2.d.ts.map +1 -0
- package/dist/categories/gravity/acceleration-on1-by2.js +75 -0
- package/dist/categories/gravity/acceleration-on1-by2.js.map +1 -0
- package/dist/categories/gravity/force-on1-by2.d.ts +87 -0
- package/dist/categories/gravity/force-on1-by2.d.ts.map +1 -0
- package/dist/categories/gravity/force-on1-by2.js +96 -0
- package/dist/categories/gravity/force-on1-by2.js.map +1 -0
- package/dist/categories/gravity/gravitational-force.d.ts +94 -0
- package/dist/categories/gravity/gravitational-force.d.ts.map +1 -0
- package/dist/categories/gravity/gravitational-force.js +119 -0
- package/dist/categories/gravity/gravitational-force.js.map +1 -0
- package/dist/categories/gravity/gravitational-parameter.d.ts +49 -0
- package/dist/categories/gravity/gravitational-parameter.d.ts.map +1 -0
- package/dist/categories/gravity/gravitational-parameter.js +61 -0
- package/dist/categories/gravity/gravitational-parameter.js.map +1 -0
- package/dist/{solve-kepler-bisection.d.ts → categories/kepler/solve-kepler-bisection.d.ts} +1 -1
- package/dist/categories/kepler/solve-kepler-bisection.d.ts.map +1 -0
- package/dist/{solve-kepler-bisection.js → categories/kepler/solve-kepler-bisection.js} +1 -1
- package/dist/categories/kepler/solve-kepler-bisection.js.map +1 -0
- package/dist/{solve-kepler-high-eccentricity.d.ts → categories/kepler/solve-kepler-high-eccentricity.d.ts} +2 -8
- package/dist/categories/kepler/solve-kepler-high-eccentricity.d.ts.map +1 -0
- package/dist/{solve-kepler-high-eccentricity.js → categories/kepler/solve-kepler-high-eccentricity.js} +5 -9
- package/dist/categories/kepler/solve-kepler-high-eccentricity.js.map +1 -0
- package/dist/{solve-kepler-newton-raphson.d.ts → categories/kepler/solve-kepler-newton-raphson.d.ts} +1 -1
- package/dist/categories/kepler/solve-kepler-newton-raphson.d.ts.map +1 -0
- package/dist/{solve-kepler-newton-raphson.js → categories/kepler/solve-kepler-newton-raphson.js} +1 -1
- package/dist/categories/kepler/solve-kepler-newton-raphson.js.map +1 -0
- package/dist/{solve-kepler.d.ts → categories/kepler/solve-kepler.d.ts} +1 -1
- package/dist/categories/kepler/solve-kepler.d.ts.map +1 -0
- package/dist/{solve-kepler.js → categories/kepler/solve-kepler.js} +2 -2
- package/dist/categories/kepler/solve-kepler.js.map +1 -0
- package/dist/categories/orbits/circular-speed.d.ts +42 -0
- package/dist/categories/orbits/circular-speed.d.ts.map +1 -0
- package/dist/categories/orbits/circular-speed.js +50 -0
- package/dist/categories/orbits/circular-speed.js.map +1 -0
- package/dist/categories/orbits/escape-speed.d.ts +50 -0
- package/dist/categories/orbits/escape-speed.d.ts.map +1 -0
- package/dist/categories/orbits/escape-speed.js +58 -0
- package/dist/categories/orbits/escape-speed.js.map +1 -0
- package/dist/categories/orbits/kepler-period.d.ts +45 -0
- package/dist/categories/orbits/kepler-period.d.ts.map +1 -0
- package/dist/categories/orbits/kepler-period.js +54 -0
- package/dist/categories/orbits/kepler-period.js.map +1 -0
- package/dist/categories/orbits/peri-apoapsis-radii.d.ts +46 -0
- package/dist/categories/orbits/peri-apoapsis-radii.d.ts.map +1 -0
- package/dist/categories/orbits/peri-apoapsis-radii.js +85 -0
- package/dist/categories/orbits/peri-apoapsis-radii.js.map +1 -0
- package/dist/categories/orbits/specific-angular-momentum-from-elements.d.ts +60 -0
- package/dist/categories/orbits/specific-angular-momentum-from-elements.d.ts.map +1 -0
- package/dist/categories/orbits/specific-angular-momentum-from-elements.js +76 -0
- package/dist/categories/orbits/specific-angular-momentum-from-elements.js.map +1 -0
- package/dist/categories/orbits/specific-angular-momentum.d.ts +55 -0
- package/dist/categories/orbits/specific-angular-momentum.d.ts.map +1 -0
- package/dist/categories/orbits/specific-angular-momentum.js +76 -0
- package/dist/categories/orbits/specific-angular-momentum.js.map +1 -0
- package/dist/categories/orbits/specific-mechanical-energy.d.ts +49 -0
- package/dist/categories/orbits/specific-mechanical-energy.d.ts.map +1 -0
- package/dist/categories/orbits/specific-mechanical-energy.js +57 -0
- package/dist/categories/orbits/specific-mechanical-energy.js.map +1 -0
- package/dist/categories/orbits/vis-viva-speed.d.ts +42 -0
- package/dist/categories/orbits/vis-viva-speed.d.ts.map +1 -0
- package/dist/categories/orbits/vis-viva-speed.js +70 -0
- package/dist/categories/orbits/vis-viva-speed.js.map +1 -0
- package/dist/index.d.ts +20 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +25 -10
- package/dist/index.js.map +1 -1
- package/package.json +77 -5
- package/dist/__tests__/compute-mean-anomaly.int.spec.d.ts +0 -2
- package/dist/__tests__/compute-mean-anomaly.int.spec.d.ts.map +0 -1
- package/dist/__tests__/compute-mean-anomaly.int.spec.js.map +0 -1
- package/dist/__tests__/true-anomaly-to-mean-anomaly.int.spec.d.ts +0 -2
- package/dist/__tests__/true-anomaly-to-mean-anomaly.int.spec.d.ts.map +0 -1
- package/dist/__tests__/true-anomaly-to-mean-anomaly.int.spec.js.map +0 -1
- package/dist/compute-angle.d.ts.map +0 -1
- package/dist/compute-angle.js.map +0 -1
- package/dist/compute-mean-anomaly.d.ts.map +0 -1
- package/dist/compute-mean-anomaly.js.map +0 -1
- package/dist/eccentric-to-true-anomaly.d.ts.map +0 -1
- package/dist/eccentric-to-true-anomaly.js.map +0 -1
- package/dist/solve-kepler-bisection.d.ts.map +0 -1
- package/dist/solve-kepler-bisection.js.map +0 -1
- package/dist/solve-kepler-high-eccentricity.d.ts.map +0 -1
- package/dist/solve-kepler-high-eccentricity.js.map +0 -1
- package/dist/solve-kepler-newton-raphson.d.ts.map +0 -1
- package/dist/solve-kepler-newton-raphson.js.map +0 -1
- package/dist/solve-kepler.d.ts.map +0 -1
- package/dist/solve-kepler.js.map +0 -1
- package/dist/true-anomaly-to-mean-anomaly.d.ts.map +0 -1
- package/dist/true-anomaly-to-mean-anomaly.js.map +0 -1
- package/dist/wrap-angle.d.ts.map +0 -1
- package/dist/wrap-angle.js.map +0 -1
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import type { ForceResultInterface, Vector3DTupleType } from '@interstellar-tools/types';
|
|
2
|
+
/**
|
|
3
|
+
* Compute the Newtonian **gravitational force** on body 1 due to body 2.
|
|
4
|
+
*
|
|
5
|
+
* **Definitions**
|
|
6
|
+
*
|
|
7
|
+
* $$
|
|
8
|
+
* \mathbf r=\mathbf r_2-\mathbf r_1,\quad
|
|
9
|
+
* r=\lVert\mathbf r\rVert,\quad
|
|
10
|
+
* \hat{\mathbf r}=\frac{\mathbf r}{r}
|
|
11
|
+
* $$
|
|
12
|
+
*
|
|
13
|
+
* **Law & Decomposition**
|
|
14
|
+
*
|
|
15
|
+
* $$
|
|
16
|
+
* \mathbf F_{1\leftarrow2}
|
|
17
|
+
* = G\,\frac{m_1 m_2}{r^2}\,\hat{\mathbf r}
|
|
18
|
+
* $$
|
|
19
|
+
*
|
|
20
|
+
* $$
|
|
21
|
+
* \lVert\mathbf F\rVert
|
|
22
|
+
* = G\,\frac{m_1 m_2}{r^2},\qquad
|
|
23
|
+
* \mathbf F=\langle F_x,F_y,F_z\rangle
|
|
24
|
+
* = \lVert\mathbf F\rVert\,\hat{\mathbf r}
|
|
25
|
+
* $$
|
|
26
|
+
*
|
|
27
|
+
* $$
|
|
28
|
+
* F_x=\lVert\mathbf F\rVert\,\hat r_x,\quad
|
|
29
|
+
* F_y=\lVert\mathbf F\rVert\,\hat r_y,\quad
|
|
30
|
+
* F_z=\lVert\mathbf F\rVert\,\hat r_z
|
|
31
|
+
* $$
|
|
32
|
+
*
|
|
33
|
+
* **Newton's 3rd law, for context**
|
|
34
|
+
*
|
|
35
|
+
* $$
|
|
36
|
+
* \mathbf F_{1\leftarrow2}=-\,\mathbf F_{2\leftarrow1}
|
|
37
|
+
* $$
|
|
38
|
+
*
|
|
39
|
+
* **Conventions & units**
|
|
40
|
+
* - Input masses in **kilograms (kg)**; positions in **meters (m)**.
|
|
41
|
+
* - Output force in **newtons (N)**.
|
|
42
|
+
* - Returned `vector` and `direction` point **from body 1 toward body 2**; i.e., `direction = \hat{\mathbf r}`.
|
|
43
|
+
*
|
|
44
|
+
* **Invariants (within numerical tolerance)**
|
|
45
|
+
* - `vector = magnitude * direction`
|
|
46
|
+
* - `magnitude = sqrt(Fx² + Fy² + Fz²)`
|
|
47
|
+
* - `||direction|| = 1`
|
|
48
|
+
*
|
|
49
|
+
*
|
|
50
|
+
* @param {number} m1 Mass of body 1 (kg).
|
|
51
|
+
* @param {number} m2 Mass of body 2 (kg).
|
|
52
|
+
* @param {Vector3DTupleType} r1 Position of body 1 as a 3-tuple `[x, y, z]` in meters.
|
|
53
|
+
* @param {Vector3DTupleType} r2 Position of body 2 as a 3-tuple `[x, y, z]` in meters.
|
|
54
|
+
* @param {number} [G] Gravitational constant (defaults to `G_SI`, m³·kg⁻¹·s⁻²).
|
|
55
|
+
* @returns {ForceResultInterface} `{ vector, magnitude, direction }`.
|
|
56
|
+
* @throws {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error | Error} If `m1` or `m2` are non-finite or negative.
|
|
57
|
+
* @throws {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error | Error} If positions coincide (`r = 0`).
|
|
58
|
+
* @throws {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error | Error} If `G` is non-finite or not positive.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```ts
|
|
62
|
+
* import { gravitationalForce } from "@interstellar-tools/equations";
|
|
63
|
+
* import { G_SI } from "@interstellar-tools/constants";
|
|
64
|
+
*
|
|
65
|
+
* // Earth–Sun at ~1 AU
|
|
66
|
+
* const mEarth = 5.972e24; // kg
|
|
67
|
+
* const mSun = 1.9885e30; // kg
|
|
68
|
+
* const rEarth: [number, number, number] = [0, 0, 0];
|
|
69
|
+
* const rSun : [number, number, number] = [1.495978707e11, 0, 0]; // m
|
|
70
|
+
*
|
|
71
|
+
* const F = gravitationalForce(mEarth, mSun, rEarth, rSun, G_SI);
|
|
72
|
+
* console.log(F.magnitude.toExponential(3)); // ≈ "3.542e+22" N
|
|
73
|
+
* console.log(F.vector); // Points from Earth toward Sun (−x here)
|
|
74
|
+
* ```
|
|
75
|
+
*
|
|
76
|
+
* **Get F directly (recommended)**
|
|
77
|
+
*
|
|
78
|
+
* ```ts
|
|
79
|
+
* import { gravitationalForce } from "@interstellar-tools/equations";
|
|
80
|
+
* import type { Vector3DTupleType, ForceResultInterface } from "@interstellar-tools/types";
|
|
81
|
+
*
|
|
82
|
+
* const m1 = 5.972e24; // kg
|
|
83
|
+
* const m2 = 1.9885e30; // kg
|
|
84
|
+
* const r1: Vector3DTupleType = [0, 0, 0]; // m
|
|
85
|
+
* const r2: Vector3DTupleType = [1.495978707e11, 0, 0]; // m
|
|
86
|
+
*
|
|
87
|
+
* const { vector: F, magnitude, direction }: ForceResultInterface = gravitationalForce(m1, m2, r1, r2);
|
|
88
|
+
* ```
|
|
89
|
+
*
|
|
90
|
+
* @see https://en.wikipedia.org/wiki/Newton%27s_law_of_universal_gravitation
|
|
91
|
+
* @group Gravity
|
|
92
|
+
*/
|
|
93
|
+
export declare const gravitationalForce: (m1: number, m2: number, r1: Vector3DTupleType, r2: Vector3DTupleType, G?: number) => ForceResultInterface;
|
|
94
|
+
//# sourceMappingURL=gravitational-force.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gravitational-force.d.ts","sourceRoot":"","sources":["../../../src/categories/gravity/gravitational-force.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,oBAAoB,EACpB,iBAAiB,EAClB,MAAM,2BAA2B,CAAC;AAEnC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0FG;AACH,eAAO,MAAM,kBAAkB,GAC7B,IAAI,MAAM,EACV,IAAI,MAAM,EACV,IAAI,iBAAiB,EACrB,IAAI,iBAAiB,EACrB,IAAG,MAAa,KACf,oBAgCF,CAAC"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { G_SI } from '@interstellar-tools/constants';
|
|
2
|
+
/**
|
|
3
|
+
* Compute the Newtonian **gravitational force** on body 1 due to body 2.
|
|
4
|
+
*
|
|
5
|
+
* **Definitions**
|
|
6
|
+
*
|
|
7
|
+
* $$
|
|
8
|
+
* \mathbf r=\mathbf r_2-\mathbf r_1,\quad
|
|
9
|
+
* r=\lVert\mathbf r\rVert,\quad
|
|
10
|
+
* \hat{\mathbf r}=\frac{\mathbf r}{r}
|
|
11
|
+
* $$
|
|
12
|
+
*
|
|
13
|
+
* **Law & Decomposition**
|
|
14
|
+
*
|
|
15
|
+
* $$
|
|
16
|
+
* \mathbf F_{1\leftarrow2}
|
|
17
|
+
* = G\,\frac{m_1 m_2}{r^2}\,\hat{\mathbf r}
|
|
18
|
+
* $$
|
|
19
|
+
*
|
|
20
|
+
* $$
|
|
21
|
+
* \lVert\mathbf F\rVert
|
|
22
|
+
* = G\,\frac{m_1 m_2}{r^2},\qquad
|
|
23
|
+
* \mathbf F=\langle F_x,F_y,F_z\rangle
|
|
24
|
+
* = \lVert\mathbf F\rVert\,\hat{\mathbf r}
|
|
25
|
+
* $$
|
|
26
|
+
*
|
|
27
|
+
* $$
|
|
28
|
+
* F_x=\lVert\mathbf F\rVert\,\hat r_x,\quad
|
|
29
|
+
* F_y=\lVert\mathbf F\rVert\,\hat r_y,\quad
|
|
30
|
+
* F_z=\lVert\mathbf F\rVert\,\hat r_z
|
|
31
|
+
* $$
|
|
32
|
+
*
|
|
33
|
+
* **Newton's 3rd law, for context**
|
|
34
|
+
*
|
|
35
|
+
* $$
|
|
36
|
+
* \mathbf F_{1\leftarrow2}=-\,\mathbf F_{2\leftarrow1}
|
|
37
|
+
* $$
|
|
38
|
+
*
|
|
39
|
+
* **Conventions & units**
|
|
40
|
+
* - Input masses in **kilograms (kg)**; positions in **meters (m)**.
|
|
41
|
+
* - Output force in **newtons (N)**.
|
|
42
|
+
* - Returned `vector` and `direction` point **from body 1 toward body 2**; i.e., `direction = \hat{\mathbf r}`.
|
|
43
|
+
*
|
|
44
|
+
* **Invariants (within numerical tolerance)**
|
|
45
|
+
* - `vector = magnitude * direction`
|
|
46
|
+
* - `magnitude = sqrt(Fx² + Fy² + Fz²)`
|
|
47
|
+
* - `||direction|| = 1`
|
|
48
|
+
*
|
|
49
|
+
*
|
|
50
|
+
* @param {number} m1 Mass of body 1 (kg).
|
|
51
|
+
* @param {number} m2 Mass of body 2 (kg).
|
|
52
|
+
* @param {Vector3DTupleType} r1 Position of body 1 as a 3-tuple `[x, y, z]` in meters.
|
|
53
|
+
* @param {Vector3DTupleType} r2 Position of body 2 as a 3-tuple `[x, y, z]` in meters.
|
|
54
|
+
* @param {number} [G] Gravitational constant (defaults to `G_SI`, m³·kg⁻¹·s⁻²).
|
|
55
|
+
* @returns {ForceResultInterface} `{ vector, magnitude, direction }`.
|
|
56
|
+
* @throws {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error | Error} If `m1` or `m2` are non-finite or negative.
|
|
57
|
+
* @throws {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error | Error} If positions coincide (`r = 0`).
|
|
58
|
+
* @throws {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error | Error} If `G` is non-finite or not positive.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```ts
|
|
62
|
+
* import { gravitationalForce } from "@interstellar-tools/equations";
|
|
63
|
+
* import { G_SI } from "@interstellar-tools/constants";
|
|
64
|
+
*
|
|
65
|
+
* // Earth–Sun at ~1 AU
|
|
66
|
+
* const mEarth = 5.972e24; // kg
|
|
67
|
+
* const mSun = 1.9885e30; // kg
|
|
68
|
+
* const rEarth: [number, number, number] = [0, 0, 0];
|
|
69
|
+
* const rSun : [number, number, number] = [1.495978707e11, 0, 0]; // m
|
|
70
|
+
*
|
|
71
|
+
* const F = gravitationalForce(mEarth, mSun, rEarth, rSun, G_SI);
|
|
72
|
+
* console.log(F.magnitude.toExponential(3)); // ≈ "3.542e+22" N
|
|
73
|
+
* console.log(F.vector); // Points from Earth toward Sun (−x here)
|
|
74
|
+
* ```
|
|
75
|
+
*
|
|
76
|
+
* **Get F directly (recommended)**
|
|
77
|
+
*
|
|
78
|
+
* ```ts
|
|
79
|
+
* import { gravitationalForce } from "@interstellar-tools/equations";
|
|
80
|
+
* import type { Vector3DTupleType, ForceResultInterface } from "@interstellar-tools/types";
|
|
81
|
+
*
|
|
82
|
+
* const m1 = 5.972e24; // kg
|
|
83
|
+
* const m2 = 1.9885e30; // kg
|
|
84
|
+
* const r1: Vector3DTupleType = [0, 0, 0]; // m
|
|
85
|
+
* const r2: Vector3DTupleType = [1.495978707e11, 0, 0]; // m
|
|
86
|
+
*
|
|
87
|
+
* const { vector: F, magnitude, direction }: ForceResultInterface = gravitationalForce(m1, m2, r1, r2);
|
|
88
|
+
* ```
|
|
89
|
+
*
|
|
90
|
+
* @see https://en.wikipedia.org/wiki/Newton%27s_law_of_universal_gravitation
|
|
91
|
+
* @group Gravity
|
|
92
|
+
*/
|
|
93
|
+
export const gravitationalForce = (m1, m2, r1, r2, G = G_SI) => {
|
|
94
|
+
if (!Number.isFinite(m1) || !Number.isFinite(m2) || m1 < 0 || m2 < 0) {
|
|
95
|
+
throw new Error('m1 and m2 must be finite, non-negative numbers (kg).');
|
|
96
|
+
}
|
|
97
|
+
if (!Number.isFinite(G) || G <= 0) {
|
|
98
|
+
throw new Error('G must be a finite, positive number (m^3·kg^-1·s^-2).');
|
|
99
|
+
}
|
|
100
|
+
const rx = r2[0] - r1[0];
|
|
101
|
+
const ry = r2[1] - r1[1];
|
|
102
|
+
const rz = r2[2] - r1[2];
|
|
103
|
+
const r2mag = rx * rx + ry * ry + rz * rz;
|
|
104
|
+
if (r2mag === 0) {
|
|
105
|
+
throw new Error('Bodies are at the same position: gravitational force is singular (r = 0).');
|
|
106
|
+
}
|
|
107
|
+
const invR = 1 / Math.sqrt(r2mag);
|
|
108
|
+
const dir = [rx * invR, ry * invR, rz * invR];
|
|
109
|
+
// |F| = G m1 m2 / r^2
|
|
110
|
+
const magnitude = (G * m1 * m2) / r2mag;
|
|
111
|
+
// Vector points from body 1 toward body 2.
|
|
112
|
+
const Fx = dir[0] * magnitude;
|
|
113
|
+
const Fy = dir[1] * magnitude;
|
|
114
|
+
const Fz = dir[2] * magnitude;
|
|
115
|
+
// Ensure the tuple type is preserved for callers.
|
|
116
|
+
const vector = [Fx, Fy, Fz];
|
|
117
|
+
return { vector, magnitude, direction: dir };
|
|
118
|
+
};
|
|
119
|
+
//# sourceMappingURL=gravitational-force.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gravitational-force.js","sourceRoot":"","sources":["../../../src/categories/gravity/gravitational-force.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,+BAA+B,CAAC;AAMrD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0FG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAChC,EAAU,EACV,EAAU,EACV,EAAqB,EACrB,EAAqB,EACrB,IAAY,IAAI,EACM,EAAE;IACxB,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE,CAAC;QACrE,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;IAC1E,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAClC,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;IAC3E,CAAC;IAED,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;IACzB,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;IACzB,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;IACzB,MAAM,KAAK,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;IAE1C,IAAI,KAAK,KAAK,CAAC,EAAE,CAAC;QAChB,MAAM,IAAI,KAAK,CACb,2EAA2E,CAC5E,CAAC;IACJ,CAAC;IAED,MAAM,IAAI,GAAG,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAClC,MAAM,GAAG,GAAsB,CAAC,EAAE,GAAG,IAAI,EAAE,EAAE,GAAG,IAAI,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;IACjE,sBAAsB;IACtB,MAAM,SAAS,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,GAAG,KAAK,CAAC;IACxC,2CAA2C;IAC3C,MAAM,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;IAC9B,MAAM,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;IAC9B,MAAM,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;IAC9B,kDAAkD;IAClD,MAAM,MAAM,GAAsB,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;IAE/C,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC;AAC/C,CAAC,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Two-body **gravitational parameter** ($ \mu $).
|
|
3
|
+
*
|
|
4
|
+
* **Definition**
|
|
5
|
+
*
|
|
6
|
+
* $$
|
|
7
|
+
* \mu = G\,(M + m)
|
|
8
|
+
* $$
|
|
9
|
+
*
|
|
10
|
+
* **Common approximation, when** ($ M \gg m $)
|
|
11
|
+
*
|
|
12
|
+
* $$
|
|
13
|
+
* \mu \approx G\,M
|
|
14
|
+
* $$
|
|
15
|
+
*
|
|
16
|
+
* **Units**
|
|
17
|
+
* - Inputs: masses in **kg**, ( $ G $ ) in **m³·kg⁻¹·s⁻²** (defaults to `G_SI`).
|
|
18
|
+
* - Output: ($ \mu $) in **m³/s²**.
|
|
19
|
+
*
|
|
20
|
+
* ::: tip
|
|
21
|
+
*
|
|
22
|
+
* - Use `m = 0` (default) for the standard published ($ \mu $) of a central body.
|
|
23
|
+
* - When modelling a binary with comparable masses, pass both `M` and `m`.
|
|
24
|
+
*
|
|
25
|
+
* :::
|
|
26
|
+
*
|
|
27
|
+
* @param {number} M Mass of the primary body (kg).
|
|
28
|
+
* @param {number} m Mass of the secondary body (kg). Defaults to `0`.
|
|
29
|
+
* @param {number} [G] Gravitational constant. Defaults to `G_SI`.
|
|
30
|
+
* @returns {number} Gravitational parameter ($ \mu $) in m³/s².
|
|
31
|
+
* @throws {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error | Error} If `M` is non-finite or negative.
|
|
32
|
+
* @throws {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error | Error} If `m` is non-finite or negative.
|
|
33
|
+
* @throws {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error | Error} If `G` is non-finite or negative.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```ts
|
|
37
|
+
* // Standard gravitational parameter for Earth (approximate: m ~ 0)
|
|
38
|
+
* const muEarth = gravitationalParameter(5.97219e24); // ≈ 3.986004e14 m^3/s^2
|
|
39
|
+
*
|
|
40
|
+
* // Earth + 1000 kg satellite: practically identical to GM
|
|
41
|
+
* const muExact = gravitationalParameter(5.97219e24, 1000);
|
|
42
|
+
*
|
|
43
|
+
* // Earth–Moon system (two-body μ)
|
|
44
|
+
* const muEarthMoon = gravitationalParameter(5.97219e24, 7.342e22);
|
|
45
|
+
* ```
|
|
46
|
+
* @group Gravity
|
|
47
|
+
*/
|
|
48
|
+
export declare const gravitationalParameter: (M: number, m?: number, G?: number) => number;
|
|
49
|
+
//# sourceMappingURL=gravitational-parameter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gravitational-parameter.d.ts","sourceRoot":"","sources":["../../../src/categories/gravity/gravitational-parameter.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,eAAO,MAAM,sBAAsB,GACjC,GAAG,MAAM,EACT,IAAG,MAAU,EACb,IAAG,MAAa,KACf,MAcF,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { G_SI } from '@interstellar-tools/constants';
|
|
2
|
+
/**
|
|
3
|
+
* Two-body **gravitational parameter** ($ \mu $).
|
|
4
|
+
*
|
|
5
|
+
* **Definition**
|
|
6
|
+
*
|
|
7
|
+
* $$
|
|
8
|
+
* \mu = G\,(M + m)
|
|
9
|
+
* $$
|
|
10
|
+
*
|
|
11
|
+
* **Common approximation, when** ($ M \gg m $)
|
|
12
|
+
*
|
|
13
|
+
* $$
|
|
14
|
+
* \mu \approx G\,M
|
|
15
|
+
* $$
|
|
16
|
+
*
|
|
17
|
+
* **Units**
|
|
18
|
+
* - Inputs: masses in **kg**, ( $ G $ ) in **m³·kg⁻¹·s⁻²** (defaults to `G_SI`).
|
|
19
|
+
* - Output: ($ \mu $) in **m³/s²**.
|
|
20
|
+
*
|
|
21
|
+
* ::: tip
|
|
22
|
+
*
|
|
23
|
+
* - Use `m = 0` (default) for the standard published ($ \mu $) of a central body.
|
|
24
|
+
* - When modelling a binary with comparable masses, pass both `M` and `m`.
|
|
25
|
+
*
|
|
26
|
+
* :::
|
|
27
|
+
*
|
|
28
|
+
* @param {number} M Mass of the primary body (kg).
|
|
29
|
+
* @param {number} m Mass of the secondary body (kg). Defaults to `0`.
|
|
30
|
+
* @param {number} [G] Gravitational constant. Defaults to `G_SI`.
|
|
31
|
+
* @returns {number} Gravitational parameter ($ \mu $) in m³/s².
|
|
32
|
+
* @throws {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error | Error} If `M` is non-finite or negative.
|
|
33
|
+
* @throws {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error | Error} If `m` is non-finite or negative.
|
|
34
|
+
* @throws {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error | Error} If `G` is non-finite or negative.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```ts
|
|
38
|
+
* // Standard gravitational parameter for Earth (approximate: m ~ 0)
|
|
39
|
+
* const muEarth = gravitationalParameter(5.97219e24); // ≈ 3.986004e14 m^3/s^2
|
|
40
|
+
*
|
|
41
|
+
* // Earth + 1000 kg satellite: practically identical to GM
|
|
42
|
+
* const muExact = gravitationalParameter(5.97219e24, 1000);
|
|
43
|
+
*
|
|
44
|
+
* // Earth–Moon system (two-body μ)
|
|
45
|
+
* const muEarthMoon = gravitationalParameter(5.97219e24, 7.342e22);
|
|
46
|
+
* ```
|
|
47
|
+
* @group Gravity
|
|
48
|
+
*/
|
|
49
|
+
export const gravitationalParameter = (M, m = 0, G = G_SI) => {
|
|
50
|
+
if (!Number.isFinite(M) || M < 0) {
|
|
51
|
+
throw new Error('M must be a finite, positive number (kg).');
|
|
52
|
+
}
|
|
53
|
+
if (!Number.isFinite(m) || m < 0) {
|
|
54
|
+
throw new Error('m must be a finite, positive number (kg).');
|
|
55
|
+
}
|
|
56
|
+
if (!Number.isFinite(G) || G <= 0) {
|
|
57
|
+
throw new Error('G must be a finite, positive number (m^3·kg^-1·s^-2).');
|
|
58
|
+
}
|
|
59
|
+
return G * (M + m);
|
|
60
|
+
};
|
|
61
|
+
//# sourceMappingURL=gravitational-parameter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gravitational-parameter.js","sourceRoot":"","sources":["../../../src/categories/gravity/gravitational-parameter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,+BAA+B,CAAC;AAErD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CACpC,CAAS,EACT,IAAY,CAAC,EACb,IAAY,IAAI,EACR,EAAE;IACV,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QACjC,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;IAC/D,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QACjC,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;IAC/D,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAClC,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;IAC3E,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;AACrB,CAAC,CAAC"}
|
|
@@ -69,7 +69,7 @@ import { Radians } from '@interstellar-tools/types';
|
|
|
69
69
|
*
|
|
70
70
|
* @see [Kepler's Equation (Wikipedia)](https://en.wikipedia.org/wiki/Kepler%27s_equation)
|
|
71
71
|
* @see [Bisection Method (Wikipedia)](https://en.wikipedia.org/wiki/Bisection_method)
|
|
72
|
-
* @
|
|
72
|
+
* @group Kepler Solvers
|
|
73
73
|
*/
|
|
74
74
|
export declare const solveKeplerBisection: (M: Radians, e: number, maxIter: number, tolerance: number) => Radians;
|
|
75
75
|
//# sourceMappingURL=solve-kepler-bisection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"solve-kepler-bisection.d.ts","sourceRoot":"","sources":["../../../src/categories/kepler/solve-kepler-bisection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAEpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuEG;AACH,eAAO,MAAM,oBAAoB,GAC/B,GAAG,OAAO,EACV,GAAG,MAAM,EACT,SAAS,MAAM,EACf,WAAW,MAAM,KAChB,OAwBF,CAAC"}
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
*
|
|
69
69
|
* @see [Kepler's Equation (Wikipedia)](https://en.wikipedia.org/wiki/Kepler%27s_equation)
|
|
70
70
|
* @see [Bisection Method (Wikipedia)](https://en.wikipedia.org/wiki/Bisection_method)
|
|
71
|
-
* @
|
|
71
|
+
* @group Kepler Solvers
|
|
72
72
|
*/
|
|
73
73
|
export const solveKeplerBisection = (M, e, maxIter, tolerance) => {
|
|
74
74
|
let E_low = 0;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"solve-kepler-bisection.js","sourceRoot":"","sources":["../../../src/categories/kepler/solve-kepler-bisection.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuEG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAClC,CAAU,EACV,CAAS,EACT,OAAe,EACf,SAAiB,EACR,EAAE;IACX,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC;IACrB,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IAC7B,IAAI,IAAI,GAAG,CAAC,CAAC;IAEb,OAAO,IAAI,GAAG,OAAO,EAAE,CAAC;QACtB,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QAElC,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,SAAS,EAAE,CAAC;YAC5B,OAAO,CAAC,CAAC,CAAC,YAAY;QACxB,CAAC;QAED,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;YACV,MAAM,GAAG,CAAC,CAAC;QACb,CAAC;aAAM,CAAC;YACN,KAAK,GAAG,CAAC,CAAC;QACZ,CAAC;QAED,CAAC,GAAG,CAAC,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;QACzB,IAAI,EAAE,CAAC;IACT,CAAC;IAED,OAAO,CAAC,CAAC,CAAC,qBAAqB;AACjC,CAAC,CAAC"}
|
|
@@ -3,8 +3,6 @@ import { Radians } from '@interstellar-tools/types';
|
|
|
3
3
|
* Solves **Kepler's Equation** for the **Eccentric Anomaly** ($E$) in highly eccentric orbits
|
|
4
4
|
* ($e > 0.9$) using an iterative numerical approach.
|
|
5
5
|
*
|
|
6
|
-
* ---
|
|
7
|
-
*
|
|
8
6
|
* **Mathematical Explanation:**
|
|
9
7
|
*
|
|
10
8
|
* Kepler's equation for eccentric anomaly ($E$) is:
|
|
@@ -55,13 +53,11 @@ import { Radians } from '@interstellar-tools/types';
|
|
|
55
53
|
* 3. **Angle Wrapping (Elliptical Only):**
|
|
56
54
|
* - The result is wrapped using `wrapAngle()` for consistency.
|
|
57
55
|
*
|
|
58
|
-
* ---
|
|
59
56
|
*
|
|
60
57
|
* **Performance Considerations:**
|
|
61
58
|
* - **Typically converges in fewer than 10 iterations for $e > 0.9$.**
|
|
62
59
|
* - **Time complexity:** $O(1)$ for standard convergence.
|
|
63
60
|
*
|
|
64
|
-
* ---
|
|
65
61
|
*
|
|
66
62
|
* @param {Radians} M - Mean anomaly ($M$) in **radians**.
|
|
67
63
|
* @param {number} e - Orbital eccentricity ($e > 0.9$ for high-eccentricity orbits).
|
|
@@ -69,7 +65,6 @@ import { Radians } from '@interstellar-tools/types';
|
|
|
69
65
|
* @param {number} [tolerance=1e-9] - Convergence criterion for stopping the iteration.
|
|
70
66
|
* @returns {Radians} The **eccentric anomaly** ($E$) in **radians** (wrapped to $[-\pi, \pi]$ for elliptical orbits).
|
|
71
67
|
*
|
|
72
|
-
* ---
|
|
73
68
|
*
|
|
74
69
|
* @example
|
|
75
70
|
* ```ts
|
|
@@ -89,11 +84,10 @@ import { Radians } from '@interstellar-tools/types';
|
|
|
89
84
|
* console.log(solveKeplerHighEccentricity(M_hyperbolic, e_hyperbolic));
|
|
90
85
|
* ```
|
|
91
86
|
*
|
|
92
|
-
* ---
|
|
93
|
-
*
|
|
94
87
|
* @see [Kepler's Equation (Wikipedia)](https://en.wikipedia.org/wiki/Kepler%27s_equation)
|
|
95
88
|
* @see [Hyperbolic Anomaly (Wikipedia)](https://en.wikipedia.org/wiki/Hyperbolic_trajectory#Hyperbolic_anomaly)
|
|
96
|
-
* @
|
|
89
|
+
* @group Kepler Solvers
|
|
90
|
+
*
|
|
97
91
|
*/
|
|
98
92
|
export declare const solveKeplerHighEccentricity: (M: Radians, e: number, maxIter?: number, tolerance?: number) => Radians;
|
|
99
93
|
//# sourceMappingURL=solve-kepler-high-eccentricity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"solve-kepler-high-eccentricity.d.ts","sourceRoot":"","sources":["../../../src/categories/kepler/solve-kepler-high-eccentricity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAKpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyFG;AAEH,eAAO,MAAM,2BAA2B,GACtC,GAAG,OAAO,EACV,GAAG,MAAM,EACT,gBAAsE,EACtE,kBAAgB,KACf,OAgEF,CAAC"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { wrapAngle } from '
|
|
1
|
+
import { wrapAngle } from '../angle/wrap-angle';
|
|
2
|
+
/* node:coverage disable */
|
|
2
3
|
/**
|
|
3
4
|
* Solves **Kepler's Equation** for the **Eccentric Anomaly** ($E$) in highly eccentric orbits
|
|
4
5
|
* ($e > 0.9$) using an iterative numerical approach.
|
|
5
6
|
*
|
|
6
|
-
* ---
|
|
7
|
-
*
|
|
8
7
|
* **Mathematical Explanation:**
|
|
9
8
|
*
|
|
10
9
|
* Kepler's equation for eccentric anomaly ($E$) is:
|
|
@@ -55,13 +54,11 @@ import { wrapAngle } from './wrap-angle';
|
|
|
55
54
|
* 3. **Angle Wrapping (Elliptical Only):**
|
|
56
55
|
* - The result is wrapped using `wrapAngle()` for consistency.
|
|
57
56
|
*
|
|
58
|
-
* ---
|
|
59
57
|
*
|
|
60
58
|
* **Performance Considerations:**
|
|
61
59
|
* - **Typically converges in fewer than 10 iterations for $e > 0.9$.**
|
|
62
60
|
* - **Time complexity:** $O(1)$ for standard convergence.
|
|
63
61
|
*
|
|
64
|
-
* ---
|
|
65
62
|
*
|
|
66
63
|
* @param {Radians} M - Mean anomaly ($M$) in **radians**.
|
|
67
64
|
* @param {number} e - Orbital eccentricity ($e > 0.9$ for high-eccentricity orbits).
|
|
@@ -69,7 +66,6 @@ import { wrapAngle } from './wrap-angle';
|
|
|
69
66
|
* @param {number} [tolerance=1e-9] - Convergence criterion for stopping the iteration.
|
|
70
67
|
* @returns {Radians} The **eccentric anomaly** ($E$) in **radians** (wrapped to $[-\pi, \pi]$ for elliptical orbits).
|
|
71
68
|
*
|
|
72
|
-
* ---
|
|
73
69
|
*
|
|
74
70
|
* @example
|
|
75
71
|
* ```ts
|
|
@@ -89,12 +85,12 @@ import { wrapAngle } from './wrap-angle';
|
|
|
89
85
|
* console.log(solveKeplerHighEccentricity(M_hyperbolic, e_hyperbolic));
|
|
90
86
|
* ```
|
|
91
87
|
*
|
|
92
|
-
* ---
|
|
93
|
-
*
|
|
94
88
|
* @see [Kepler's Equation (Wikipedia)](https://en.wikipedia.org/wiki/Kepler%27s_equation)
|
|
95
89
|
* @see [Hyperbolic Anomaly (Wikipedia)](https://en.wikipedia.org/wiki/Hyperbolic_trajectory#Hyperbolic_anomaly)
|
|
96
|
-
* @
|
|
90
|
+
* @group Kepler Solvers
|
|
91
|
+
*
|
|
97
92
|
*/
|
|
93
|
+
/* node:coverage enable */
|
|
98
94
|
export const solveKeplerHighEccentricity = (M, e, maxIter = Math.max(300, Math.floor(5 + 3 * Math.log(1 + Math.abs(M)))), tolerance = 1e-9) => {
|
|
99
95
|
if (e < 0) {
|
|
100
96
|
throw new RangeError(`Invalid eccentricity: ${e}. Must be e ≥ 0.`);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"solve-kepler-high-eccentricity.js","sourceRoot":"","sources":["../../../src/categories/kepler/solve-kepler-high-eccentricity.ts"],"names":[],"mappings":"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"}
|
package/dist/{solve-kepler-newton-raphson.d.ts → categories/kepler/solve-kepler-newton-raphson.d.ts}
RENAMED
|
@@ -81,7 +81,7 @@ import { Radians } from '@interstellar-tools/types';
|
|
|
81
81
|
* @see [Kepler's Equation (Wikipedia)](https://en.wikipedia.org/wiki/Kepler%27s_equation)
|
|
82
82
|
* @see [Newton-Raphson Method (Wikipedia)](https://en.wikipedia.org/wiki/Newton%27s_method)
|
|
83
83
|
* @see [Eccentric Anomaly (Wikipedia)](https://en.wikipedia.org/wiki/Mean_anomaly#Eccentric_anomaly)
|
|
84
|
-
* @
|
|
84
|
+
* @group Kepler Solvers
|
|
85
85
|
*/
|
|
86
86
|
export declare const solveKeplerNewtonRaphson: (M: Radians, e: number, maxIter: number, tolerance: number) => Radians;
|
|
87
87
|
//# sourceMappingURL=solve-kepler-newton-raphson.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"solve-kepler-newton-raphson.d.ts","sourceRoot":"","sources":["../../../src/categories/kepler/solve-kepler-newton-raphson.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAEpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmFG;AACH,eAAO,MAAM,wBAAwB,GACnC,GAAG,OAAO,EACV,GAAG,MAAM,EACT,SAAS,MAAM,EACf,WAAW,MAAM,KAChB,OAwCF,CAAC"}
|
package/dist/{solve-kepler-newton-raphson.js → categories/kepler/solve-kepler-newton-raphson.js}
RENAMED
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
* @see [Kepler's Equation (Wikipedia)](https://en.wikipedia.org/wiki/Kepler%27s_equation)
|
|
81
81
|
* @see [Newton-Raphson Method (Wikipedia)](https://en.wikipedia.org/wiki/Newton%27s_method)
|
|
82
82
|
* @see [Eccentric Anomaly (Wikipedia)](https://en.wikipedia.org/wiki/Mean_anomaly#Eccentric_anomaly)
|
|
83
|
-
* @
|
|
83
|
+
* @group Kepler Solvers
|
|
84
84
|
*/
|
|
85
85
|
export const solveKeplerNewtonRaphson = (M, e, maxIter, tolerance) => {
|
|
86
86
|
if (e < 0 || e >= 1) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"solve-kepler-newton-raphson.js","sourceRoot":"","sources":["../../../src/categories/kepler/solve-kepler-newton-raphson.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmFG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CACtC,CAAU,EACV,CAAS,EACT,OAAe,EACf,SAAiB,EACR,EAAE;IACX,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QACpB,MAAM,IAAI,UAAU,CAAC,yBAAyB,CAAC,2BAA2B,CAAC,CAAC;IAC9E,CAAC;IAED,IAAI,CAAS,CAAC;IAEd,sBAAsB;IACtB,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC;QACZ,CAAC,GAAG,CAAC,CAAC;IACR,CAAC;SAAM,IAAI,CAAC,GAAG,IAAI,EAAE,CAAC;QACpB,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAClD,CAAC;SAAM,CAAC;QACN,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,wBAAwB;IAC3C,CAAC;IAED,IAAI,IAAI,GAAG,CAAC,CAAC;IAEb,OAAO,IAAI,GAAG,OAAO,EAAE,CAAC;QACtB,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QAClC,MAAM,EAAE,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAC/B,MAAM,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAC5B,MAAM,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAC5B,MAAM,MAAM,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,gBAAgB;QAExC,oDAAoD;QACpD,IAAI,UAAU,GAAG,MAAM,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,GAAG,MAAM,GAAG,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC;QAE1D,UAAU,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,UAAU,GAAG,UAAU,GAAG,GAAG,CAAC,GAAG,EAAE,CAAC;QAEjE,CAAC,IAAI,UAAU,CAAC;QAEhB,IAAI,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,SAAS,EAAE,CAAC;YACrC,OAAO,CAAC,CAAC,CAAC,YAAY;QACxB,CAAC;QAED,IAAI,EAAE,CAAC;IACT,CAAC;IAED,OAAO,GAAG,CAAC,CAAC,mBAAmB;AACjC,CAAC,CAAC"}
|
|
@@ -76,7 +76,7 @@ import { Radians } from '@interstellar-tools/types';
|
|
|
76
76
|
* @see [Newton-Raphson Method (Wikipedia)](https://en.wikipedia.org/wiki/Newton%27s_method)
|
|
77
77
|
* @see [Eccentric Anomaly (Wikipedia)](https://en.wikipedia.org/wiki/Mean_anomaly#Eccentric_anomaly)
|
|
78
78
|
* @see [RangeError](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError)
|
|
79
|
-
* @
|
|
79
|
+
* @group Kepler Solvers
|
|
80
80
|
*/
|
|
81
81
|
export declare const solveKepler: (M: Radians, e: number, maxIter?: number, tolerance?: number) => Radians;
|
|
82
82
|
//# sourceMappingURL=solve-kepler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"solve-kepler.d.ts","sourceRoot":"","sources":["../../../src/categories/kepler/solve-kepler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAQpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8EG;AACH,eAAO,MAAM,WAAW,GACtB,GAAG,OAAO,EACV,GAAG,MAAM,EACT,gBAAY,EACZ,kBAAgB,KACf,OAkBF,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { wrapAngle } from '../angle/wrap-angle';
|
|
1
2
|
import { solveKeplerBisection } from './solve-kepler-bisection';
|
|
2
3
|
import { solveKeplerHighEccentricity } from './solve-kepler-high-eccentricity';
|
|
3
4
|
import { solveKeplerNewtonRaphson } from './solve-kepler-newton-raphson';
|
|
4
|
-
import { wrapAngle } from './wrap-angle';
|
|
5
5
|
/**
|
|
6
6
|
* Solves **Kepler's Equation** for the **Eccentric Anomaly** ($E$) using an adaptive approach:
|
|
7
7
|
* - **Newton-Raphson method** for fast convergence.
|
|
@@ -79,7 +79,7 @@ import { wrapAngle } from './wrap-angle';
|
|
|
79
79
|
* @see [Newton-Raphson Method (Wikipedia)](https://en.wikipedia.org/wiki/Newton%27s_method)
|
|
80
80
|
* @see [Eccentric Anomaly (Wikipedia)](https://en.wikipedia.org/wiki/Mean_anomaly#Eccentric_anomaly)
|
|
81
81
|
* @see [RangeError](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError)
|
|
82
|
-
* @
|
|
82
|
+
* @group Kepler Solvers
|
|
83
83
|
*/
|
|
84
84
|
export const solveKepler = (M, e, maxIter = 50, tolerance = 1e-9) => {
|
|
85
85
|
if (e < 0 || e >= 1) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"solve-kepler.js","sourceRoot":"","sources":["../../../src/categories/kepler/solve-kepler.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAC/E,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAEzE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8EG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CACzB,CAAU,EACV,CAAS,EACT,OAAO,GAAG,EAAE,EACZ,SAAS,GAAG,IAAI,EACP,EAAE;IACX,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QACpB,MAAM,IAAI,UAAU,CAAC,yBAAyB,CAAC,2BAA2B,CAAC,CAAC;IAC9E,CAAC;IAED,wDAAwD;IACxD,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC;QACZ,OAAO,2BAA2B,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;IAC/D,CAAC;IAED,+DAA+D;IAC/D,IAAI,CAAC,GAAG,wBAAwB,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;IAE3D,IAAI,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;QACb,CAAC,GAAG,oBAAoB,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;IACrD,CAAC;IAED,OAAO,SAAS,CAAC,CAAC,CAAC,CAAC;AACtB,CAAC,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* **Circular speed** ($ v_c $) for a body in a circular orbit at radius ($ r $).
|
|
3
|
+
*
|
|
4
|
+
* **Definition**
|
|
5
|
+
*
|
|
6
|
+
* $$
|
|
7
|
+
* v_c=\sqrt{\frac{\mu}{r}}
|
|
8
|
+
* $$
|
|
9
|
+
*
|
|
10
|
+
* where ($ \mu $) is the standard gravitational parameter and ($ r $) is the distance
|
|
11
|
+
* from the central body's center to the orbiting body.
|
|
12
|
+
*
|
|
13
|
+
* **Units**
|
|
14
|
+
* - Inputs: ($ r $) in **meters (m)**, ($ \mu $) in **m³/s²**.
|
|
15
|
+
* - Output: ($ v_c $) in **m/s**.
|
|
16
|
+
*
|
|
17
|
+
* ::: info
|
|
18
|
+
*
|
|
19
|
+
* - This is the special case of the vis-viva equation for circular orbits (($ a=r $)).
|
|
20
|
+
* - If you need a non-circular orbit, use `visVivaSpeed(r, a, mu)`.
|
|
21
|
+
*
|
|
22
|
+
* :::
|
|
23
|
+
*
|
|
24
|
+
* @param {number} r Orbital radius ($ r $) (m), must be finite and **> 0**.
|
|
25
|
+
* @param {number} mu Gravitational parameter ($ \mu $) (m³/s²), must be finite and **≥ 0**.
|
|
26
|
+
* @returns {number} Circular speed ($ v_c $) (m/s).
|
|
27
|
+
* @throws {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error | Error} If inputs are non-finite or out of domain.
|
|
28
|
+
*
|
|
29
|
+
* @see {@link visVivaSpeed}
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```ts
|
|
33
|
+
* // LEO ~400 km altitude around Earth
|
|
34
|
+
* const muEarth = 3.986004418e14; // m^3/s^2
|
|
35
|
+
* const r = 6378e3 + 400e3; // m
|
|
36
|
+
* const v = circularSpeed(r, muEarth); // ≈ 7670 m/s
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* @group Orbits
|
|
40
|
+
*/
|
|
41
|
+
export declare const circularSpeed: (r: number, mu: number) => number;
|
|
42
|
+
//# sourceMappingURL=circular-speed.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"circular-speed.d.ts","sourceRoot":"","sources":["../../../src/categories/orbits/circular-speed.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,eAAO,MAAM,aAAa,GAAI,GAAG,MAAM,EAAE,IAAI,MAAM,KAAG,MAUrD,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* **Circular speed** ($ v_c $) for a body in a circular orbit at radius ($ r $).
|
|
3
|
+
*
|
|
4
|
+
* **Definition**
|
|
5
|
+
*
|
|
6
|
+
* $$
|
|
7
|
+
* v_c=\sqrt{\frac{\mu}{r}}
|
|
8
|
+
* $$
|
|
9
|
+
*
|
|
10
|
+
* where ($ \mu $) is the standard gravitational parameter and ($ r $) is the distance
|
|
11
|
+
* from the central body's center to the orbiting body.
|
|
12
|
+
*
|
|
13
|
+
* **Units**
|
|
14
|
+
* - Inputs: ($ r $) in **meters (m)**, ($ \mu $) in **m³/s²**.
|
|
15
|
+
* - Output: ($ v_c $) in **m/s**.
|
|
16
|
+
*
|
|
17
|
+
* ::: info
|
|
18
|
+
*
|
|
19
|
+
* - This is the special case of the vis-viva equation for circular orbits (($ a=r $)).
|
|
20
|
+
* - If you need a non-circular orbit, use `visVivaSpeed(r, a, mu)`.
|
|
21
|
+
*
|
|
22
|
+
* :::
|
|
23
|
+
*
|
|
24
|
+
* @param {number} r Orbital radius ($ r $) (m), must be finite and **> 0**.
|
|
25
|
+
* @param {number} mu Gravitational parameter ($ \mu $) (m³/s²), must be finite and **≥ 0**.
|
|
26
|
+
* @returns {number} Circular speed ($ v_c $) (m/s).
|
|
27
|
+
* @throws {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error | Error} If inputs are non-finite or out of domain.
|
|
28
|
+
*
|
|
29
|
+
* @see {@link visVivaSpeed}
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```ts
|
|
33
|
+
* // LEO ~400 km altitude around Earth
|
|
34
|
+
* const muEarth = 3.986004418e14; // m^3/s^2
|
|
35
|
+
* const r = 6378e3 + 400e3; // m
|
|
36
|
+
* const v = circularSpeed(r, muEarth); // ≈ 7670 m/s
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* @group Orbits
|
|
40
|
+
*/
|
|
41
|
+
export const circularSpeed = (r, mu) => {
|
|
42
|
+
if (!Number.isFinite(r) || r <= 0) {
|
|
43
|
+
throw new Error('r must be a finite, positive number (m).');
|
|
44
|
+
}
|
|
45
|
+
if (!Number.isFinite(mu) || mu < 0) {
|
|
46
|
+
throw new Error('mu must be a finite, non-negative number (m^3/s^2).');
|
|
47
|
+
}
|
|
48
|
+
return Math.sqrt(mu / r);
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=circular-speed.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"circular-speed.js","sourceRoot":"","sources":["../../../src/categories/orbits/circular-speed.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAS,EAAE,EAAU,EAAU,EAAE;IAC7D,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAClC,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;IAC9D,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE,CAAC;QACnC,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;IACzE,CAAC;IAED,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;AAC3B,CAAC,CAAC"}
|