@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.
Files changed (191) hide show
  1. package/dist/__tests__/circular-speed.spec.d.ts +2 -0
  2. package/dist/__tests__/circular-speed.spec.d.ts.map +1 -0
  3. package/dist/__tests__/circular-speed.spec.js +69 -0
  4. package/dist/__tests__/circular-speed.spec.js.map +1 -0
  5. package/dist/__tests__/compute-angle.int.spec.js +2 -2
  6. package/dist/__tests__/compute-angle.int.spec.js.map +1 -1
  7. package/dist/__tests__/eccentric-to-true-anomaly.spec.js +1 -1
  8. package/dist/__tests__/eccentric-to-true-anomaly.spec.js.map +1 -1
  9. package/dist/__tests__/escape-speed.spec.d.ts +2 -0
  10. package/dist/__tests__/escape-speed.spec.d.ts.map +1 -0
  11. package/dist/__tests__/escape-speed.spec.js +79 -0
  12. package/dist/__tests__/escape-speed.spec.js.map +1 -0
  13. package/dist/__tests__/gravitational-acceleration-on1-by2.int.spec.d.ts +2 -0
  14. package/dist/__tests__/gravitational-acceleration-on1-by2.int.spec.d.ts.map +1 -0
  15. package/dist/__tests__/gravitational-acceleration-on1-by2.int.spec.js +86 -0
  16. package/dist/__tests__/gravitational-acceleration-on1-by2.int.spec.js.map +1 -0
  17. package/dist/__tests__/gravitational-force-on1-by2.int.spec.d.ts +2 -0
  18. package/dist/__tests__/gravitational-force-on1-by2.int.spec.d.ts.map +1 -0
  19. package/dist/__tests__/gravitational-force-on1-by2.int.spec.js +106 -0
  20. package/dist/__tests__/gravitational-force-on1-by2.int.spec.js.map +1 -0
  21. package/dist/__tests__/gravitational-force.spec.d.ts +2 -0
  22. package/dist/__tests__/gravitational-force.spec.d.ts.map +1 -0
  23. package/dist/__tests__/gravitational-force.spec.js +105 -0
  24. package/dist/__tests__/gravitational-force.spec.js.map +1 -0
  25. package/dist/__tests__/gravitational-parameters.spec.d.ts +2 -0
  26. package/dist/__tests__/gravitational-parameters.spec.d.ts.map +1 -0
  27. package/dist/__tests__/gravitational-parameters.spec.js +75 -0
  28. package/dist/__tests__/gravitational-parameters.spec.js.map +1 -0
  29. package/dist/__tests__/helpers/index.d.ts +9 -0
  30. package/dist/__tests__/helpers/index.d.ts.map +1 -0
  31. package/dist/__tests__/helpers/index.js +31 -0
  32. package/dist/__tests__/helpers/index.js.map +1 -0
  33. package/dist/__tests__/kepler-period.spec.d.ts +2 -0
  34. package/dist/__tests__/kepler-period.spec.d.ts.map +1 -0
  35. package/dist/__tests__/kepler-period.spec.js +72 -0
  36. package/dist/__tests__/kepler-period.spec.js.map +1 -0
  37. package/dist/__tests__/mean-to-eccentric-anomaly.spec.d.ts +2 -0
  38. package/dist/__tests__/mean-to-eccentric-anomaly.spec.d.ts.map +1 -0
  39. package/dist/__tests__/{compute-mean-anomaly.int.spec.js → mean-to-eccentric-anomaly.spec.js} +49 -27
  40. package/dist/__tests__/mean-to-eccentric-anomaly.spec.js.map +1 -0
  41. package/dist/__tests__/peri-apoapsis-radii.spec.d.ts +2 -0
  42. package/dist/__tests__/peri-apoapsis-radii.spec.d.ts.map +1 -0
  43. package/dist/__tests__/peri-apoapsis-radii.spec.js +74 -0
  44. package/dist/__tests__/peri-apoapsis-radii.spec.js.map +1 -0
  45. package/dist/__tests__/solve-kepler-bisection.spec.js +1 -1
  46. package/dist/__tests__/solve-kepler-bisection.spec.js.map +1 -1
  47. package/dist/__tests__/solve-kepler-high-eccentricity.spec.js +1 -1
  48. package/dist/__tests__/solve-kepler-high-eccentricity.spec.js.map +1 -1
  49. package/dist/__tests__/solve-kepler-newton-raphson.spec.js +1 -1
  50. package/dist/__tests__/solve-kepler-newton-raphson.spec.js.map +1 -1
  51. package/dist/__tests__/solve-kepler.int.spec.js +1 -1
  52. package/dist/__tests__/solve-kepler.int.spec.js.map +1 -1
  53. package/dist/__tests__/specific-angular-momentum-from-elements.spec.d.ts +2 -0
  54. package/dist/__tests__/specific-angular-momentum-from-elements.spec.d.ts.map +1 -0
  55. package/dist/__tests__/specific-angular-momentum-from-elements.spec.js +86 -0
  56. package/dist/__tests__/specific-angular-momentum-from-elements.spec.js.map +1 -0
  57. package/dist/__tests__/specific-angular-momentum.spec.d.ts +2 -0
  58. package/dist/__tests__/specific-angular-momentum.spec.d.ts.map +1 -0
  59. package/dist/__tests__/specific-angular-momentum.spec.js +84 -0
  60. package/dist/__tests__/specific-angular-momentum.spec.js.map +1 -0
  61. package/dist/__tests__/specific-mechanical-energy.spec.d.ts +2 -0
  62. package/dist/__tests__/specific-mechanical-energy.spec.d.ts.map +1 -0
  63. package/dist/__tests__/specific-mechanical-energy.spec.js +81 -0
  64. package/dist/__tests__/specific-mechanical-energy.spec.js.map +1 -0
  65. package/dist/__tests__/true-to-mean-anomaly.spec.d.ts +2 -0
  66. package/dist/__tests__/true-to-mean-anomaly.spec.d.ts.map +1 -0
  67. package/dist/__tests__/{true-anomaly-to-mean-anomaly.int.spec.js → true-to-mean-anomaly.spec.js} +13 -13
  68. package/dist/__tests__/true-to-mean-anomaly.spec.js.map +1 -0
  69. package/dist/__tests__/vis-viva-speed.spec.d.ts +2 -0
  70. package/dist/__tests__/vis-viva-speed.spec.d.ts.map +1 -0
  71. package/dist/__tests__/vis-viva-speed.spec.js +80 -0
  72. package/dist/__tests__/vis-viva-speed.spec.js.map +1 -0
  73. package/dist/__tests__/wrap-angle.spec.js +1 -1
  74. package/dist/__tests__/wrap-angle.spec.js.map +1 -1
  75. package/dist/{compute-angle.d.ts → categories/angle/compute-angle.d.ts} +1 -1
  76. package/dist/categories/angle/compute-angle.d.ts.map +1 -0
  77. package/dist/{compute-angle.js → categories/angle/compute-angle.js} +5 -5
  78. package/dist/categories/angle/compute-angle.js.map +1 -0
  79. package/dist/{wrap-angle.d.ts → categories/angle/wrap-angle.d.ts} +1 -1
  80. package/dist/categories/angle/wrap-angle.d.ts.map +1 -0
  81. package/dist/{wrap-angle.js → categories/angle/wrap-angle.js} +1 -1
  82. package/dist/categories/angle/wrap-angle.js.map +1 -0
  83. package/dist/{eccentric-to-true-anomaly.d.ts → categories/anomalies/eccentric-to-true-anomaly.d.ts} +2 -2
  84. package/dist/categories/anomalies/eccentric-to-true-anomaly.d.ts.map +1 -0
  85. package/dist/{eccentric-to-true-anomaly.js → categories/anomalies/eccentric-to-true-anomaly.js} +2 -2
  86. package/dist/categories/anomalies/eccentric-to-true-anomaly.js.map +1 -0
  87. package/dist/{compute-mean-anomaly.d.ts → categories/anomalies/mean-to-eccentric-anomaly.d.ts} +6 -6
  88. package/dist/categories/anomalies/mean-to-eccentric-anomaly.d.ts.map +1 -0
  89. package/dist/{compute-mean-anomaly.js → categories/anomalies/mean-to-eccentric-anomaly.js} +12 -21
  90. package/dist/categories/anomalies/mean-to-eccentric-anomaly.js.map +1 -0
  91. package/dist/{true-anomaly-to-mean-anomaly.d.ts → categories/anomalies/true-to-mean-anomaly.d.ts} +6 -6
  92. package/dist/categories/anomalies/true-to-mean-anomaly.d.ts.map +1 -0
  93. package/dist/{true-anomaly-to-mean-anomaly.js → categories/anomalies/true-to-mean-anomaly.js} +7 -7
  94. package/dist/categories/anomalies/true-to-mean-anomaly.js.map +1 -0
  95. package/dist/categories/anomalies/utils/are-equal.d.ts +10 -0
  96. package/dist/categories/anomalies/utils/are-equal.d.ts.map +1 -0
  97. package/dist/categories/anomalies/utils/are-equal.js +13 -0
  98. package/dist/categories/anomalies/utils/are-equal.js.map +1 -0
  99. package/dist/categories/gravity/acceleration-on1-by2.d.ts +66 -0
  100. package/dist/categories/gravity/acceleration-on1-by2.d.ts.map +1 -0
  101. package/dist/categories/gravity/acceleration-on1-by2.js +75 -0
  102. package/dist/categories/gravity/acceleration-on1-by2.js.map +1 -0
  103. package/dist/categories/gravity/force-on1-by2.d.ts +87 -0
  104. package/dist/categories/gravity/force-on1-by2.d.ts.map +1 -0
  105. package/dist/categories/gravity/force-on1-by2.js +96 -0
  106. package/dist/categories/gravity/force-on1-by2.js.map +1 -0
  107. package/dist/categories/gravity/gravitational-force.d.ts +94 -0
  108. package/dist/categories/gravity/gravitational-force.d.ts.map +1 -0
  109. package/dist/categories/gravity/gravitational-force.js +119 -0
  110. package/dist/categories/gravity/gravitational-force.js.map +1 -0
  111. package/dist/categories/gravity/gravitational-parameter.d.ts +49 -0
  112. package/dist/categories/gravity/gravitational-parameter.d.ts.map +1 -0
  113. package/dist/categories/gravity/gravitational-parameter.js +61 -0
  114. package/dist/categories/gravity/gravitational-parameter.js.map +1 -0
  115. package/dist/{solve-kepler-bisection.d.ts → categories/kepler/solve-kepler-bisection.d.ts} +1 -1
  116. package/dist/categories/kepler/solve-kepler-bisection.d.ts.map +1 -0
  117. package/dist/{solve-kepler-bisection.js → categories/kepler/solve-kepler-bisection.js} +1 -1
  118. package/dist/categories/kepler/solve-kepler-bisection.js.map +1 -0
  119. package/dist/{solve-kepler-high-eccentricity.d.ts → categories/kepler/solve-kepler-high-eccentricity.d.ts} +2 -8
  120. package/dist/categories/kepler/solve-kepler-high-eccentricity.d.ts.map +1 -0
  121. package/dist/{solve-kepler-high-eccentricity.js → categories/kepler/solve-kepler-high-eccentricity.js} +5 -9
  122. package/dist/categories/kepler/solve-kepler-high-eccentricity.js.map +1 -0
  123. package/dist/{solve-kepler-newton-raphson.d.ts → categories/kepler/solve-kepler-newton-raphson.d.ts} +1 -1
  124. package/dist/categories/kepler/solve-kepler-newton-raphson.d.ts.map +1 -0
  125. package/dist/{solve-kepler-newton-raphson.js → categories/kepler/solve-kepler-newton-raphson.js} +1 -1
  126. package/dist/categories/kepler/solve-kepler-newton-raphson.js.map +1 -0
  127. package/dist/{solve-kepler.d.ts → categories/kepler/solve-kepler.d.ts} +1 -1
  128. package/dist/categories/kepler/solve-kepler.d.ts.map +1 -0
  129. package/dist/{solve-kepler.js → categories/kepler/solve-kepler.js} +2 -2
  130. package/dist/categories/kepler/solve-kepler.js.map +1 -0
  131. package/dist/categories/orbits/circular-speed.d.ts +42 -0
  132. package/dist/categories/orbits/circular-speed.d.ts.map +1 -0
  133. package/dist/categories/orbits/circular-speed.js +50 -0
  134. package/dist/categories/orbits/circular-speed.js.map +1 -0
  135. package/dist/categories/orbits/escape-speed.d.ts +50 -0
  136. package/dist/categories/orbits/escape-speed.d.ts.map +1 -0
  137. package/dist/categories/orbits/escape-speed.js +58 -0
  138. package/dist/categories/orbits/escape-speed.js.map +1 -0
  139. package/dist/categories/orbits/kepler-period.d.ts +45 -0
  140. package/dist/categories/orbits/kepler-period.d.ts.map +1 -0
  141. package/dist/categories/orbits/kepler-period.js +54 -0
  142. package/dist/categories/orbits/kepler-period.js.map +1 -0
  143. package/dist/categories/orbits/peri-apoapsis-radii.d.ts +46 -0
  144. package/dist/categories/orbits/peri-apoapsis-radii.d.ts.map +1 -0
  145. package/dist/categories/orbits/peri-apoapsis-radii.js +85 -0
  146. package/dist/categories/orbits/peri-apoapsis-radii.js.map +1 -0
  147. package/dist/categories/orbits/specific-angular-momentum-from-elements.d.ts +60 -0
  148. package/dist/categories/orbits/specific-angular-momentum-from-elements.d.ts.map +1 -0
  149. package/dist/categories/orbits/specific-angular-momentum-from-elements.js +76 -0
  150. package/dist/categories/orbits/specific-angular-momentum-from-elements.js.map +1 -0
  151. package/dist/categories/orbits/specific-angular-momentum.d.ts +55 -0
  152. package/dist/categories/orbits/specific-angular-momentum.d.ts.map +1 -0
  153. package/dist/categories/orbits/specific-angular-momentum.js +76 -0
  154. package/dist/categories/orbits/specific-angular-momentum.js.map +1 -0
  155. package/dist/categories/orbits/specific-mechanical-energy.d.ts +49 -0
  156. package/dist/categories/orbits/specific-mechanical-energy.d.ts.map +1 -0
  157. package/dist/categories/orbits/specific-mechanical-energy.js +57 -0
  158. package/dist/categories/orbits/specific-mechanical-energy.js.map +1 -0
  159. package/dist/categories/orbits/vis-viva-speed.d.ts +42 -0
  160. package/dist/categories/orbits/vis-viva-speed.d.ts.map +1 -0
  161. package/dist/categories/orbits/vis-viva-speed.js +70 -0
  162. package/dist/categories/orbits/vis-viva-speed.js.map +1 -0
  163. package/dist/index.d.ts +20 -10
  164. package/dist/index.d.ts.map +1 -1
  165. package/dist/index.js +25 -10
  166. package/dist/index.js.map +1 -1
  167. package/package.json +77 -5
  168. package/dist/__tests__/compute-mean-anomaly.int.spec.d.ts +0 -2
  169. package/dist/__tests__/compute-mean-anomaly.int.spec.d.ts.map +0 -1
  170. package/dist/__tests__/compute-mean-anomaly.int.spec.js.map +0 -1
  171. package/dist/__tests__/true-anomaly-to-mean-anomaly.int.spec.d.ts +0 -2
  172. package/dist/__tests__/true-anomaly-to-mean-anomaly.int.spec.d.ts.map +0 -1
  173. package/dist/__tests__/true-anomaly-to-mean-anomaly.int.spec.js.map +0 -1
  174. package/dist/compute-angle.d.ts.map +0 -1
  175. package/dist/compute-angle.js.map +0 -1
  176. package/dist/compute-mean-anomaly.d.ts.map +0 -1
  177. package/dist/compute-mean-anomaly.js.map +0 -1
  178. package/dist/eccentric-to-true-anomaly.d.ts.map +0 -1
  179. package/dist/eccentric-to-true-anomaly.js.map +0 -1
  180. package/dist/solve-kepler-bisection.d.ts.map +0 -1
  181. package/dist/solve-kepler-bisection.js.map +0 -1
  182. package/dist/solve-kepler-high-eccentricity.d.ts.map +0 -1
  183. package/dist/solve-kepler-high-eccentricity.js.map +0 -1
  184. package/dist/solve-kepler-newton-raphson.d.ts.map +0 -1
  185. package/dist/solve-kepler-newton-raphson.js.map +0 -1
  186. package/dist/solve-kepler.d.ts.map +0 -1
  187. package/dist/solve-kepler.js.map +0 -1
  188. package/dist/true-anomaly-to-mean-anomaly.d.ts.map +0 -1
  189. package/dist/true-anomaly-to-mean-anomaly.js.map +0 -1
  190. package/dist/wrap-angle.d.ts.map +0 -1
  191. package/dist/wrap-angle.js.map +0 -1
