@interstellar-tools/equations 0.60.1 → 0.61.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.
@@ -1,62 +1,51 @@
1
- import type { CelestialBodyType, Radians, TimeStepInterface } from '@interstellar-tools/types';
1
+ import type { OrbitInterface, Radians, TimeStepInterface } from '@interstellar-tools/types';
2
2
  /**
3
- * Computes the orbital angle (true anomaly, $ν$) of a celestial body for a given date and time step.
3
+ * Advances a body along its orbit by one time step and returns its new
4
+ * **true anomaly** ($\nu$).
4
5
  *
5
- * **Mathematical Explanation:**
6
+ * The orbit's `angle` is the starting true anomaly. There is no date input:
7
+ * call this once per frame or step, and feed the result back in as the next
8
+ * `angle` to move the body over time.
6
9
  *
7
- * This function determines the **true anomaly** ($ν$) based on the time elapsed since the
8
- * **J2000 epoch** (January 1, 2000) and the provided time step. The calculation follows these steps:
10
+ * **Step 1: Mean anomaly after the time step ($M$)**
9
11
  *
10
- * **Step 1: Compute Time Elapsed Since J2000**
11
- *
12
- * The number of days since **J2000** is computed as:
13
- * $$ \Delta T = \frac{t - t_{J2000}}{\text{MILLISECONDS\_PER\_DAY}} $$
12
+ * Done by {@link advanceMeanAnomaly}:
13
+ * $$ M = M_0 + n \cdot \Delta t, \qquad n = \frac{2\pi}{|P|} $$
14
14
  * where:
15
- * - $t$ is the current date in milliseconds.
16
- * - $t_{J2000}$ is **J2000** (2000-01-01T00:00:00Z).
17
- * - **MILLISECONDS_PER_DAY** is the number of milliseconds in one day.
18
- *
19
- * **Step 2: Compute the Mean Anomaly ($M$)**
15
+ * - $M_0$ is the mean anomaly at the start, converted from the true anomaly
16
+ * `angle` (equal to it when $e = 0$).
17
+ * - $n$ is the mean motion, from the period $P$ converted to days. The sign of
18
+ * $P$ is ignored, so the angle always increases.
19
+ * - $\Delta t$ is `timeStep.value` in days, clamped to at least $10^{-5}$ days
20
+ * and at most $10\,|P|$ ($|P|$ when $e \geq 0.9$).
20
21
  *
21
- * The **mean anomaly** is calculated as:
22
- * $$ M = M_0 + n \cdot (\Delta T + \text{timeStep}) $$
23
- * where:
24
- * - $M_0$ is the initial mean anomaly at **J2000**.
25
- * - $n$ is the mean motion (orbital angular velocity).
26
- * - $\text{timeStep}$ is the time step in days.
22
+ * The result is wrapped to $[0, 2\pi)$.
27
23
  *
28
- * **Step 3: Solve Kepler’s Equation for Eccentric Anomaly ($E$)**
24
+ * **Step 2: Solve Kepler's equation for the eccentric anomaly ($E$)**
29
25
  *
30
- * Kepler’s equation:
31
26
  * $$ M = E - e \sin(E) $$
32
- * is solved numerically to obtain the **eccentric anomaly** ($E$).
33
- *
34
- * **Step 4: Convert Eccentric Anomaly ($E$) to True Anomaly ($ν$)**
27
+ * is solved numerically by {@link solveKepler}.
35
28
  *
36
- * Using the relation:
37
- * $$ ν = 2 \tan^{-1} \left( \sqrt{\frac{1+e}{1-e}} \tan\left(\frac{E}{2}\right) \right) $$
29
+ * **Step 3: Convert the eccentric anomaly to the true anomaly ($\nu$)**
38
30
  *
39
- * **Step 5: Adjust the True Anomaly for Certain Bodies**
40
- * - For **comets**, the final **true anomaly** is adjusted by subtracting the **eccentricity** ($e$).
41
- * - For **stars and other celestial objects**, the computed **true anomaly** is used directly.
31
+ * Done by {@link eccentricToTrueAnomaly}:
32
+ * $$ \nu = 2 \tan^{-1} \left( \sqrt{\frac{1+e}{1-e}} \tan\left(\frac{E}{2}\right) \right) $$
42
33
  *
43
- * @param {CelestialBodyType} body - The celestial body for which to compute the true anomaly.
44
- * @param {TimeStepInterface} timeStep - The time step in days since the last frame.
45
- * @returns {Radians} The computed true anomaly in radians.
34
+ * @param {Pick<OrbitInterface, 'e' | 'angle' | 'period'>} orbit - The body's orbit, for example `body.orbit` from a dataset.
35
+ * @param {TimeStepInterface} timeStep - How far to advance, in days.
36
+ * @returns {Radians} The true anomaly after the time step, in radians.
37
+ * @throws {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError | RangeError} If the orbit's eccentricity is outside $0 \leq e < 1$.
46
38
  *
47
39
  * @example
48
40
  * ```ts
41
+ * import { PLANETS } from '@interstellar-tools/constants';
49
42
  * import { computeAngle } from '@interstellar-tools/equations';
50
43
  *
51
- * const earth: CelestialBodyType = {
52
- * name: 'Earth',
53
- * e: 0.0167, // Orbital eccentricity
54
- * angle: 0, // Initial angle
55
- * };
44
+ * const earth = PLANETS.find((planet) => planet.id === 'earth')!;
45
+ * const timeStep: TimeStepInterface = { value: 1, unit: 'd' };
56
46
  *
57
- * const timeStep: TimeStepInterface = { days: 1 }; // Time step of 1 day
58
- * const angle: Radians = computeAngle(earth, timeStep);
59
- * console.log(angle); // Output: Computed true anomaly in radians
47
+ * // Earth's true anomaly one day after its dataset position
48
+ * const angle: Radians = computeAngle(earth.orbit!, timeStep);
60
49
  * ```
61
50
  *
62
51
  * @see [Kepler's Equation (Wikipedia)](https://en.wikipedia.org/wiki/Kepler%27s_equation)
@@ -65,5 +54,5 @@ import type { CelestialBodyType, Radians, TimeStepInterface } from '@interstella
65
54
  * @see [Orbital Mechanics (NASA)](https://solarsystem.nasa.gov/basics/chapter2-2/)
66
55
  * @group Angles
67
56
  */
