@interstellar-tools/equations 0.1.1 → 0.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.
Files changed (62) hide show
  1. package/README.md +0 -8
  2. package/dist/__tests__/gravitational-acceleration-on1-by2.int.spec.d.ts +2 -0
  3. package/dist/__tests__/gravitational-acceleration-on1-by2.int.spec.d.ts.map +1 -0
  4. package/dist/__tests__/gravitational-acceleration-on1-by2.int.spec.js +86 -0
  5. package/dist/__tests__/gravitational-acceleration-on1-by2.int.spec.js.map +1 -0
  6. package/dist/__tests__/gravitational-force-on1-by2.int.spec.d.ts +2 -0
  7. package/dist/__tests__/gravitational-force-on1-by2.int.spec.d.ts.map +1 -0
  8. package/dist/__tests__/gravitational-force-on1-by2.int.spec.js +106 -0
  9. package/dist/__tests__/gravitational-force-on1-by2.int.spec.js.map +1 -0
  10. package/dist/__tests__/gravitational-force.spec.d.ts +2 -0
  11. package/dist/__tests__/gravitational-force.spec.d.ts.map +1 -0
  12. package/dist/__tests__/gravitational-force.spec.js +105 -0
  13. package/dist/__tests__/gravitational-force.spec.js.map +1 -0
  14. package/dist/__tests__/gravitational-parameters.spec.d.ts +2 -0
  15. package/dist/__tests__/gravitational-parameters.spec.d.ts.map +1 -0
  16. package/dist/__tests__/gravitational-parameters.spec.js +75 -0
  17. package/dist/__tests__/gravitational-parameters.spec.js.map +1 -0
  18. package/dist/__tests__/helpers/index.d.ts +8 -0
  19. package/dist/__tests__/helpers/index.d.ts.map +1 -0
  20. package/dist/__tests__/helpers/index.js +25 -0
  21. package/dist/__tests__/helpers/index.js.map +1 -0
  22. package/dist/__tests__/kepler-period.spec.d.ts +2 -0
  23. package/dist/__tests__/kepler-period.spec.d.ts.map +1 -0
  24. package/dist/__tests__/kepler-period.spec.js +72 -0
  25. package/dist/__tests__/kepler-period.spec.js.map +1 -0
  26. package/dist/__tests__/specific-mechanical-energy.spec.d.ts +2 -0
  27. package/dist/__tests__/specific-mechanical-energy.spec.d.ts.map +1 -0
  28. package/dist/__tests__/specific-mechanical-energy.spec.js +81 -0
  29. package/dist/__tests__/specific-mechanical-energy.spec.js.map +1 -0
  30. package/dist/__tests__/vis-viva-speed.spec.d.ts +2 -0
  31. package/dist/__tests__/vis-viva-speed.spec.d.ts.map +1 -0
  32. package/dist/__tests__/vis-viva-speed.spec.js +80 -0
  33. package/dist/__tests__/vis-viva-speed.spec.js.map +1 -0
  34. package/dist/compute-mean-anomaly.d.ts +1 -1
  35. package/dist/compute-mean-anomaly.js +1 -1
  36. package/dist/eccentric-to-true-anomaly.d.ts +1 -1
  37. package/dist/eccentric-to-true-anomaly.js +1 -1
  38. package/dist/gravitational-parameter.d.ts +49 -0
  39. package/dist/gravitational-parameter.d.ts.map +1 -0
  40. package/dist/gravitational-parameter.js +61 -0
  41. package/dist/gravitational-parameter.js.map +1 -0
  42. package/dist/index.d.ts +5 -0
  43. package/dist/index.d.ts.map +1 -1
  44. package/dist/index.js +5 -0
  45. package/dist/index.js.map +1 -1
  46. package/dist/kepler-period.d.ts +45 -0
  47. package/dist/kepler-period.d.ts.map +1 -0
  48. package/dist/kepler-period.js +54 -0
  49. package/dist/kepler-period.js.map +1 -0
  50. package/dist/law-of-gravitation.d.ts +243 -0
  51. package/dist/law-of-gravitation.d.ts.map +1 -0
  52. package/dist/law-of-gravitation.js +284 -0
  53. package/dist/law-of-gravitation.js.map +1 -0
  54. package/dist/specific-mechanical-energy.d.ts +49 -0
  55. package/dist/specific-mechanical-energy.d.ts.map +1 -0
  56. package/dist/specific-mechanical-energy.js +57 -0
  57. package/dist/specific-mechanical-energy.js.map +1 -0
  58. package/dist/vis-viva-speed.d.ts +42 -0
  59. package/dist/vis-viva-speed.d.ts.map +1 -0
  60. package/dist/vis-viva-speed.js +70 -0
  61. package/dist/vis-viva-speed.js.map +1 -0
  62. package/package.json +76 -4
