@interstellar-tools/equations 0.61.1 → 0.62.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.
@@ -56,7 +56,7 @@ import { CwState, CwStateDerivative } from '@interstellar-tools/types';
56
56
  *
57
57
  * const mu = 398600.4418; // km³/s²
58
58
  * const a = 7000; // km
59
- * const n = meanMotion(mu, a); // rad/s
59
+ * const n = meanMotion(a, mu); // rad/s
60
60
  *
61
61
  * const s: CwState = [100, 0, 0, 0, 0.01, 0];
62
62
  * const ds = cwHillDerivatives(s, n);
@@ -55,7 +55,7 @@
55
55
  *
56
56
  * const mu = 398600.4418; // km³/s²
57
57
  * const a = 7000; // km
58
- * const n = meanMotion(mu, a); // rad/s
58
+ * const n = meanMotion(a, mu); // rad/s
59
59
  *
60
60
  * const s: CwState = [100, 0, 0, 0, 0.01, 0];
61
61
  * const ds = cwHillDerivatives(s, n);
@@ -16,19 +16,19 @@
16
16
  * - If $ \mu $ is in km³/s², then $r_p$ must be in km and speeds are in km/s.
17
17
  *
18
18
  * @param vInfinity Hyperbolic excess speed $ v_{\infty} $ (must be finite, >= 0).
19
- * @param mu Standard gravitational parameter $ \mu $ (must be finite, > 0).
20
19
  * @param rp Periapsis radius $ r_p $ from the central body's center (must be finite, > 0).
20
+ * @param mu Standard gravitational parameter $ \mu $ (must be finite, > 0).
21
21
  * @returns Periapsis speed $ v_p $ in the same speed units as `vInfinity`.
22
22
  * @throws {TypeError} If any input is not finite.
23
- * @throws {RangeError} If `vInfinity < 0`, `mu <= 0`, or `rp <= 0`.
23
+ * @throws {RangeError} If `vInfinity < 0`, `rp <= 0`, or `mu <= 0`.
24
24
  * @group Orbits
25
25
  *
26
26
  * @example
27
27
  * ```ts
28
28
  * // Earth example (km-based):
29
29
  * // mu = 398600.4418 km³/s², rp ~ 6678 km (LEO-ish), v∞ = 3.2 km/s
30
- * const vp = hyperbolicPeriapsisSpeed(3.2, 398600.4418, 6678);
30
+ * const vp = hyperbolicPeriapsisSpeed(3.2, 6678, 398600.4418);
31
31
  * ```
32
32
  */
33
- export declare const hyperbolicPeriapsisSpeed: (vInfinity: number, mu: number, rp: number) => number;
33
+ export declare const hyperbolicPeriapsisSpeed: (vInfinity: number, rp: number, mu: number) => number;
34
34
  //# sourceMappingURL=hyperbolic-periapsis-speed.d.ts.map
@@ -17,40 +17,40 @@
17
17
  * - If $ \mu $ is in km³/s², then $r_p$ must be in km and speeds are in km/s.
18
18
  *
19
19
  * @param vInfinity Hyperbolic excess speed $ v_{\infty} $ (must be finite, >= 0).
20
- * @param mu Standard gravitational parameter $ \mu $ (must be finite, > 0).
21
20
  * @param rp Periapsis radius $ r_p $ from the central body's center (must be finite, > 0).
21
+ * @param mu Standard gravitational parameter $ \mu $ (must be finite, > 0).
22
22
  * @returns Periapsis speed $ v_p $ in the same speed units as `vInfinity`.
23
23
  * @throws {TypeError} If any input is not finite.
24
- * @throws {RangeError} If `vInfinity < 0`, `mu <= 0`, or `rp <= 0`.
24
+ * @throws {RangeError} If `vInfinity < 0`, `rp <= 0`, or `mu <= 0`.
25
25
  * @group Orbits
26
26
  *
27
27
  * @example
28
28
  * ```ts
29
29
  * // Earth example (km-based):
30
30
  * // mu = 398600.4418 km³/s², rp ~ 6678 km (LEO-ish), v∞ = 3.2 km/s
31
- * const vp = hyperbolicPeriapsisSpeed(3.2, 398600.4418, 6678);
31
+ * const vp = hyperbolicPeriapsisSpeed(3.2, 6678, 398600.4418);
32
32
  * ```
33
33
  */