68
- export declare const computeAngle: (body: CelestialBodyType, timeStep: TimeStepInterface) => Radians;
57
+ export declare const computeAngle: (orbit: Pick<OrbitInterface, "e" | "angle" | "period">, timeStep: TimeStepInterface) => Radians;
69
58
  //# sourceMappingURL=compute-angle.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"compute-angle.d.ts","sourceRoot":"","sources":["../../../src/categories/angle/compute-angle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EACjB,OAAO,EACP,iBAAiB,EAClB,MAAM,2BAA2B,CAAC;AAMnC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiEG;AACH,eAAO,MAAM,YAAY,GACvB,MAAM,iBAAiB,EACvB,UAAU,iBAAiB,KAC1B,OASF,CAAC"}
1
+ {"version":3,"file":"compute-angle.d.ts","sourceRoot":"","sources":["../../../src/categories/angle/compute-angle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,OAAO,EACP,iBAAiB,EAClB,MAAM,2BAA2B,CAAC;AAMnC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,eAAO,MAAM,YAAY,GACvB,OAAO,IAAI,CAAC,cAAc,EAAE,GAAG,GAAG,OAAO,GAAG,QAAQ,CAAC,EACrD,UAAU,iBAAiB,KAC1B,OASF,CAAC"}
@@ -1,64 +1,53 @@
1
+ import { advanceMeanAnomaly } from '../anomalies/advance-mean-anomaly.js';
1
2
  import { eccentricToTrueAnomaly } from '../anomalies/eccentric-to-true-anomaly.js';
2
- import { meanToEccentricAnomaly } from '../anomalies/mean-to-eccentric-anomaly.js';
3
3
  import { solveKepler } from '../kepler/solve-kepler.js';
4
4
  /**
5
- * Computes the orbital angle (true anomaly, $ν$) of a celestial body for a given date and time step.
5
+ * Advances a body along its orbit by one time step and returns its new
6
+ * **true anomaly** ($\nu$).
6
7
  *
7
- * **Mathematical Explanation:**
8
+ * The orbit's `angle` is the starting true anomaly. There is no date input:
9
+ * call this once per frame or step, and feed the result back in as the next
10
+ * `angle` to move the body over time.
8
11
  *
9
- * This function determines the **true anomaly** ($ν$) based on the time elapsed since the
10
- * **J2000 epoch** (January 1, 2000) and the provided time step. The calculation follows these steps:
12
+ * **Step 1: Mean anomaly after the time step ($M$)**
11
13
  *
12
- * **Step 1: Compute Time Elapsed Since J2000**
13
- *
14
- * The number of days since **J2000** is computed as:
15
- * $$ \Delta T = \frac{t - t_{J2000}}{\text{MILLISECONDS\_PER\_DAY}} $$
14
+ * Done by {@link advanceMeanAnomaly}:
15
+ * $$ M = M_0 + n \cdot \Delta t, \qquad n = \frac{2\pi}{|P|} $$
16
16
  * where:
17
- * - $t$ is the current date in milliseconds.
18
- * - $t_{J2000}$ is **J2000** (2000-01-01T00:00:00Z).
19
- * - **MILLISECONDS_PER_DAY** is the number of milliseconds in one day.
20
- *
21
- * **Step 2: Compute the Mean Anomaly ($M$)**
17
+ * - $M_0$ is the mean anomaly at the start, converted from the true anomaly
18
+ * `angle` (equal to it when $e = 0$).
19
+ * - $n$ is the mean motion, from the period $P$ converted to days. The sign of
20
+ * $P$ is ignored, so the angle always increases.
21
+ * - $\Delta t$ is `timeStep.value` in days, clamped to at least $10^{-5}$ days
22
+ * and at most $10\,|P|$ ($|P|$ when $e \geq 0.9$).
22
23
  *
23
- * The **mean anomaly** is calculated as:
24
- * $$ M = M_0 + n \cdot (\Delta T + \text{timeStep}) $$
25
- * where:
26
- * - $M_0$ is the initial mean anomaly at **J2000**.
27
- * - $n$ is the mean motion (orbital angular velocity).
28
- * - $\text{timeStep}$ is the time step in days.
24
+ * The result is wrapped to $[0, 2\pi)$.
29
25
  *
30
- * **Step 3: Solve Kepler’s Equation for Eccentric Anomaly ($E$)**
26
+ * **Step 2: Solve Kepler's equation for the eccentric anomaly ($E$)**
31
27
  *
32
- * Kepler’s equation:
33
28
  * $$ M = E - e \sin(E) $$
34
- * is solved numerically to obtain the **eccentric anomaly** ($E$).
35
- *
36
- * **Step 4: Convert Eccentric Anomaly ($E$) to True Anomaly ($ν$)**
29
+ * is solved numerically by {@link solveKepler}.
37
30
  *
38
- * Using the relation:
39
- * $$ ν = 2 \tan^{-1} \left( \sqrt{\frac{1+e}{1-e}} \tan\left(\frac{E}{2}\right) \right) $$
31
+ * **Step 3: Convert the eccentric anomaly to the true anomaly ($\nu$)**
40
32
  *
41
- * **Step 5: Adjust the True Anomaly for Certain Bodies**
42
- * - For **comets**, the final **true anomaly** is adjusted by subtracting the **eccentricity** ($e$).
43
- * - For **stars and other celestial objects**, the computed **true anomaly** is used directly.
33
+ * Done by {@link eccentricToTrueAnomaly}:
34
+ * $$ \nu = 2 \tan^{-1} \left( \sqrt{\frac{1+e}{1-e}} \tan\left(\frac{E}{2}\right) \right) $$
44
35
  *
45
- * @param {CelestialBodyType} body - The celestial body for which to compute the true anomaly.
46
- * @param {TimeStepInterface} timeStep - The time step in days since the last frame.
47
- * @returns {Radians} The computed true anomaly in radians.
36
+ * @param {Pick<OrbitInterface, 'e' | 'angle' | 'period'>} orbit - The body's orbit, for example `body.orbit` from a dataset.
37
+ * @param {TimeStepInterface} timeStep - How far to advance, in days.
38
+ * @returns {Radians} The true anomaly after the time step, in radians.
39
+ * @throws {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError | RangeError} If the orbit's eccentricity is outside $0 \leq e < 1$.
48
40
  *
49
41
  * @example
50
42
  * ```ts
43
+ * import { PLANETS } from '@interstellar-tools/constants';
51
44
  * import { computeAngle } from '@interstellar-tools/equations';
52
45
  *
53
- * const earth: CelestialBodyType = {
54
- * name: 'Earth',
55
- * e: 0.0167, // Orbital eccentricity
56
- * angle: 0, // Initial angle
57
- * };
46
+ * const earth = PLANETS.find((planet) => planet.id === 'earth')!;
47
+ * const timeStep: TimeStepInterface = { value: 1, unit: 'd' };
58
48
  *
59
- * const timeStep: TimeStepInterface = { days: 1 }; // Time step of 1 day
60
- * const angle: Radians = computeAngle(earth, timeStep);
61
- * console.log(angle); // Output: Computed true anomaly in radians
49
+ * // Earth's true anomaly one day after its dataset position
50
+ * const angle: Radians = computeAngle(earth.orbit!, timeStep);
62
51
  * ```
63
52
  *
64
53
  * @see [Kepler's Equation (Wikipedia)](https://en.wikipedia.org/wiki/Kepler%27s_equation)
@@ -67,13 +56,13 @@ import { solveKepler } from '../kepler/solve-kepler.js';
67
56
  * @see [Orbital Mechanics (NASA)](https://solarsystem.nasa.gov/basics/chapter2-2/)
68
57
  * @group Angles
69
58
  */
70
- export const computeAngle = (body, timeStep) => {
59
+ export const computeAngle = (orbit, timeStep) => {
71
60
  // Compute mean anomaly (M) with time step
72
- const M = meanToEccentricAnomaly(body, timeStep);
61
+ const M = advanceMeanAnomaly(orbit, timeStep);
73
62
  // Solve Kepler's equation for eccentric anomaly (E)
74
- const E = solveKepler(M, body.e);
63
+ const E = solveKepler(M, orbit.e);
75
64
  // Convert eccentric anomaly (E) to true anomaly (ν)
76
- const V = eccentricToTrueAnomaly(E, body.e);
65
+ const V = eccentricToTrueAnomaly(E, orbit.e);
77
66
  return V;
78
67
  };
79
68
  //# sourceMappingURL=compute-angle.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"compute-angle.js","sourceRoot":"","sources":["../../../src/categories/angle/compute-angle.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,sBAAsB,EAAE,MAAM,2CAA2C,CAAC;AACnF,OAAO,EAAE,sBAAsB,EAAE,MAAM,2CAA2C,CAAC;AACnF,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,IAAuB,EACvB,QAA2B,EAClB,EAAE;IACX,0CAA0C;IAC1C,MAAM,CAAC,GAAY,sBAAsB,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IAC1D,oDAAoD;IACpD,MAAM,CAAC,GAAY,WAAW,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;IAC1C,oDAAoD;IACpD,MAAM,CAAC,GAAY,sBAAsB,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;IAErD,OAAO,CAAC,CAAC;AACX,CAAC,CAAC"}
1
+ {"version":3,"file":"compute-angle.js","sourceRoot":"","sources":["../../../src/categories/angle/compute-angle.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAC1E,OAAO,EAAE,sBAAsB,EAAE,MAAM,2CAA2C,CAAC;AACnF,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,KAAqD,EACrD,QAA2B,EAClB,EAAE;IACX,0CAA0C;IAC1C,MAAM,CAAC,GAAY,kBAAkB,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IACvD,oDAAoD;IACpD,MAAM,CAAC,GAAY,WAAW,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;IAC3C,oDAAoD;IACpD,MAAM,CAAC,GAAY,sBAAsB,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;IAEtD,OAAO,CAAC,CAAC;AACX,CAAC,CAAC"}
@@ -0,0 +1,50 @@
1
+ import type { OrbitInterface, Radians, TemporalInterface } from '@interstellar-tools/types';
2
+ /**
3
+ * Advances an orbit by a time step and returns its new **mean anomaly** ($M$).
4
+ *
5
+ * The orbit's `angle` (true anomaly) is the starting point. To get the eccentric
6
+ * anomaly from the result, pass it to {@link solveKepler}.
7
+ *
8
+ * **Mathematical Explanation:**
9
+ *
10
+ * The **mean anomaly** is a measure of the position of an orbiting body as if it moved
11
+ * with uniform angular motion along a circular orbit with the same period as the actual
12
+ * elliptical orbit. It is computed as:
13
+ *
14
+ * $$ M = M_0 + n \cdot \Delta T $$
15
+ *
16
+ * where:
17
+ * - $M_0$ is the **initial mean anomaly** (converted from true anomaly if necessary).
18
+ * - $n$ is the **mean motion**, given by:
19
+ * $$ n = \frac{2\pi}{P} $$
20
+ * where $P$ is the orbital period in days.
21
+ * - $\Delta T$ is the time step, converted to days from its unit.
22
+ *
23
+ * @param {Pick<OrbitInterface, 'e' | 'angle' | 'period'>} orbit - The body's orbit, for example `body.orbit` from a dataset.
24
+ * @param {TemporalInterface} timeStep - The time step over which to compute the change, in any temporal unit.
25
+ * @returns {Radians} The computed mean anomaly in radians.
26
+ *
27
+ * @throws {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError | RangeError} If the orbit's eccentricity is outside the range $0 \leq e < 1$.
28
+ *
29
+ * @example
30
+ * ```ts
31
+ * import { advanceMeanAnomaly } from '@interstellar-tools/equations';
32
+ *
33
+ * const marsOrbit = {
34
+ * e: 0.0934, // Eccentricity of Mars' orbit
35
+ * angle: 1.047 as Radians, // Initial true anomaly (in radians)
36
+ * period: { value: 687, unit: 'd' } // Orbital period in days
37
+ * };
38
+ *
39
+ * const timeStep: TemporalInterface = { value: 1, unit: 'd' }; // 1-day step
40
+ * const meanAnomaly = advanceMeanAnomaly(marsOrbit, timeStep);
41
+ * console.log(meanAnomaly); // Output: Computed mean anomaly in radians
42
+ * ```
43
+ *
44
+ * @see {@link solveKepler} to convert the mean anomaly to the eccentric anomaly.
45
+ * @see [Mean Anomaly (Wikipedia)](https://en.wikipedia.org/wiki/Mean_anomaly)
46
+ * @see [Orbital Mechanics (NASA)](https://solarsystem.nasa.gov/basics/chapter2-2/)
47
+ * @group Anomalies
48
+ */
49
+ export declare const advanceMeanAnomaly: (orbit: Pick<OrbitInterface, "e" | "angle" | "period">, timeStep: TemporalInterface) => Radians;
50
+ //# sourceMappingURL=advance-mean-anomaly.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"advance-mean-anomaly.d.ts","sourceRoot":"","sources":["../../../src/categories/anomalies/advance-mean-anomaly.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,cAAc,EACd,OAAO,EACP,iBAAiB,EAClB,MAAM,2BAA2B,CAAC;AAQnC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AAEH,eAAO,MAAM,kBAAkB,GAC7B,OAAO,IAAI,CAAC,cAAc,EAAE,GAAG,GAAG,OAAO,GAAG,QAAQ,CAAC,EACrD,UAAU,iBAAiB,KAC1B,OAqCF,CAAC"}
@@ -5,7 +5,10 @@ import { trueToMeanAnomaly } from './true-to-mean-anomaly.js';
5
5
  import { areEqual } from './utils/are-equal.js';
6
6
  /* node:coverage disable */
7
7
  /**
8
- * Computes the **mean anomaly** ($M$) of a celestial body for a given time step.
8
+ * Advances an orbit by a time step and returns its new **mean anomaly** ($M$).
9
+ *
10
+ * The orbit's `angle` (true anomaly) is the starting point. To get the eccentric
11
+ * anomaly from the result, pass it to {@link solveKepler}.
9
12
  *
10
13
  * **Mathematical Explanation:**
11
14
  *
@@ -20,52 +23,53 @@ import { areEqual } from './utils/are-equal.js';
20
23
  * - $n$ is the **mean motion**, given by:
21
24
  * $$ n = \frac{2\pi}{P} $$
22
25
  * where $P$ is the orbital period in days.
23
- * - $\Delta T$ is the time step.
26
+ * - $\Delta T$ is the time step, converted to days from its unit.
24
27
  *
25
- * @param {CelestialBodyType} body - The celestial body for which to compute the mean anomaly.
26
- * @param {TemporalInterface} timeStep - The time step over which to compute the change.
28
+ * @param {Pick<OrbitInterface, 'e' | 'angle' | 'period'>} orbit - The body's orbit, for example `body.orbit` from a dataset.
29
+ * @param {TemporalInterface} timeStep - The time step over which to compute the change, in any temporal unit.
27
30
  * @returns {Radians} The computed mean anomaly in radians.
28
31
  *
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$.
32
+ * @throws {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError | RangeError} If the orbit's eccentricity is outside the range $0 \leq e < 1$.
30
33
  *
31
34
  * @example
32
35
  * ```ts
33
- * import { meanToEccentricAnomaly } from '@interstellar-tools/equations';
36
+ * import { advanceMeanAnomaly } from '@interstellar-tools/equations';
34
37
  *
35
- * const mars: CelestialBodyType = {
36
- * name: 'Mars',
38
+ * const marsOrbit = {
37
39
  * e: 0.0934, // Eccentricity of Mars' orbit
38
- * angle: 1.047, // Initial true anomaly (in radians)
39
- * period: { value: 687, unit: 'day' }, // Orbital period in days
40
+ * angle: 1.047 as Radians, // Initial true anomaly (in radians)
41
+ * period: { value: 687, unit: 'd' } // Orbital period in days
40
42
  * };
41
43
  *
42
- * const timeStep: TemporalInterface = { value: 1, unit: 'day' }; // 1-day step
43
- * const meanAnomaly = meanToEccentricAnomaly(mars, timeStep);
44
+ * const timeStep: TemporalInterface = { value: 1, unit: 'd' }; // 1-day step
45
+ * const meanAnomaly = advanceMeanAnomaly(marsOrbit, timeStep);
44
46
  * console.log(meanAnomaly); // Output: Computed mean anomaly in radians
45
47
  * ```
46
48
  *
49
+ * @see {@link solveKepler} to convert the mean anomaly to the eccentric anomaly.
47
50
  * @see [Mean Anomaly (Wikipedia)](https://en.wikipedia.org/wiki/Mean_anomaly)
48
51
  * @see [Orbital Mechanics (NASA)](https://solarsystem.nasa.gov/basics/chapter2-2/)
49
52
  * @group Anomalies
50
53
  */
51
54
  /* node:coverage enable */
52
- export const meanToEccentricAnomaly = (body, timeStep) => {
53
- const { e, angle, period } = body;
55
+ export const advanceMeanAnomaly = (orbit, timeStep) => {
56
+ const { e, angle, period } = orbit;
54
57
  if (e < 0 || e >= 1) {
55
58
  throw new RangeError(`Invalid eccentricity: ${e}. Eccentricity must be in the range [0, 1].`);
56
59
  }
57
- // Convert period to days and compute mean motion
60
+ // Convert period and time step to days and compute mean motion
58
61
  const periodInDays = convertTemporalUnit(period, 'd').value;
62
+ const timeStepInDays = convertTemporalUnit(timeStep, 'd').value;
59
63
  const meanMotion = TWO_PI / Math.abs(periodInDays);
60
64
  // Convert true anomaly (V) to mean anomaly (M0) if necessary
61
65
  const M0 = e === 0 ? angle : trueToMeanAnomaly(angle, e);
62
- if (timeStep.value === 0) {
66
+ if (timeStepInDays === 0) {
63
67
  return M0;
64
68
  }
65
69
  // Clamping small time steps to prevent unnecessary updates
66
70
  const minTimeStep = 1e-5; // Minimum allowed time step
67
71
  const maxTimeStepFactor = e >= 0.9 ? 1 : 10; // Stricter limit for highly eccentric orbits
68
- const clampedDeltaT = Math.max(minTimeStep, Math.min(timeStep.value, maxTimeStepFactor * Math.abs(periodInDays)));
72
+ const clampedDeltaT = Math.max(minTimeStep, Math.min(timeStepInDays, maxTimeStepFactor * Math.abs(periodInDays)));
69
73
  // Compute new mean anomaly with hysteresis filter and sign preservation
70
74
  const prevM = M0;
71
75
  let newM = wrapAngle(M0 + meanMotion * clampedDeltaT);
@@ -74,4 +78,4 @@ export const meanToEccentricAnomaly = (body, timeStep) => {
74
78
  }
75
79
  return newM;
76
80
  };
77
- //# sourceMappingURL=mean-to-eccentric-anomaly.js.map
81
+ //# sourceMappingURL=advance-mean-anomaly.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"advance-mean-anomaly.js","sourceRoot":"","sources":["../../../src/categories/anomalies/advance-mean-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,wBAAwB,CAAC;AAEnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEhD,2BAA2B;AAC3B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,0BAA0B;AAC1B,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAChC,KAAqD,EACrD,QAA2B,EAClB,EAAE;IACX,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC;IAEnC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QACpB,MAAM,IAAI,UAAU,CAClB,yBAAyB,CAAC,6CAA6C,CACxE,CAAC;IACJ,CAAC;IAED,+DAA+D;IAC/D,MAAM,YAAY,GAAG,mBAAmB,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC;IAC5D,MAAM,cAAc,GAAG,mBAAmB,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC;IAChE,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,cAAc,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,EAAa,CAAC;IACvB,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,cAAc,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,IAAe,CAAC;AACzB,CAAC,CAAC"}
@@ -6,6 +6,9 @@ import type { Radians } from '@interstellar-tools/types';
6
6
  * - **High-eccentricity solver** for extreme orbits ($e > 0.9$).
7
7
  * - **Bisection fallback** if the selected solver doesn't return a root.
8
8
  *
9
+ * This is the conversion from **mean anomaly** to **eccentric anomaly**. Use
10
+ * {@link eccentricToTrueAnomaly} on the result to get the true anomaly.
11
+ *
9
12
  * ---
10
13
  *
11
14
  * **Mathematical Explanation:**
@@ -1 +1 @@
1
- {"version":3,"file":"solve-kepler.d.ts","sourceRoot":"","sources":["../../../src/categories/kepler/solve-kepler.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAQzD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoFG;AACH,eAAO,MAAM,WAAW,GACtB,GAAG,OAAO,EACV,GAAG,MAAM,EACT,gBAAY,EACZ,kBAAgB,KACf,OAuBF,CAAC"}
1
+ {"version":3,"file":"solve-kepler.d.ts","sourceRoot":"","sources":["../../../src/categories/kepler/solve-kepler.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAQzD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuFG;AACH,eAAO,MAAM,WAAW,GACtB,GAAG,OAAO,EACV,GAAG,MAAM,EACT,gBAAY,EACZ,kBAAgB,KACf,OAuBF,CAAC"}
@@ -10,6 +10,9 @@ import { solveKeplerNewtonRaphson } from './solve-kepler-newton-raphson.js';
10
10
  * - **High-eccentricity solver** for extreme orbits ($e > 0.9$).
11
11
  * - **Bisection fallback** if the selected solver doesn't return a root.
12
12
  *
13
+ * This is the conversion from **mean anomaly** to **eccentric anomaly**. Use
14
+ * {@link eccentricToTrueAnomaly} on the result to get the true anomaly.
15
+ *
13
16
  * ---
14
17
  *
15
18
  * **Mathematical Explanation:**
@@ -1 +1 @@
1
- {"version":3,"file":"solve-kepler.js","sourceRoot":"","sources":["../../../src/categories/kepler/solve-kepler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AAGvD,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CA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,GAAG,CAAC,QAAQ,EAAE,MAAM,GAAG,QAAQ,CAAC,IAAI,SAAS,CAAC,EAAE,CAAC;QAC1D,CAAC,GAAG,oBAAoB,CAAC,EAAE,EAAE,CAAC,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;IACtD,CAAC;IAED,OAAO,OAAO,CAAC,CAAC,CAAY,CAAC;AAC/B,CAAC,CAAC"}
package/dist/index.d.ts CHANGED
@@ -19,8 +19,8 @@ export * from './categories/helpers/radians.js';
19
19
  export * from './categories/helpers/rot-1.js';
20
20
  export * from './categories/helpers/rot-3.js';
21
21
  export * from './categories/helpers/transpose-3.js';
22
+ export * from './categories/anomalies/advance-mean-anomaly.js';
22
23
  export * from './categories/anomalies/eccentric-to-true-anomaly.js';
23
- export * from './categories/anomalies/mean-to-eccentric-anomaly.js';
24
24
  export * from './categories/anomalies/true-to-mean-anomaly.js';
25
25
  export * from './categories/kepler/solve-kepler-bisection.js';
26
26
  export * from './categories/kepler/solve-kepler-high-eccentricity.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,cAAc,qCAAqC,CAAC;AAEpD,cAAc,kCAAkC,CAAC;AAIjD,cAAc,8DAA8D,CAAC;AAE7E,cAAc,kEAAkE,CAAC;AAEjF,cAAc,wDAAwD,CAAC;AAEvE,cAAc,8DAA8D,CAAC;AAE7E,cAAc,qDAAqD,CAAC;AAEpE,cAAc,4DAA4D,CAAC;AAI3E,cAAc,wCAAwC,CAAC;AAEvD,cAAc,+BAA+B,CAAC;AAE9C,cAAc,kCAAkC,CAAC;AAEjD,cAAc,8BAA8B,CAAC;AAE7C,cAAc,iCAAiC,CAAC;AAEhD,cAAc,+BAA+B,CAAC;AAE9C,cAAc,+BAA+B,CAAC;AAE9C,cAAc,qCAAqC,CAAC;AAIpD,cAAc,qDAAqD,CAAC;AAEpE,cAAc,qDAAqD,CAAC;AAEpE,cAAc,gDA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
24
  export * from './categories/helpers/transpose-3.js';
25
25
  // categories/anomalies
26
+ export * from './categories/anomalies/advance-mean-anomaly.js';
26
27
  export * from './categories/anomalies/eccentric-to-true-anomaly.js';
27
- export * from './categories/anomalies/mean-to-eccentric-anomaly.js';
28
28
  export * from './categories/anomalies/true-to-mean-anomaly.js';
29
29
  // categories/kepler (solvers)
30
30
  export * from './categories/kepler/solve-kepler-bisection.js';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,mBAAmB;AACnB,cAAc,qCAAqC,CAAC;AAEpD,cAAc,kCAAkC,CAAC;AAEjD,yBAAyB;AAEzB,cAAc,8DAA8D,CAAC;AAE7E,cAAc,kEAAkE,CAAC;AAEjF,cAAc,wDAAwD,CAAC;AAEvE,cAAc,8DAA8D,CAAC;AAE7E,cAAc,qDAAqD,CAAC;AAEpE,cAAc,4DAA4D,CAAC;AAE3E,qBAAqB;AAErB,cAAc,wCAAwC,CAAC;AAEvD,cAAc,+BAA+B,CAAC;AAE9C,cAAc,kCAAkC,CAAC;AAEjD,cAAc,8BAA8B,CAAC;AAE7C,cAAc,iCAAiC,CAAC;AAEhD,cAAc,+BAA+B,CAAC;AAE9C,cAAc,+BAA+B,CAAC;AAE9C,cAAc,qCAAqC,CAAC;AAEpD,uBAAuB;AAEvB,cAAc,qDAAqD,CAAC;AAEpE,cAAc,qDAAqD,CAAC;AAEpE,cAAc,gDAAgD,CAAC;AAE/D,8BAA8B;AAE9B,cAAc,+CAA+C,CAAC;AAE9D,cAAc,uDAAuD,CAAC;AAEtE,cAAc,oDAAoD,CAAC;AAEnE,cAAc,qCAAqC,CAAC;AAEpD,qBAAqB;AAErB,cAAc,8CAA8C,CAAC;AAE7D,cAAc,uCAAuC,CAAC;AAEtD,cAAc,6CAA6C,CAAC;AAE5D,cAAc,iDAAiD,CAAC;AAEhE,oBAAoB;AAEpB,cAAc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uBAAuB;AAEvB,cAAc,gDAAgD,CAAC;AAE/D,cAAc,qDAAqD,CAAC;AAEpE,cAAc,gDAAgD,CAAC;AAE/D,8BAA8B;AAE9B,cAAc,+CAA+C,CAAC;AAE9D,cAAc,uDAAuD,CAAC;AAEtE,cAAc,oDAAoD,CAAC;AAEnE,cAAc,qCAAqC,CAAC;AAEpD,qBAAqB;AAErB,cAAc,8CAA8C,CAAC;AAE7D,cAAc,uCAAuC,CAAC;AAEtD,cAAc,6CAA6C,CAAC;AAE5D,cAAc,iDAAiD,CAAC;AAEhE,oBAAoB;AAEpB,cAAc,sDAAsD,CAAC;AAErE,cAAc,iDAAiD,CAAC;AAEhE,cAAc,uCAAuC,CAAC;AAEtD,cAAc,4CAA4C,CAAC;AAE3D,cAAc,qCAAqC,CAAC;AAEpD,cAAc,4DAA4D,CAAC;AAE3E,cAAc,mDAAmD,CAAC;AAElE,cAAc,oDAAoD,CAAC;AAEnE,cAAc,iDAAiD,CAAC;AAEhE,cAAc,sCAAsC,CAAC;AAErD,cAAc,oCAAoC,CAAC;AAEnD,cAAc,4CAA4C,CAAC;AAE3D,cAAc,gEAAgE,CAAC;AAE/E,cAAc,kDAAkD,CAAC;AAEjE,cAAc,mDAAmD,CAAC;AAElE,cAAc,mDAAmD,CAAC;AAElE,cAAc,uCAAuC,CAAC;AAEtD,wBAAwB;AAExB,cAAc,kDAAkD,CAAC;AAEjE,cAAc,yDAAyD,CAAC;AAExE,cAAc,6CAA6C,CAAC;AAE5D,cAAc,+CAA+C,CAAC;AAE9D,cAAc,iDAAiD,CAAC;AAEhE,cAAc,oDAAoD,CAAC;AAEnE,cAAc,mDAAmD,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@interstellar-tools/equations",
3
- "version": "0.60.1",
3
+ "version": "0.61.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",
@@ -77,7 +77,7 @@
77
77
  "geo",
78
78
  "earth-sun"
79
79
  ],
80
- "homepage": "https://phun-ky.net/projects/interstellar-tools",
80
+ "homepage": "https://phun-ky.net/interstellar-tools/",
81
81
  "bugs": {
82
82
  "url": "https://github.com/phun-ky/interstellar-tools/issues"
83
83
  },
@@ -110,12 +110,13 @@
110
110
  "test:ci": "glob-bin -c \"node --import tsx --test --no-warnings --experimental-test-coverage --test-coverage-exclude='**/__tests__/helpers/**' --test-reporter=cobertura --test-reporter-destination=coverage/cobertura-coverage.xml --test-reporter=spec --test-reporter-destination=stdout\" \"**/__tests__/**/*.spec.ts\""
111
111
  },
112
112
  "dependencies": {
113
- "@interstellar-tools/constants": "^0.60.0",
113
+ "@interstellar-tools/constants": "^0.61.0",
114
114
  "@interstellar-tools/temporal": "^0.60.0",
115
- "@interstellar-tools/types": "^0.60.0"
115
+ "@interstellar-tools/types": "^0.61.0"
116
116
  },
117
117
  "devDependencies": {
118
118
  "@types/node": "^24.19.2",
119
+ "fast-check": "4.10.2",
119
120
  "prettier": "^3.9.10",
120
121
  "typescript": "^6.0.3"
121
122
  },
@@ -1,47 +0,0 @@
1
- import type { CelestialBodyType, Radians, TemporalInterface } from '@interstellar-tools/types';
2
- /**
3
- * Computes the **mean anomaly** ($M$) of a celestial body for a given time step.
4
- *
5
- * **Mathematical Explanation:**
6
- *
7
- * The **mean anomaly** is a measure of the position of an orbiting body as if it moved
8
- * with uniform angular motion along a circular orbit with the same period as the actual
9
- * elliptical orbit. It is computed as:
10
- *
11
- * $$ M = M_0 + n \cdot \Delta T $$
12
- *
13
- * where:
14
- * - $M_0$ is the **initial mean anomaly** (converted from true anomaly if necessary).
15
- * - $n$ is the **mean motion**, given by:
16
- * $$ n = \frac{2\pi}{P} $$
17
- * where $P$ is the orbital period in days.
18
- * - $\Delta T$ is the time step.
19
- *
20
- * @param {CelestialBodyType} body - The celestial body for which to compute the mean anomaly.
21
- * @param {TemporalInterface} timeStep - The time step over which to compute the change.
22
- * @returns {Radians} The computed mean anomaly in radians.
23
- *
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
- *
26
- * @example
27
- * ```ts
28
- * import { meanToEccentricAnomaly } from '@interstellar-tools/equations';
29
- *
30
- * const mars: CelestialBodyType = {
31
- * name: 'Mars',
32
- * e: 0.0934, // Eccentricity of Mars' orbit
33
- * angle: 1.047, // Initial true anomaly (in radians)
34
- * period: { value: 687, unit: 'day' }, // Orbital period in days
35
- * };
36
- *
37
- * const timeStep: TemporalInterface = { value: 1, unit: 'day' }; // 1-day step
38
- * const meanAnomaly = meanToEccentricAnomaly(mars, timeStep);
39
- * console.log(meanAnomaly); // Output: Computed mean anomaly in radians
40
- * ```
41
- *
42
- * @see [Mean Anomaly (Wikipedia)](https://en.wikipedia.org/wiki/Mean_anomaly)
43
- * @see [Orbital Mechanics (NASA)](https://solarsystem.nasa.gov/basics/chapter2-2/)
44
- * @group Anomalies
45
- */
46
- export declare const meanToEccentricAnomaly: (body: CelestialBodyType, timeStep: TemporalInterface) => Radians;
47
- //# sourceMappingURL=mean-to-eccentric-anomaly.d.ts.map
@@ -1 +0,0 @@
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 +0,0 @@
1
- {"version":3,"file":"mean-to-eccentric-anomaly.js","sourceRoot":"","sources":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