@@ -0,0 +1,81 @@
1
+ import assert from 'node:assert/strict';
2
+ import test, { describe } from 'node:test';
3
+ import { specificMechanicalEnergy } from '../specific-mechanical-energy';
4
+ import { absClose, relClose } from './helpers';
5
+ describe('specificMechanicalEnergy', () => {
6
+ test('circular orbit: ε = -μ/(2r) when v = sqrt(μ/r)', () => {
7
+ const mu = 3.986004418e14; // m^3/s^2 (Earth GM)
8
+ const r = 6378e3 + 400e3; // m (LEO-ish)
9
+ const v = Math.sqrt(mu / r); // m/s
10
+ const eps = specificMechanicalEnergy(v, r, mu);
11
+ const expected = -mu / (2 * r);
12
+ relClose(eps, expected, 1e-12);
13
+ });
14
+ test('parabolic case: v = sqrt(2μ/r) → ε ≈ 0', () => {
15
+ const mu = 3.986004418e14; // m^3/s^2
16
+ const r = 7000e3; // m
17
+ const v = Math.sqrt((2 * mu) / r);
18
+ const eps = specificMechanicalEnergy(v, r, mu);
19
+ // Use absolute tolerance because the expected value is 0
20
+ absClose(eps, 0, 1e-9);
21
+ });
22
+ test('hyperbolic case: v slightly above escape → ε > 0', () => {
23
+ const mu = 3.986004418e14;
24
+ const r = 7000e3;
25
+ const v_escape = Math.sqrt((2 * mu) / r);
26
+ const v = 1.01 * v_escape;
27
+ const eps = specificMechanicalEnergy(v, r, mu);
28
+ assert.ok(eps > 0, 'ε should be positive for hyperbolic cases');
29
+ });
30
+ test('elliptic case: v below circular → ε < 0', () => {
31
+ const mu = 3.986004418e14;
32
+ const r = 7000e3;
33
+ const v_circ = Math.sqrt(mu / r);
34
+ const v = 0.95 * v_circ;
35
+ const eps = specificMechanicalEnergy(v, r, mu);
36
+ assert.ok(eps < 0, 'ε should be negative for bound (elliptic) cases');
37
+ });
38
+ test('semi-major axis identity: ε = -μ/(2a) (using vis-viva for v)', () => {
39
+ const mu = 3.986004418e14;
40
+ const a = 10000e3; // m (semi-major axis)
41
+ const r = 8000e3; // m (some point on the ellipse)
42
+ const v = Math.sqrt(mu * (2 / r - 1 / a)); // vis-viva
43
+ const eps = specificMechanicalEnergy(v, r, mu);
44
+ const expected = -mu / (2 * a);
45
+ relClose(eps, expected, 1e-12);
46
+ });
47
+ test('monotonic in speed: increasing v increases ε (same r, μ)', () => {
48
+ const mu = 3.986004418e14;
49
+ const r = 8000e3;
50
+ const v1 = 7000;
51
+ const v2 = 7500;
52
+ const eps1 = specificMechanicalEnergy(v1, r, mu);
53
+ const eps2 = specificMechanicalEnergy(v2, r, mu);
54
+ assert.ok(eps2 > eps1);
55
+ });
56
+ test('increases with radius for fixed v: larger r → larger ε (less negative)', () => {
57
+ const mu = 3.986004418e14;
58
+ const v = 7500;
59
+ const r1 = 7000e3;
60
+ const r2 = 8000e3;
61
+ const eps1 = specificMechanicalEnergy(v, r1, mu);
62
+ const eps2 = specificMechanicalEnergy(v, r2, mu);
63
+ assert.ok(eps2 > eps1);
64
+ });
65
+ test('throws on invalid inputs', () => {
66
+ const mu = 3.986004418e14;
67
+ const r = 7000e3;
68
+ const v = 7500;
69
+ // v invalid
70
+ assert.throws(() => specificMechanicalEnergy(Number.NaN, r, mu), /non-negative/);
71
+ assert.throws(() => specificMechanicalEnergy(-1, r, mu), /non-negative/);
72
+ // r invalid
73
+ assert.throws(() => specificMechanicalEnergy(v, Number.NaN, mu), /positive/);
74
+ assert.throws(() => specificMechanicalEnergy(v, 0, mu), /positive/);
75
+ assert.throws(() => specificMechanicalEnergy(v, -1, mu), /positive/);
76
+ // mu invalid
77
+ assert.throws(() => specificMechanicalEnergy(v, r, Number.NaN), /non-negative/);
78
+ assert.throws(() => specificMechanicalEnergy(v, r, -1), /non-negative/);
79
+ });
80
+ });
81
+ //# sourceMappingURL=specific-mechanical-energy.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"specific-mechanical-energy.spec.js","sourceRoot":"","sources":["../../src/__tests__/specific-mechanical-energy.spec.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,IAAI,EAAE,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OA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wB,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,cAAc,CAAC,CAAC;QAEzE,YAAY;QACZ,MAAM,CAAC,MAAM,CACX,GAAG,EAAE,CAAC,wBAAwB,CAAC,CAAC,EAAE,MAAM,CAAC,GAAG,EAAE,EAAE,CAAC,EACjD,UAAU,CACX,CAAC;QACF,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,wBAAwB,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,UAAU,CAAC,CAAC;QACpE,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,wBAAwB,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,UAAU,CAAC,CAAC;QAErE,aAAa;QACb,MAAM,CAAC,MAAM,CACX,GAAG,EAAE,CAAC,wBAAwB,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,EAChD,cAAc,CACf,CAAC;QACF,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,wBAAwB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC;IAC1E,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=vis-viva-speed.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vis-viva-speed.spec.d.ts","sourceRoot":"","sources":["../../src/__tests__/vis-viva-speed.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,80 @@
1
+ import assert from 'node:assert/strict';
2
+ import test, { describe } from 'node:test';
3
+ import { absClose, relClose } from './helpers';
4
+ import { visVivaSpeed } from '../vis-viva-speed';
5
+ describe('visVivaSpeed', () => {
6
+ test('circular orbit: a = r → v = sqrt(μ/r)', () => {
7
+ const mu = 3.986004418e14; // m^3/s^2 (Earth GM)
8
+ const r = 6778e3; // m (LEO-ish)
9
+ const a = r;
10
+ const v = visVivaSpeed(r, a, mu);
11
+ const expected = Math.sqrt(mu / r);
12
+ relClose(v, expected, 1e-12);
13
+ });
14
+ test('parabolic trajectory: a = Infinity → v = sqrt(2μ/r)', () => {
15
+ const mu = 3.986004418e14;
16
+ const r = 7000e3;
17
+ const v = visVivaSpeed(r, Infinity, mu);
18
+ const expected = Math.sqrt((2 * mu) / r);
19
+ relClose(v, expected, 1e-12);
20
+ });
21
+ test('hyperbolic case: a < 0 uses same formula and yields valid speed', () => {
22
+ const mu = 3.986004418e14;
23
+ const r = 10000e3;
24
+ const a = -15000e3; // negative semi-major axis
25
+ const v = visVivaSpeed(r, a, mu);
26
+ const expected = Math.sqrt(mu * (2 / r - 1 / a));
27
+ relClose(v, expected, 1e-12);
28
+ });
29
+ test('radicand zero boundary: choose a such that 2/r - 1/a = 0 → v = 0', () => {
30
+ const mu = 3.986004418e14;
31
+ const r = 8000e3;
32
+ const a = r / 2; // 1/a = 2/r
33
+ const v = visVivaSpeed(r, a, mu);
34
+ absClose(v, 0, 1e-12);
35
+ });
36
+ test('tiny negative radicand (within tolerance) is clamped to v ≈ 0', () => {
37
+ const mu = 3.986004418e14;
38
+ const r = 8000e3;
39
+ // Function's tolerance: tol = |1e-14 * mu / r|
40
+ const tol = Math.abs((1e-14 * mu) / r);
41
+ const delta = tol / (2 * mu); // makes radicand = μ*(2/r - 1/a) = -tol/2
42
+ // Choose 1/a = 2/r + delta → a = 1 / (2/r + delta)
43
+ const a = 1 / (2 / r + delta);
44
+ const v = visVivaSpeed(r, a, mu);
45
+ absClose(v, 0, 1e-12);
46
+ });
47
+ test('significantly negative radicand throws (physically impossible state)', () => {
48
+ const mu = 3.986004418e14;
49
+ const r = 8000e3;
50
+ const a = r / 4; // 1/a = 4/r -> 2/r - 1/a = -2/r (negative)
51
+ assert.throws(() => visVivaSpeed(r, a, mu), /Invalid state: μ\*\(2\/r - 1\/a\) < 0/);
52
+ });
53
+ test('monotonic with radius for fixed a, μ: larger r → smaller v (ellipse domain)', () => {
54
+ const mu = 3.986004418e14;
55
+ const a = 10000e3; // ellipse: r must be < 2a
56
+ const r1 = 8000e3;
57
+ const r2 = 15000e3; // < 2a = 20000 km
58
+ const v1 = visVivaSpeed(r1, a, mu);
59
+ const v2 = visVivaSpeed(r2, a, mu);
60
+ assert.ok(v1 > v2, 'speed should decrease as radius increases (for fixed a)');
61
+ });
62
+ test('input validation: r<=0, mu<0/NaN, a non-finite (except +Infinity), a=0', () => {
63
+ const mu = 3.986004418e14;
64
+ const r = 7000e3;
65
+ const a = r;
66
+ // r invalid
67
+ assert.throws(() => visVivaSpeed(0, a, mu), /positive/);
68
+ assert.throws(() => visVivaSpeed(-1, a, mu), /positive/);
69
+ assert.throws(() => visVivaSpeed(Number.NaN, a, mu), /finite/);
70
+ // mu invalid
71
+ assert.throws(() => visVivaSpeed(r, a, -1), /non-negative/);
72
+ assert.throws(() => visVivaSpeed(r, a, Number.NaN), /finite/);
73
+ // a invalid (non-finite other than +Infinity)
74
+ assert.throws(() => visVivaSpeed(r, Number.NaN, mu), /finite/);
75
+ assert.throws(() => visVivaSpeed(r, Number.NEGATIVE_INFINITY, mu), /finite/);
76
+ // a = 0 invalid
77
+ assert.throws(() => visVivaSpeed(r, 0, mu), /non-zero/);
78
+ });
79
+ });
80
+ //# sourceMappingURL=vis-viva-speed.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vis-viva-speed.spec.js","sourceRoot":"","sources":["../../src/__tests__/vis-viva-speed.spec.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,IAAI,EAAE,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;IAC5B,IAAI,C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AC;QAC5D,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,CAAC;QAE9D,8CAA8C;QAC9C,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,CAAC,EAAE,MAAM,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,QAAQ,CAAC,CAAC;QAC/D,MAAM,CAAC,MAAM,CACX,GAAG,EAAE,CAAC,YAAY,CAAC,CAAC,EAAE,MAAM,CAAC,iBAAiB,EAAE,EAAE,CAAC,EACnD,QAAQ,CACT,CAAC;QAEF,gBAAgB;QAChB,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,UAAU,CAAC,CAAC;IAC1D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -21,7 +21,7 @@ import type { CelestialBodyType, Radians, TemporalInterface } from '@interstella
21
21
  * @param {TemporalInterface} timeStep - The time step over which to compute the change.