@@ -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
@@ -37,7 +37,7 @@ import { Radians } from '@interstellar-tools/types';
37
37
  * ```
38
38
  *
39
39
  * @see [True Anomaly (Wikipedia)](https://en.wikipedia.org/wiki/True_anomaly)
40
- * @category Anomaly
40
+ * @group Anomalies
41
41
  */
42
42
  export declare const eccentricToTrueAnomaly: (E: Radians, e: number) => Radians;
43
43
  //# sourceMappingURL=eccentric-to-true-anomaly.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eccentric-to-true-anomaly.d.ts","sourceRoot":"","sources":["../../../src/categories/anomalies/eccentric-to-true-anomaly.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAEpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,eAAO,MAAM,sBAAsB,GAAI,GAAG,OAAO,EAAE,GAAG,MAAM,KAAG,OAiC9D,CAAC"}
@@ -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
@@ -36,7 +36,7 @@
36
36
  * ```
37
37
  *
38
38
  * @see [True Anomaly (Wikipedia)](https://en.wikipedia.org/wiki/True_anomaly)
39
- * @category Anomaly
39
+ * @group Anomalies
40
40
  */
41
41
  export const eccentricToTrueAnomaly = (E, e) => {
42
42
  // Validate eccentricity range
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eccentric-to-true-anomaly.js","sourceRoot":"","sources":["../../../src/categories/anomalies/eccentric-to-true-anomaly.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAU,EAAE,CAAS,EAAW,EAAE;IACvE,8BAA8B;IAC9B,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QACnB,MAAM,IAAI,UAAU,CAClB,yBAAyB,CAAC,6CAA6C,CACxE,CAAC;IACJ,CAAC;IAED,gCAAgC;IAChC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACZ,OAAO,CAAC,CAAC,CAAC,4DAA4D;IACxE,CAAC;IAED,iCAAiC;IACjC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACZ,OAAO,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,uCAAuC;IACtE,CAAC;IAED,0CAA0C;IAC1C,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,0CAA0C;IAEjE,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,OAAO,EAAE,CAAC;QACxC,OAAO,IAAI,CAAC,EAAE,CAAC,CAAC,+BAA+B;IACjD,CAAC;IAED,0EAA0E;IAC1E,OAAO,CACL,CAAC;QACD,IAAI,CAAC,KAAK,CACR,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,EAClC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CACnC,CACF,CAAC;AACJ,CAAC,CAAC"}
@@ -21,11 +21,11 @@ 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
28
- * import { computeMeanAnomaly } from './compute-mean-anomaly';
28
+ * import { meanToEccentricAnomaly } from './mean-to-eccentric-anomaly';
29
29
  *
30
30
  * const mars: CelestialBodyType = {
31
31
  * name: 'Mars',
@@ -35,13 +35,13 @@ import type { CelestialBodyType, Radians, TemporalInterface } from '@interstella
35
35
  * };
36
36
  *
37
37
  * const timeStep: TemporalInterface = { value: 1, unit: 'day' }; // 1-day step
38
- * const meanAnomaly = computeMeanAnomaly(mars, timeStep);
38
+ * const meanAnomaly = meanToEccentricAnomaly(mars, timeStep);
39
39
  * console.log(meanAnomaly); // Output: Computed mean anomaly in radians
40
40
  * ```
41
41
  *
42
42
  * @see [Mean Anomaly (Wikipedia)](https://en.wikipedia.org/wiki/Mean_anomaly)
43
43
  * @see [Orbital Mechanics (NASA)](https://solarsystem.nasa.gov/basics/chapter2-2/)
44
- * @category Anomaly
44
+ * @group Anomalies
45
45
  */
46
- export declare const computeMeanAnomaly: (body: CelestialBodyType, timeStep: TemporalInterface) => Radians;
47
- //# sourceMappingURL=compute-mean-anomaly.d.ts.map
46
+ export declare const meanToEccentricAnomaly: (body: CelestialBodyType, timeStep: TemporalInterface) => Radians;
47
+ //# sourceMappingURL=mean-to-eccentric-anomaly.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mean-to-eccentric-anomaly.d.ts","sourceRoot":"","sources":["../../../src/categories/anomalies/mean-to-eccentric-anomaly.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,iBAAiB,EACjB,OAAO,EACP,iBAAiB,EAClB,MAAM,2BAA2B,CAAC;AAQnC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAEH,eAAO,MAAM,sBAAsB,GACjC,MAAM,iBAAiB,EACvB,UAAU,iBAAiB,KAC1B,OAoCF,CAAC"}
@@ -1,19 +1,9 @@
1
1
  import { TWO_PI } from '@interstellar-tools/constants';
2
2
  import { convertTemporalUnit } from '@interstellar-tools/temporal';
3
- import { trueAnomalyToMeanAnomaly } from './true-anomaly-to-mean-anomaly';
4
- import { wrapAngle } from './wrap-angle';
5
- const EPSILON = 1e-15; // Increased tolerance for high eccentricity
6
- /**
7
- * Compares two floating-point numbers for equality within a tolerance.
8
- *
9
- * @param {number} a - First number to compare.
10
- * @param {number} b - Second number to compare.
11
- * @param {number} [epsilon=EPSILON] - Tolerance for floating-point precision.
12
- * @returns {boolean} `true` if values are approximately equal.
13
- */
14
- const areEqual = (a, b, epsilon = EPSILON) => {
15
- return Math.abs(a - b) < epsilon * Math.max(1, Math.abs(a), Math.abs(b));
16
- };
3
+ import { wrapAngle } from '../angle/wrap-angle';
4
+ import { trueToMeanAnomaly } from './true-to-mean-anomaly';
5
+ import { areEqual } from './utils/are-equal';
6
+ /* node:coverage disable */
17
7
  /**
18
8
  * Computes the **mean anomaly** ($M$) of a celestial body for a given time step.
19
9
  *
@@ -36,11 +26,11 @@ const areEqual = (a, b, epsilon = EPSILON) => {
36
26
  * @param {TemporalInterface} timeStep - The time step over which to compute the change.
37
27
  * @returns {Radians} The computed mean anomaly in radians.
38
28
  *
39
- * @throws {RangeError} If the body's eccentricity is outside the range $0 \leq e < 1$.
29
+ * @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
30
  *
41
31
  * @example
42
32
  * ```ts
43
- * import { computeMeanAnomaly } from './compute-mean-anomaly';
33
+ * import { meanToEccentricAnomaly } from './mean-to-eccentric-anomaly';
44
34
  *
45
35
  * const mars: CelestialBodyType = {
46
36
  * name: 'Mars',
@@ -50,15 +40,16 @@ const areEqual = (a, b, epsilon = EPSILON) => {
50
40
  * };
51
41
  *
52
42
  * const timeStep: TemporalInterface = { value: 1, unit: 'day' }; // 1-day step
53
- * const meanAnomaly = computeMeanAnomaly(mars, timeStep);
43
+ * const meanAnomaly = meanToEccentricAnomaly(mars, timeStep);
54
44
  * console.log(meanAnomaly); // Output: Computed mean anomaly in radians
55
45
  * ```
56
46
  *
57
47
  * @see [Mean Anomaly (Wikipedia)](https://en.wikipedia.org/wiki/Mean_anomaly)
58
48
  * @see [Orbital Mechanics (NASA)](https://solarsystem.nasa.gov/basics/chapter2-2/)
59
- * @category Anomaly
49
+ * @group Anomalies
60
50
  */
61
- export const computeMeanAnomaly = (body, timeStep) => {
51
+ /* node:coverage enable */
52
+ export const meanToEccentricAnomaly = (body, timeStep) => {
62
53
  const { e, angle, period } = body;
63
54
  if (e < 0 || e >= 1) {
64
55
  throw new RangeError(`Invalid eccentricity: ${e}. Eccentricity must be in the range [0, 1].`);
@@ -67,7 +58,7 @@ export const computeMeanAnomaly = (body, timeStep) => {
67
58
  const periodInDays = convertTemporalUnit(period, 'd').value;
68
59
  const meanMotion = TWO_PI / Math.abs(periodInDays);
69
60
  // Convert true anomaly (V) to mean anomaly (M0) if necessary
70
- const M0 = e === 0 ? angle : trueAnomalyToMeanAnomaly(angle, e);
61
+ const M0 = e === 0 ? angle : trueToMeanAnomaly(angle, e);
71
62
  if (timeStep.value === 0) {
72
63
  return M0;
73
64
  }
@@ -83,4 +74,4 @@ export const computeMeanAnomaly = (body, timeStep) => {
83
74
  }
84
75
  return newM;
85
76
  };
86
- //# sourceMappingURL=compute-mean-anomaly.js.map
77
+ //# sourceMappingURL=mean-to-eccentric-anomaly.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mean-to-eccentric-anomaly.js","sourceRoot":"","sources":["../../../src/categories/anomalies/mean-to-eccentric-anomaly.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAOnE,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,2BAA2B;AAC3B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,0BAA0B;AAC1B,MAAM,CAAC,MAAM,sBAAsB,GAAG,CACpC,IAAuB,EACvB,QAA2B,EAClB,EAAE;IACX,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IAElC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QACpB,MAAM,IAAI,UAAU,CAClB,yBAAyB,CAAC,6CAA6C,CACxE,CAAC;IACJ,CAAC;IAED,iDAAiD;IACjD,MAAM,YAAY,GAAG,mBAAmB,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC;IAC5D,MAAM,UAAU,GAAG,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IACnD,6DAA6D;IAC7D,MAAM,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,iBAAiB,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IAEzD,IAAI,QAAQ,CAAC,KAAK,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,2DAA2D;IAC3D,MAAM,WAAW,GAAG,IAAI,CAAC,CAAC,4BAA4B;IACtD,MAAM,iBAAiB,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,6CAA6C;IAC1F,MAAM,aAAa,GAAG,IAAI,CAAC,GAAG,CAC5B,WAAW,EACX,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,EAAE,iBAAiB,GAAG,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,CACrE,CAAC;IACF,wEAAwE;IACxE,MAAM,KAAK,GAAG,EAAE,CAAC;IAEjB,IAAI,IAAI,GAAG,SAAS,CAAC,EAAE,GAAG,UAAU,GAAG,aAAa,CAAC,CAAC;IAEtD,IAAI,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC;QAC1B,IAAI,GAAG,KAAK,CAAC;IACf,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC"}
@@ -46,12 +46,12 @@
46
46
  *
47
47
  * @example
48
48
  * ```ts
49
- * import { trueAnomalyToMeanAnomaly } from './true-anomaly-to-mean-anomaly';
49
+ * import { trueToMeanAnomaly } from './true-anomaly-to-mean-anomaly';
50
50
  *
51
51
  * // Example 1: Standard elliptical orbit
52
52
  * const V = Math.PI / 3; // 60 degrees in radians
53
53
  * const e = 0.1; // Eccentricity
54
- * console.log(trueAnomalyToMeanAnomaly(V, e)); // Output: Mean anomaly in radians
54
+ * console.log(trueToMeanAnomaly(V, e)); // Output: Mean anomaly in radians
55
55
  * ```
56
56
  *
57
57
  * @example
@@ -59,7 +59,7 @@
59
59
  * // Example 2: Retrograde motion handling
60
60
  * const V_retrograde = -Math.PI / 2; // -90 degrees
61
61
  * const e_retrograde = 0.2;
62
- * console.log(trueAnomalyToMeanAnomaly(V_retrograde, e_retrograde));
62
+ * console.log(trueToMeanAnomaly(V_retrograde, e_retrograde));
63
63
  * ```
64
64
  *
65
65
  * ---
@@ -68,7 +68,7 @@
68
68
  * @see [True Anomaly (Wikipedia)](https://en.wikipedia.org/wiki/True_anomaly)
69
69
  * @see [Mean Anomaly (Wikipedia)](https://en.wikipedia.org/wiki/Mean_anomaly)
70
70
  * @see [Orbital Eccentricity (Wikipedia)](https://en.wikipedia.org/wiki/Orbital_eccentricity)
71
- * @category Anomaly
71
+ * @group Anomalies
72
72
  */
73
- export declare const trueAnomalyToMeanAnomaly: (V: number, e: number) => number;
74
- //# sourceMappingURL=true-anomaly-to-mean-anomaly.d.ts.map
73
+ export declare const trueToMeanAnomaly: (V: number, e: number) => number;
74
+ //# sourceMappingURL=true-to-mean-anomaly.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"true-to-mean-anomaly.d.ts","sourceRoot":"","sources":["../../../src/categories/anomalies/true-to-mean-anomaly.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuEG;AACH,eAAO,MAAM,iBAAiB,GAAI,GAAG,MAAM,EAAE,GAAG,MAAM,KAAG,MAuBxD,CAAC"}
@@ -1,4 +1,4 @@
1
- import { wrapAngle } from './wrap-angle';
1
+ import { wrapAngle } from '../angle/wrap-angle';
2
2
  /**
3
3
  * Converts **true anomaly** ($\nu$) to **mean anomaly** ($M$) using Kepler's equation.
4
4
  *
@@ -47,12 +47,12 @@ import { wrapAngle } from './wrap-angle';
47
47
  *
48
48
  * @example
49
49
  * ```ts
50
- * import { trueAnomalyToMeanAnomaly } from './true-anomaly-to-mean-anomaly';
50
+ * import { trueToMeanAnomaly } from './true-anomaly-to-mean-anomaly';
51
51
  *
52
52
  * // Example 1: Standard elliptical orbit
53
53
  * const V = Math.PI / 3; // 60 degrees in radians
54
54
  * const e = 0.1; // Eccentricity
55
- * console.log(trueAnomalyToMeanAnomaly(V, e)); // Output: Mean anomaly in radians
55
+ * console.log(trueToMeanAnomaly(V, e)); // Output: Mean anomaly in radians
56
56
  * ```
57
57
  *
58
58
  * @example
@@ -60,7 +60,7 @@ import { wrapAngle } from './wrap-angle';
60
60
  * // Example 2: Retrograde motion handling
61
61
  * const V_retrograde = -Math.PI / 2; // -90 degrees
62
62
  * const e_retrograde = 0.2;
63
- * console.log(trueAnomalyToMeanAnomaly(V_retrograde, e_retrograde));
63
+ * console.log(trueToMeanAnomaly(V_retrograde, e_retrograde));
64
64
  * ```
65
65
  *
66
66
  * ---
@@ -69,9 +69,9 @@ import { wrapAngle } from './wrap-angle';
69
69
  * @see [True Anomaly (Wikipedia)](https://en.wikipedia.org/wiki/True_anomaly)
70
70
  * @see [Mean Anomaly (Wikipedia)](https://en.wikipedia.org/wiki/Mean_anomaly)
71
71
  * @see [Orbital Eccentricity (Wikipedia)](https://en.wikipedia.org/wiki/Orbital_eccentricity)
72
- * @category Anomaly
72
+ * @group Anomalies
73
73
  */
74
- export const trueAnomalyToMeanAnomaly = (V, e) => {
74
+ export const trueToMeanAnomaly = (V, e) => {
75
75
  if (e < 0 || e >= 1) {
76
76
  throw new RangeError('Eccentricity (e) must be in the range 0 ≤ e < 1 for elliptical orbits.');
77
77
  }
@@ -88,4 +88,4 @@ export const trueAnomalyToMeanAnomaly = (V, e) => {
88
88
  // Ensure M is always in the range [0, 2π]
89
89
  return wrapAngle(M);
90
90
  };
91
- //# sourceMappingURL=true-anomaly-to-mean-anomaly.js.map
91
+ //# sourceMappingURL=true-to-mean-anomaly.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"true-to-mean-anomaly.js","sourceRoot":"","sources":["../../../src/categories/anomalies/true-to-mean-anomaly.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAS,EAAE,CAAS,EAAU,EAAE;IAChE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QACpB,MAAM,IAAI,UAAU,CAClB,wEAAwE,CACzE,CAAC;IACJ,CAAC;IAED,8EAA8E;IAC9E,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IACjC,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAE5C,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,MAAM,EAAE,CAAC,CAAC,CAAC;IAE7C,yDAAyD;IACzD,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;QAChC,CAAC,GAAG,SAAS,CAAC,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC;IACvC,CAAC;IAED,oDAAoD;IACpD,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAE9B,0CAA0C;IAC1C,OAAO,SAAS,CAAC,CAAC,CAAC,CAAC;AACtB,CAAC,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Compares two floating-point numbers for equality within a tolerance.
3
+ *
4
+ * @param {number} a - First number to compare.
5
+ * @param {number} b - Second number to compare.
6
+ * @param {number} [epsilon=EPSILON] - Tolerance for floating-point precision.
7
+ * @returns {boolean} `true` if values are approximately equal.
8
+ */
9
+ export declare const areEqual: (a: number, b: number, epsilon?: number) => boolean;
10
+ //# sourceMappingURL=are-equal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"are-equal.d.ts","sourceRoot":"","sources":["../../../../src/categories/anomalies/utils/are-equal.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,eAAO,MAAM,QAAQ,GACnB,GAAG,MAAM,EACT,GAAG,MAAM,EACT,UAAS,MAAgB,KACxB,OAEF,CAAC"}
@@ -0,0 +1,13 @@
1
+ const EPSILON = 1e-15; // Increased tolerance for high eccentricity
2
+ /**
3
+ * Compares two floating-point numbers for equality within a tolerance.
4
+ *
5
+ * @param {number} a - First number to compare.
6
+ * @param {number} b - Second number to compare.
7
+ * @param {number} [epsilon=EPSILON] - Tolerance for floating-point precision.
8
+ * @returns {boolean} `true` if values are approximately equal.
9
+ */
10
+ export const areEqual = (a, b, epsilon = EPSILON) => {
11
+ return Math.abs(a - b) < epsilon * Math.max(1, Math.abs(a), Math.abs(b));
12
+ };
13
+ //# sourceMappingURL=are-equal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"are-equal.js","sourceRoot":"","sources":["../../../../src/categories/anomalies/utils/are-equal.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,4CAA4C;AAEnE;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CACtB,CAAS,EACT,CAAS,EACT,UAAkB,OAAO,EAChB,EAAE;IACX,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AAC3E,CAAC,CAAC"}
@@ -0,0 +1,66 @@
1
+ import type { Vector3DTupleType } from '@interstellar-tools/types';
2
+ /**
3
+ * Gravitational **acceleration** of body 1 due to body 2 (vector, m/s²).
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
+ * **Acceleration field**
14
+ *
15
+ * $$
16
+ * \mathbf a_{1\leftarrow2}
17
+ * = \frac{\mathbf F_{1\leftarrow2}}{m_1}
18
+ * = G\,\frac{m_2}{r^2}\,\hat{\mathbf r}
19
+ * $$
20
+ *
21
+ * **Units**
22
+ * - Inputs: masses in **kg**, positions in **m**, ($ G $) in **m³·kg⁻¹·s⁻²**.
23
+ * - Output: acceleration in **m/s²**.
24
+ *
25
+ * ::: info
26
+ *
27
+ * - Implemented via `gravitationalForce(1, m2, r1, r2, G)`, so the returned vector equals the force on a **1 kg** test mass (i.e., the acceleration).
28
+ * - Direction points **from body 1 toward body 2**: ($ \hat{\mathbf r} $).
29
+ *
30
+ * :::
31
+ *
32
+ * **Invariants (within FP tolerance)**
33
+ * - `||a|| = G*m2/r^2`
34
+ * - `a = ||a|| * r̂`
35
+ *
36
+ * @param {number} m2 Mass of body 2 (kg).
37
+ * @param {Vector3DTupleType} r1 Position of body 1 `[x, y, z]` in meters.
38
+ * @param {Vector3DTupleType} r2 Position of body 2 `[x, y, z]` in meters.
39
+ * @param {number} [G=G_SI] Gravitational constant.
40
+ * @returns {Vector3DTupleType} Acceleration of body 1 due to body 2 (m/s²).
41
+ *
42
+ * @example
43
+ * ```ts
44
+ * // Acceleration of a satellite due to Earth at ~7000 km from Earth's center
45
+ * const mSat = 500; // kg (any value; a is independent of mSat)
46
+ * const mEarth = 5.972e24; // kg
47
+ * const rSat: [number, number, number] = [7.0e6, 0, 0]; // m
48
+ * const rEarth: [number, number, number] = [0, 0, 0];
49
+ *
50
+ * const a = accelerationOn1By2(mSat, mEarth, rSat, rEarth);
51
+ * // ≈ [-8.14, 0, 0] m/s² (toward Earth)
52
+ * ```
53
+ *
54
+ * @example
55
+ * ```ts
56
+ * // Derive force from acceleration (F = m1 * a)
57
+ * const m1 = 1200; // kg spacecraft
58
+ * const a = accelerationOn1By2(m1, mEarth, rSat, rEarth);
59
+ * const F: [number, number, number] = [a[0]*m1, a[1]*m1, a[2]*m1]; // newtons
60
+ * ```
61
+ *
62
+ * @see https://en.wikipedia.org/wiki/Newton%27s_law_of_universal_gravitation
63
+ * @group Gravity
64
+ */
65
+ export declare const accelerationOn1By2: (m2: number, r1: Vector3DTupleType, r2: Vector3DTupleType, G?: number) => Vector3DTupleType;
66
+ //# sourceMappingURL=acceleration-on1-by2.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"acceleration-on1-by2.d.ts","sourceRoot":"","sources":["../../../src/categories/gravity/acceleration-on1-by2.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAInE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8DG;AACH,eAAO,MAAM,kBAAkB,GAC7B,IAAI,MAAM,EACV,IAAI,iBAAiB,EACrB,IAAI,iBAAiB,EACrB,IAAG,MAAa,KACf,iBASF,CAAC"}
@@ -0,0 +1,75 @@
1
+ import { G_SI } from '@interstellar-tools/constants';
2
+ import { gravitationalForce } from './gravitational-force';
3
+ /**
4
+ * Gravitational **acceleration** of body 1 due to body 2 (vector, m/s²).
5
+ *
6
+ * **Definitions**
7
+ *
8
+ * $$
9
+ * \mathbf r=\mathbf r_2-\mathbf r_1,\quad
10
+ * r=\lVert\mathbf r\rVert,\quad
11
+ * \hat{\mathbf r}=\frac{\mathbf r}{r}
12
+ * $$
13
+ *
14
+ * **Acceleration field**
15
+ *
16
+ * $$
17
+ * \mathbf a_{1\leftarrow2}
18
+ * = \frac{\mathbf F_{1\leftarrow2}}{m_1}
19
+ * = G\,\frac{m_2}{r^2}\,\hat{\mathbf r}
20
+ * $$
21
+ *
22
+ * **Units**
23
+ * - Inputs: masses in **kg**, positions in **m**, ($ G $) in **m³·kg⁻¹·s⁻²**.
24
+ * - Output: acceleration in **m/s²**.
25
+ *
26
+ * ::: info
27
+ *
28
+ * - Implemented via `gravitationalForce(1, m2, r1, r2, G)`, so the returned vector equals the force on a **1 kg** test mass (i.e., the acceleration).
29
+ * - Direction points **from body 1 toward body 2**: ($ \hat{\mathbf r} $).
30
+ *
31
+ * :::
32
+ *
33
+ * **Invariants (within FP tolerance)**
34
+ * - `||a|| = G*m2/r^2`
35
+ * - `a = ||a|| * r̂`
36
+ *
37
+ * @param {number} m2 Mass of body 2 (kg).
38
+ * @param {Vector3DTupleType} r1 Position of body 1 `[x, y, z]` in meters.
39
+ * @param {Vector3DTupleType} r2 Position of body 2 `[x, y, z]` in meters.
40
+ * @param {number} [G=G_SI] Gravitational constant.
41
+ * @returns {Vector3DTupleType} Acceleration of body 1 due to body 2 (m/s²).
42
+ *
43
+ * @example
44
+ * ```ts
45
+ * // Acceleration of a satellite due to Earth at ~7000 km from Earth's center
46
+ * const mSat = 500; // kg (any value; a is independent of mSat)
47
+ * const mEarth = 5.972e24; // kg
48
+ * const rSat: [number, number, number] = [7.0e6, 0, 0]; // m
49
+ * const rEarth: [number, number, number] = [0, 0, 0];
50
+ *
51
+ * const a = accelerationOn1By2(mSat, mEarth, rSat, rEarth);
52
+ * // ≈ [-8.14, 0, 0] m/s² (toward Earth)
53
+ * ```
54
+ *
55
+ * @example
56
+ * ```ts
57
+ * // Derive force from acceleration (F = m1 * a)
58
+ * const m1 = 1200; // kg spacecraft
59
+ * const a = accelerationOn1By2(m1, mEarth, rSat, rEarth);
60
+ * const F: [number, number, number] = [a[0]*m1, a[1]*m1, a[2]*m1]; // newtons
61
+ * ```
62
+ *
63
+ * @see https://en.wikipedia.org/wiki/Newton%27s_law_of_universal_gravitation
64
+ * @group Gravity
65
+ */
66
+ export const accelerationOn1By2 = (m2, r1, r2, G = G_SI) => {
67
+ const { direction, magnitude } = gravitationalForce(1, m2, r1, r2, G); // |F| on 1 kg == |a|
68
+ const a = [
69
+ direction[0] * magnitude,
70
+ direction[1] * magnitude,
71
+ direction[2] * magnitude
72
+ ];
73
+ return a;
74
+ };
75
+ //# sourceMappingURL=acceleration-on1-by2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"acceleration-on1-by2.js","sourceRoot":"","sources":["../../../src/categories/gravity/acceleration-on1-by2.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,+BAA+B,CAAC;AAGrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAE3D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8DG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAChC,EAAU,EACV,EAAqB,EACrB,EAAqB,EACrB,IAAY,IAAI,EACG,EAAE;IACrB,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,kBAAkB,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,qBAAqB;IAC5F,MAAM,CAAC,GAAsB;QAC3B,SAAS,CAAC,CAAC,CAAC,GAAG,SAAS;QACxB,SAAS,CAAC,CAAC,CAAC,GAAG,SAAS;QACxB,SAAS,CAAC,CAAC,CAAC,GAAG,SAAS;KACzB,CAAC;IAEF,OAAO,CAAC,CAAC;AACX,CAAC,CAAC"}
@@ -0,0 +1,87 @@
1
+ import type { Vector3DTupleType } from '@interstellar-tools/types';
2
+ /**
3
+ * Gravitational **force vector** on body 1 due to body 2 (newtons, N).
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
+ * **Newton's law (vector form)**
14
+ *
15
+ * $$
16
+ * \mathbf F_{1\leftarrow2}
17
+ * = G\,\frac{m_1 m_2}{r^2}\,\hat{\mathbf r}
18
+ * $$
19
+ *
20
+ * **Magnitude & Components**
21
+ *
22
+ * $$
23
+ * \lVert\mathbf F\rVert=G\,\frac{m_1 m_2}{r^2},\qquad
24
+ * \mathbf F=\langle F_x,F_y,F_z\rangle=\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 (context)**
34
+ *
35
+ * $$
36
+ * \mathbf F_{1\leftarrow2}=-\,\mathbf F_{2\leftarrow1}
37
+ * $$
38
+ *
39
+ * **Units**
40
+ * - Inputs: masses in **kg**, positions in **m**, ($ G $) in **m³·kg⁻¹·s⁻²**.
41
+ * - Output: force vector in **newtons (N)**.
42
+ *
43
+ * ::: info
44
+ *
45
+ * - The returned vector points **from body 1 toward body 2** (i.e., along ($ \hat{\mathbf r} $)).
46
+ * - Internally delegates to `gravitationalForce(m1, m2, r1, r2, G)` and returns its
47
+ * direction-scaled magnitude as a 3-tuple.
48
+ * - For acceleration instead of force, use `accelerationOn1By2` or compute ($ \mathbf a=\mathbf F/m_1 $).
49
+ *
50
+ * :::
51
+ *
52
+ * **Invariants (within FP tolerance)**
53
+ * - `||F|| = G*m1*m2/r^2`
54
+ * - `F = ||F|| * r̂`
55
+ *
56
+ * @param {number} m1 Mass of body 1 (kg).
57
+ * @param {number} m2 Mass of body 2 (kg).
58
+ * @param {Vector3DTupleType} r1 Position of body 1 `[x, y, z]` in meters.
59
+ * @param {Vector3DTupleType} r2 Position of body 2 `[x, y, z]` in meters.
60
+ * @param {number} [G=G_SI] Gravitational constant.
61
+ * @returns {Vector3DTupleType} Force on body 1 due to body 2, in newtons `[Fx, Fy, Fz]`.
62
+ *
63
+ * @throws {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error | Error} Propagated from `gravitationalForce` if inputs are invalid (non-finite/negative masses, coincident positions ($ r=0 $), or non-positive ($ G $)).
64
+ *
65
+ * @example
66
+ * ```ts
67
+ * // Earth–Sun at ~1 AU (force on Earth due to Sun)
68
+ * const mEarth = 5.972e24; // kg
69
+ * const mSun = 1.9885e30; // kg
70
+ * const rEarth: [number, number, number] = [0, 0, 0];
71
+ * const rSun : [number, number, number] = [1.495978707e11, 0, 0]; // m
72
+ *
73
+ * const F = forceOn1By2(mEarth, mSun, rEarth, rSun); // N
74
+ * const Fmag = Math.hypot(F[0], F[1], F[2]); // ≈ 3.54e22 N
75
+ * ```
76
+ *
77
+ * @example
78
+ * ```ts
79
+ * // Derive acceleration from the returned force: a = F / m1
80
+ * const a: [number, number, number] = [F[0]/mEarth, F[1]/mEarth, F[2]/mEarth]; // m/s^2
81
+ * ```
82
+ *
83
+ * @see https://en.wikipedia.org/wiki/Newton%27s_law_of_universal_gravitation
84
+ * @group Gravity
85
+ */
86
+ export declare const forceOn1By2: (m1: number, m2: number, r1: Vector3DTupleType, r2: Vector3DTupleType, G?: number) => Vector3DTupleType;
87
+ //# sourceMappingURL=force-on1-by2.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"force-on1-by2.d.ts","sourceRoot":"","sources":["../../../src/categories/gravity/force-on1-by2.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAInE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmFG;AACH,eAAO,MAAM,WAAW,GACtB,IAAI,MAAM,EACV,IAAI,MAAM,EACV,IAAI,iBAAiB,EACrB,IAAI,iBAAiB,EACrB,IAAG,MAAa,KACf,iBASF,CAAC"}
@@ -0,0 +1,96 @@
1
+ import { G_SI } from '@interstellar-tools/constants';
2
+ import { gravitationalForce } from './gravitational-force';
3
+ /**
4
+ * Gravitational **force vector** on body 1 due to body 2 (newtons, N).
5
+ *
6
+ * **Definitions**
7
+ *
8
+ * $$
9
+ * \mathbf r=\mathbf r_2-\mathbf r_1,\quad
10
+ * r=\lVert\mathbf r\rVert,\quad
11
+ * \hat{\mathbf r}=\frac{\mathbf r}{r}
12
+ * $$
13
+ *
14
+ * **Newton's law (vector form)**
15
+ *
16
+ * $$
17
+ * \mathbf F_{1\leftarrow2}
18
+ * = G\,\frac{m_1 m_2}{r^2}\,\hat{\mathbf r}
19
+ * $$
20
+ *
21
+ * **Magnitude & Components**
22
+ *
23
+ * $$
24
+ * \lVert\mathbf F\rVert=G\,\frac{m_1 m_2}{r^2},\qquad
25
+ * \mathbf F=\langle F_x,F_y,F_z\rangle=\lVert\mathbf F\rVert\,\hat{\mathbf r}
26
+ * $$
27
+ *
28
+ * $$
29
+ * F_x=\lVert\mathbf F\rVert\,\hat r_x,\quad
30
+ * F_y=\lVert\mathbf F\rVert\,\hat r_y,\quad
31
+ * F_z=\lVert\mathbf F\rVert\,\hat r_z
32
+ * $$
33
+ *
34
+ * **Newton's 3rd law (context)**
35
+ *
36
+ * $$
37
+ * \mathbf F_{1\leftarrow2}=-\,\mathbf F_{2\leftarrow1}
38
+ * $$
39
+ *
40
+ * **Units**
41
+ * - Inputs: masses in **kg**, positions in **m**, ($ G $) in **m³·kg⁻¹·s⁻²**.
42
+ * - Output: force vector in **newtons (N)**.
43
+ *
44
+ * ::: info
45
+ *
46
+ * - The returned vector points **from body 1 toward body 2** (i.e., along ($ \hat{\mathbf r} $)).
47
+ * - Internally delegates to `gravitationalForce(m1, m2, r1, r2, G)` and returns its
48
+ * direction-scaled magnitude as a 3-tuple.
49
+ * - For acceleration instead of force, use `accelerationOn1By2` or compute ($ \mathbf a=\mathbf F/m_1 $).
50
+ *
51
+ * :::
52
+ *
53
+ * **Invariants (within FP tolerance)**
54
+ * - `||F|| = G*m1*m2/r^2`
55
+ * - `F = ||F|| * r̂`
56
+ *
57
+ * @param {number} m1 Mass of body 1 (kg).
58
+ * @param {number} m2 Mass of body 2 (kg).
59
+ * @param {Vector3DTupleType} r1 Position of body 1 `[x, y, z]` in meters.
60
+ * @param {Vector3DTupleType} r2 Position of body 2 `[x, y, z]` in meters.
61
+ * @param {number} [G=G_SI] Gravitational constant.
62
+ * @returns {Vector3DTupleType} Force on body 1 due to body 2, in newtons `[Fx, Fy, Fz]`.
63
+ *
64
+ * @throws {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error | Error} Propagated from `gravitationalForce` if inputs are invalid (non-finite/negative masses, coincident positions ($ r=0 $), or non-positive ($ G $)).
65
+ *
66
+ * @example
67
+ * ```ts
68
+ * // Earth–Sun at ~1 AU (force on Earth due to Sun)
69
+ * const mEarth = 5.972e24; // kg
70
+ * const mSun = 1.9885e30; // kg
71
+ * const rEarth: [number, number, number] = [0, 0, 0];
72
+ * const rSun : [number, number, number] = [1.495978707e11, 0, 0]; // m
73
+ *
74
+ * const F = forceOn1By2(mEarth, mSun, rEarth, rSun); // N
75
+ * const Fmag = Math.hypot(F[0], F[1], F[2]); // ≈ 3.54e22 N
76
+ * ```
77
+ *
78
+ * @example
79
+ * ```ts
80
+ * // Derive acceleration from the returned force: a = F / m1
81
+ * const a: [number, number, number] = [F[0]/mEarth, F[1]/mEarth, F[2]/mEarth]; // m/s^2
82
+ * ```
83
+ *
84
+ * @see https://en.wikipedia.org/wiki/Newton%27s_law_of_universal_gravitation
85
+ * @group Gravity
86
+ */
87
+ export const forceOn1By2 = (m1, m2, r1, r2, G = G_SI) => {
88
+ const { direction, magnitude } = gravitationalForce(m1, m2, r1, r2, G); // |F|
89
+ const F = [
90
+ direction[0] * magnitude,
91
+ direction[1] * magnitude,
92
+ direction[2] * magnitude
93
+ ];
94
+ return F;
95
+ };
96
+ //# sourceMappingURL=force-on1-by2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"force-on1-by2.js","sourceRoot":"","sources":["../../../src/categories/gravity/force-on1-by2.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,+BAA+B,CAAC;AAGrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAE3D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmFG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CACzB,EAAU,EACV,EAAU,EACV,EAAqB,EACrB,EAAqB,EACrB,IAAY,IAAI,EACG,EAAE;IACrB,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,kBAAkB,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM;IAC9E,MAAM,CAAC,GAAsB;QAC3B,SAAS,CAAC,CAAC,CAAC,GAAG,SAAS;QACxB,SAAS,CAAC,CAAC,CAAC,GAAG,SAAS;QACxB,SAAS,CAAC,CAAC,CAAC,GAAG,SAAS;KACzB,CAAC;IAEF,OAAO,CAAC,CAAC;AACX,CAAC,CAAC"}