34
34
  /* node:coverage enable */
35
- export const hyperbolicPeriapsisSpeed = (vInfinity, mu, rp) => {
35
+ export const hyperbolicPeriapsisSpeed = (vInfinity, rp, mu) => {
36
36
  if (!Number.isFinite(vInfinity)) {
37
37
  throw new TypeError(`vInfinity must be a finite number. Received: ${vInfinity}`);
38
38
  }
39
- if (!Number.isFinite(mu)) {
40
- throw new TypeError(`mu must be a finite number. Received: ${mu}`);
41
- }
42
39
  if (!Number.isFinite(rp)) {
43
40
  throw new TypeError(`rp must be a finite number. Received: ${rp}`);
44
41
  }
42
+ if (!Number.isFinite(mu)) {
43
+ throw new TypeError(`mu must be a finite number. Received: ${mu}`);
44
+ }
45
45
  if (vInfinity < 0) {
46
46
  throw new RangeError(`vInfinity must be >= 0. Received: ${vInfinity}`);
47
47
  }
48
- if (mu <= 0) {
49
- throw new RangeError(`mu must be > 0. Received: ${mu}`);
50
- }
51
48
  if (rp <= 0) {
52
49
  throw new RangeError(`rp must be > 0. Received: ${rp}`);
53
50
  }
51
+ if (mu <= 0) {
52
+ throw new RangeError(`mu must be > 0. Received: ${mu}`);
53
+ }
54
54
  const term = vInfinity * vInfinity + (2 * mu) / rp;
55
55
  // With valid ranges above, term should be positive, but guard anyway.
56
56
  if (term < 0) {
@@ -28,16 +28,16 @@
28
28
  * orbits per day, the unit used in a satellite's two-line elements (TLEs).
29
29
  *
30
30
  * ```ts
31
- * meanMotion(3.986004418e14, 6.371e6 + 420e3); // ≈ 0.001128 rad/s
31
+ * meanMotion(6.371e6 + 420e3, 3.986004418e14); // ≈ 0.001128 rad/s
32
32
  * ```
33
33
  *
34
34
  * :::
35
35
  *
36
- * @param mu - Standard gravitational parameter $ \mu $ (finite, > 0).
37
36
  * @param a - Semi-major axis $ a $ (finite, > 0).
37
+ * @param mu - Standard gravitational parameter $ \mu $ (finite, > 0).
38
38
  * @returns Mean motion $ n $ in **rad/s**.
39
- * @throws {TypeError} If `mu` or `a` is not a finite number.
40
- * @throws {RangeError} If `mu <= 0` or `a <= 0`.
39
+ * @throws {TypeError} If `a` or `mu` is not a finite number.
40
+ * @throws {RangeError} If `a <= 0` or `mu <= 0`.
41
41
  * @group Orbits
42
42
  *
43
43
  * @example
@@ -45,8 +45,8 @@
45
45
  * // Earth example (km-based):
46
46
  * const mu = 398600.4418; // km³/s²
47
47
  * const a = 7000; // km
48
- * const n = meanMotion(mu, a); // rad/s
48
+ * const n = meanMotion(a, mu); // rad/s
49
49
  * ```
50
50
  */
51
- export declare const meanMotion: (mu: number, a: number) => number;
51
+ export declare const meanMotion: (a: number, mu: number) => number;
52
52
  //# sourceMappingURL=mean-motion.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mean-motion.d.ts","sourceRoot":"","sources":["../../../src/categories/orbits/mean-motion.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,eAAO,MAAM,UAAU,GAAI,IAAI,MAAM,EAAE,GAAG,MAAM,KAAG,MAYlD,CAAC"}
1
+ {"version":3,"file":"mean-motion.d.ts","sourceRoot":"","sources":["../../../src/categories/orbits/mean-motion.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,eAAO,MAAM,UAAU,GAAI,GAAG,MAAM,EAAE,IAAI,MAAM,KAAG,MAYlD,CAAC"}
@@ -28,16 +28,16 @@
28
28
  * orbits per day, the unit used in a satellite's two-line elements (TLEs).
29
29
  *
30
30
  * ```ts
31
- * meanMotion(3.986004418e14, 6.371e6 + 420e3); // ≈ 0.001128 rad/s
31
+ * meanMotion(6.371e6 + 420e3, 3.986004418e14); // ≈ 0.001128 rad/s
32
32
  * ```
33
33
  *
34
34
  * :::
35
35
  *
36
- * @param mu - Standard gravitational parameter $ \mu $ (finite, > 0).
37
36
  * @param a - Semi-major axis $ a $ (finite, > 0).
37
+ * @param mu - Standard gravitational parameter $ \mu $ (finite, > 0).
38
38
  * @returns Mean motion $ n $ in **rad/s**.
39
- * @throws {TypeError} If `mu` or `a` is not a finite number.
40
- * @throws {RangeError} If `mu <= 0` or `a <= 0`.
39
+ * @throws {TypeError} If `a` or `mu` is not a finite number.
40
+ * @throws {RangeError} If `a <= 0` or `mu <= 0`.
41
41
  * @group Orbits
42
42
  *
43
43
  * @example
@@ -45,18 +45,18 @@
45
45
  * // Earth example (km-based):
46
46
  * const mu = 398600.4418; // km³/s²
47
47
  * const a = 7000; // km
48
- * const n = meanMotion(mu, a); // rad/s
48
+ * const n = meanMotion(a, mu); // rad/s
49
49
  * ```
50
50
  */
51
- export const meanMotion = (mu, a) => {
52
- if (!Number.isFinite(mu))
53
- throw new TypeError(`mu must be finite. Received: ${mu}`);
51
+ export const meanMotion = (a, mu) => {
54
52
  if (!Number.isFinite(a))
55
53
  throw new TypeError(`a must be finite. Received: ${a}`);
56
- if (mu <= 0)
57
- throw new RangeError(`mu must be > 0. Received: ${mu}`);
54
+ if (!Number.isFinite(mu))
55
+ throw new TypeError(`mu must be finite. Received: ${mu}`);
58
56
  if (a <= 0)
59
57
  throw new RangeError(`a must be > 0. Received: ${a}`);
58
+ if (mu <= 0)
59
+ throw new RangeError(`mu must be > 0. Received: ${mu}`);
60
60
  return Math.sqrt(mu / (a * a * a));
61
61
  };
62
62
  //# sourceMappingURL=mean-motion.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"mean-motion.js","sourceRoot":"","sources":["../../../src/categories/orbits/mean-motion.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,EAAU,EAAE,CAAS,EAAU,EAAE;IAC1D,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;QACtB,MAAM,IAAI,SAAS,CAAC,gCAAgC,EAAE,EAAE,CAAC,CAAC;IAE5D,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;QACrB,MAAM,IAAI,SAAS,CAAC,+BAA+B,CAAC,EAAE,CAAC,CAAC;IAE1D,IAAI,EAAE,IAAI,CAAC;QAAE,MAAM,IAAI,UAAU,CAAC,6BAA6B,EAAE,EAAE,CAAC,CAAC;IAErE,IAAI,CAAC,IAAI,CAAC;QAAE,MAAM,IAAI,UAAU,CAAC,4BAA4B,CAAC,EAAE,CAAC,CAAC;IAElE,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AACrC,CAAC,CAAC"}
1
+ {"version":3,"file":"mean-motion.js","sourceRoot":"","sources":["../../../src/categories/orbits/mean-motion.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAS,EAAE,EAAU,EAAU,EAAE;IAC1D,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;QACrB,MAAM,IAAI,SAAS,CAAC,+BAA+B,CAAC,EAAE,CAAC,CAAC;IAE1D,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;QACtB,MAAM,IAAI,SAAS,CAAC,gCAAgC,EAAE,EAAE,CAAC,CAAC;IAE5D,IAAI,CAAC,IAAI,CAAC;QAAE,MAAM,IAAI,UAAU,CAAC,4BAA4B,CAAC,EAAE,CAAC,CAAC;IAElE,IAAI,EAAE,IAAI,CAAC;QAAE,MAAM,IAAI,UAAU,CAAC,6BAA6B,EAAE,EAAE,CAAC,CAAC;IAErE,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AACrC,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@interstellar-tools/equations",
3
- "version": "0.61.1",
3
+ "version": "0.62.0",
4
4
  "description": "Curated, well-tested orbital mechanics and dynamics formulas (e.g., Newtonian gravity, vis-viva, Kepler's 3rd law, escape/circular speeds, specific energy, specific angular momentum, peri/apoapsis radii).",
5
5
  "keywords": [
6
6
  "interstellar",