22
22
  * @returns {Radians} The computed mean anomaly in radians.
23
23
  *
24
- * @throws {RangeError} If the body's eccentricity is outside the range $0 \leq e < 1$.
24
+ * @throws {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError | RangeError} If the body's eccentricity is outside the range $0 \leq e < 1$.
25
25
  *
26
26
  * @example
27
27
  * ```ts
@@ -36,7 +36,7 @@ const areEqual = (a, b, epsilon = EPSILON) => {
36
36
  * @param {TemporalInterface} timeStep - The time step over which to compute the change.
37
37
  * @returns {Radians} The computed mean anomaly in radians.
38
38
  *
39
- * @throws {RangeError} If the body's eccentricity is outside the range $0 \leq e < 1$.
39
+ * @throws {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError | RangeError} If the body's eccentricity is outside the range $0 \leq e < 1$.
40
40
  *
41
41
  * @example
42
42
  * ```ts
@@ -27,7 +27,7 @@ import { Radians } from '@interstellar-tools/types';
27
27
  * @param {number} e - Orbital eccentricity ($0 \leq e < 1$).
28
28
  * @returns {Radians} True anomaly ($V$) in radians.
29
29
  *
30
- * @throws {RangeError} If **eccentricity** is out of the range $0 \leq e \leq 1$.
30
+ * @throws {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError | RangeError} If **eccentricity** is out of the range $0 \leq e \leq 1$.
31
31
  *
32
32
  * @example
33
33
  * ```ts
@@ -26,7 +26,7 @@
26
26
  * @param {number} e - Orbital eccentricity ($0 \leq e < 1$).
27
27
  * @returns {Radians} True anomaly ($V$) in radians.
28
28
  *
29
- * @throws {RangeError} If **eccentricity** is out of the range $0 \leq e \leq 1$.
29
+ * @throws {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError | RangeError} If **eccentricity** is out of the range $0 \leq e \leq 1$.
30
30
  *
31
31
  * @example
32
32
  * ```ts
@@ -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
+ * @category Dynamics
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/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
+ * @category Dynamics
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/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"}
package/dist/index.d.ts CHANGED
@@ -13,4 +13,9 @@ export * from './solve-kepler-newton-raphson';
13
13
  export * from './solve-kepler';
14
14
  export * from './true-anomaly-to-mean-anomaly';
15
15
  export * from './wrap-angle';
16
+ export * from './gravitational-parameter';
17
+ export * from './law-of-gravitation';
18
+ export * from './vis-viva-speed';
19
+ export * from './kepler-period';
20
+ export * from './specific-mechanical-energy';
16
21
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,iBAAiB,CAAC;AAEhC,cAAc,wBAAwB,CAAC;AAEvC,cAAc,6BAA6B,CAAC;AAE5C,cAAc,0BAA0B,CAAC;AAEzC,cAAc,kCAAkC,CAAC;AAEjD,cAAc,+BAA+B,CAAC;AAE9C,cAAc,gBAAgB,CAAC;AAE/B,cAAc,gCAAgC,CAAC;AAE/C,cAAc,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,iBAAiB,CAAC;AAEhC,cAAc,wBAAwB,CAAC;AAEvC,cAAc,6BAA6B,CAAC;AAE5C,cAAc,0BAA0B,CAAC;AAEzC,cAAc,kCAAkC,CAAC;AAEjD,cAAc,+BAA+B,CAAC;AAE9C,cAAc,gBAAgB,CAAC;AAE/B,cAAc,gCAAgC,CAAC;AAE/C,cAAc,cAAc,CAAC;AAE7B,cAAc,2BAA2B,CAAC;AAE1C,cAAc,sBAAsB,CAAC;AAErC,cAAc,kBAAkB,CAAC;AAEjC,cAAc,iBAAiB,CAAC;AAEhC,cAAc,8BAA8B,CAAC"}
package/dist/index.js CHANGED
@@ -13,4 +13,9 @@ export * from './solve-kepler-newton-raphson';
13
13
  export * from './solve-kepler';
14
14
  export * from './true-anomaly-to-mean-anomaly';
15
15
  export * from './wrap-angle';
16
+ export * from './gravitational-parameter';
17
+ export * from './law-of-gravitation';
18
+ export * from './vis-viva-speed';
19
+ export * from './kepler-period';
20
+ export * from './specific-mechanical-energy';
16
21
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,iBAAiB,CAAC;AAEhC,cAAc,wBAAwB,CAAC;AAEvC,cAAc,6BAA6B,CAAC;AAE5C,cAAc,0BAA0B,CAAC;AAEzC,cAAc,kCAAkC,CAAC;AAEjD,cAAc,+BAA+B,CAAC;AAE9C,cAAc,gBAAgB,CAAC;AAE/B,cAAc,gCAAgC,CAAC;AAE/C,cAAc,cAAc,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,iBAAiB,CAAC;AAEhC,cAAc,wBAAwB,CAAC;AAEvC,cAAc,6BAA6B,CAAC;AAE5C,cAAc,0BAA0B,CAAC;AAEzC,cAAc,kCAAkC,CAAC;AAEjD,cAAc,+BAA+B,CAAC;AAE9C,cAAc,gBAAgB,CAAC;AAE/B,cAAc,gCAAgC,CAAC;AAE/C,cAAc,cAAc,CAAC;AAE7B,cAAc,2BAA2B,CAAC;AAE1C,cAAc,sBAAsB,CAAC;AAErC,cAAc,kBAAkB,CAAC;AAEjC,cAAc,iBAAiB,CAAC;AAEhC,cAAc,8BAA8B,CAAC"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * **Kepler's 3rd law** - orbital period ($ T $) from semi-major axis ($ a $) and gravitational parameter ($ \mu $).
3
+ *
4
+ * **Definition**
5
+ *
6
+ * $$
7
+ * T = 2\pi \sqrt{\frac{a^3}{\mu}}
8
+ * $$
9
+ *
10
+ * **Units**
11
+ * - Inputs: ($ a $) in **meters (m)**, ($ \mu $) in **m³/s²**.
12
+ * - Output: ($ T $) in **seconds (s)**.
13
+ *
14
+ * ::: info
15
+ *
16
+ * - Valid for **Keplerian (two-body) bound orbits** with ($ a>0 $) (ellipses). Not defined for parabolic/hyperbolic trajectories.
17
+ * - ($ \mu $) is the **standard gravitational parameter** of the central body (e.g., Earth ($ \approx 3.986004418\times10^{14}\ \text{m}^3/\text{s}^2 $)).
18
+ *
19
+ * :::
20
+ *
21
+ * @param {number} a Semi-major axis (m), must be finite and **> 0**.
22
+ * @param {number} mu Gravitational parameter (m³/s²), must be finite and **> 0**.
23
+ * @returns {number} Orbital period ($ T $) (s).
24
+ * @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.
25
+ *
26
+ * @example
27
+ * ```ts
28
+ * // GEO: a ≈ 42,164 km → T ≈ 86,164 s (one sidereal day)
29
+ * const a = 42164e3; // m
30
+ * const muEarth = 3.986004418e14; // m^3/s^2
31
+ * const T = keplerPeriod(a, muEarth); // ≈ 86164 s
32
+ * ```
33
+ *
34
+ * @example
35
+ * ```ts
36
+ * // LEO-ish circular: a ≈ Earth radius + 400 km
37
+ * const a = 6378e3 + 400e3; // m
38
+ * const muEarth = 3.986004418e14; // m^3/s^2
39
+ * const T = keplerPeriod(a, muEarth); // ≈ 5550 s (~92.5 min)
40
+ * ```
41
+ *
42
+ * @category Dynamics
43
+ */
44
+ export declare const keplerPeriod: (a: number, mu: number) => number;
45
+ //# sourceMappingURL=kepler-period.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kepler-period.d.ts","sourceRoot":"","sources":["../src/kepler-period.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,eAAO,MAAM,YAAY,GAAI,GAAG,MAAM,EAAE,IAAI,MAAM,KAAG,MAYpD,CAAC"}
@@ -0,0 +1,54 @@
1
+ /**
2
+ * **Kepler's 3rd law** - orbital period ($ T $) from semi-major axis ($ a $) and gravitational parameter ($ \mu $).
3
+ *
4
+ * **Definition**
5
+ *
6
+ * $$
7
+ * T = 2\pi \sqrt{\frac{a^3}{\mu}}
8
+ * $$
9
+ *
10
+ * **Units**
11
+ * - Inputs: ($ a $) in **meters (m)**, ($ \mu $) in **m³/s²**.
12
+ * - Output: ($ T $) in **seconds (s)**.
13
+ *
14
+ * ::: info
15
+ *
16
+ * - Valid for **Keplerian (two-body) bound orbits** with ($ a>0 $) (ellipses). Not defined for parabolic/hyperbolic trajectories.
17
+ * - ($ \mu $) is the **standard gravitational parameter** of the central body (e.g., Earth ($ \approx 3.986004418\times10^{14}\ \text{m}^3/\text{s}^2 $)).
18
+ *
19
+ * :::
20
+ *
21
+ * @param {number} a Semi-major axis (m), must be finite and **> 0**.
22
+ * @param {number} mu Gravitational parameter (m³/s²), must be finite and **> 0**.
23
+ * @returns {number} Orbital period ($ T $) (s).
24
+ * @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.
25
+ *
26
+ * @example
27
+ * ```ts
28
+ * // GEO: a ≈ 42,164 km → T ≈ 86,164 s (one sidereal day)
29
+ * const a = 42164e3; // m
30
+ * const muEarth = 3.986004418e14; // m^3/s^2
31
+ * const T = keplerPeriod(a, muEarth); // ≈ 86164 s
32
+ * ```
33
+ *
34
+ * @example
35
+ * ```ts
36
+ * // LEO-ish circular: a ≈ Earth radius + 400 km
37
+ * const a = 6378e3 + 400e3; // m
38
+ * const muEarth = 3.986004418e14; // m^3/s^2
39
+ * const T = keplerPeriod(a, muEarth); // ≈ 5550 s (~92.5 min)
40
+ * ```
41
+ *
42
+ * @category Dynamics
43
+ */
44
+ export const keplerPeriod = (a, mu) => {
45
+ if (!Number.isFinite(a) || a <= 0) {
46
+ throw new Error('a must be a finite, positive number (meters).');
47
+ }
48
+ if (!Number.isFinite(mu) || mu <= 0) {
49
+ throw new Error('mu must be a finite, positive number (m^3/s^2).');
50
+ }
51
+ const a3 = a * a * a; // a^3
52
+ return 2 * Math.PI * Math.sqrt(a3 / mu);
53
+ };
54
+ //# sourceMappingURL=kepler-period.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kepler-period.js","sourceRoot":"","sources":["../src/kepler-period.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAS,EAAE,EAAU,EAAU,EAAE;IAC5D,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAClC,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;IACnE,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC;QACpC,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;IACrE,CAAC;IAED,MAAM,EAAE,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM;IAE5B,OAAO,CAAC,GAAG,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;AAC1C,CAAC,CAAC"}