@interstellar-tools/equations 0.61.1 → 0.63.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 (29) hide show
  1. package/dist/categories/angle/compute-angle.d.ts +5 -4
  2. package/dist/categories/angle/compute-angle.d.ts.map +1 -1
  3. package/dist/categories/angle/compute-angle.js +5 -4
  4. package/dist/categories/angle/compute-angle.js.map +1 -1
  5. package/dist/categories/anomalies/advance-mean-anomaly.d.ts +15 -12
  6. package/dist/categories/anomalies/advance-mean-anomaly.d.ts.map +1 -1
  7. package/dist/categories/anomalies/advance-mean-anomaly.js +18 -29
  8. package/dist/categories/anomalies/advance-mean-anomaly.js.map +1 -1
  9. package/dist/categories/anomalies/anomaly-at.d.ts +61 -0
  10. package/dist/categories/anomalies/anomaly-at.d.ts.map +1 -0
  11. package/dist/categories/anomalies/anomaly-at.js +81 -0
  12. package/dist/categories/anomalies/anomaly-at.js.map +1 -0
  13. package/dist/categories/orbits/cw-hill-derivatives.d.ts +1 -1
  14. package/dist/categories/orbits/cw-hill-derivatives.js +1 -1
  15. package/dist/categories/orbits/hyperbolic-periapsis-speed.d.ts +4 -4
  16. package/dist/categories/orbits/hyperbolic-periapsis-speed.js +10 -10
  17. package/dist/categories/orbits/mean-motion.d.ts +6 -6
  18. package/dist/categories/orbits/mean-motion.d.ts.map +1 -1
  19. package/dist/categories/orbits/mean-motion.js +10 -10
  20. package/dist/categories/orbits/mean-motion.js.map +1 -1
  21. package/dist/index.d.ts +1 -0
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +1 -0
  24. package/dist/index.js.map +1 -1
  25. package/package.json +1 -1
  26. package/dist/categories/anomalies/utils/are-equal.d.ts +0 -10
  27. package/dist/categories/anomalies/utils/are-equal.d.ts.map +0 -1
  28. package/dist/categories/anomalies/utils/are-equal.js +0 -13
  29. package/dist/categories/anomalies/utils/are-equal.js.map +0 -1
@@ -5,7 +5,8 @@ import type { OrbitInterface, Radians, TimeStepInterface } from '@interstellar-t
5
5
  *
6
6
  * The orbit's `angle` is the starting true anomaly. There is no date input:
7
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.
8
+ * `angle` to move the body over time. To find a body at a given date instead,
9
+ * use {@link trueAnomalyAt}.
9
10
  *
10
11
  * **Step 1: Mean anomaly after the time step ($M$)**
11
12
  *
@@ -15,9 +16,9 @@ import type { OrbitInterface, Radians, TimeStepInterface } from '@interstellar-t
15
16
  * - $M_0$ is the mean anomaly at the start, converted from the true anomaly
16
17
  * `angle` (equal to it when $e = 0$).
17
18
  * - $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$).
19
+ * $P$ is ignored, so a positive step always moves the body forward.
20
+ * - $\Delta t$ is `timeStep.value` in days. It can be any length, and negative
21
+ * to go back in time.
21
22
  *
22
23
  * The result is wrapped to $[0, 2\pi)$.
23
24
  *
@@ -1 +1 @@
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
+ {"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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AACH,eAAO,MAAM,YAAY,GACvB,OAAO,IAAI,CAAC,cAAc,EAAE,GAAG,GAAG,OAAO,GAAG,QAAQ,CAAC,EACrD,UAAU,iBAAiB,KAC1B,OASF,CAAC"}
@@ -7,7 +7,8 @@ import { solveKepler } from '../kepler/solve-kepler.js';
7
7
  *
8
8
  * The orbit's `angle` is the starting true anomaly. There is no date input:
9
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.
10
+ * `angle` to move the body over time. To find a body at a given date instead,
11
+ * use {@link trueAnomalyAt}.
11
12
  *
12
13
  * **Step 1: Mean anomaly after the time step ($M$)**
13
14
  *
@@ -17,9 +18,9 @@ import { solveKepler } from '../kepler/solve-kepler.js';
17
18
  * - $M_0$ is the mean anomaly at the start, converted from the true anomaly
18
19
  * `angle` (equal to it when $e = 0$).
19
20
  * - $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$).
21
+ * $P$ is ignored, so a positive step always moves the body forward.
22
+ * - $\Delta t$ is `timeStep.value` in days. It can be any length, and negative
23
+ * to go back in time.
23
24
  *
24
25
  * The result is wrapped to $[0, 2\pi)$.
25
26
  *
@@ -1 +1 @@
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"}
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;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"}
@@ -3,26 +3,29 @@ import type { OrbitInterface, Radians, TemporalInterface } from '@interstellar-t
3
3
  * Advances an orbit by a time step and returns its new **mean anomaly** ($M$).
4
4
  *
5
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}.
6
+ * anomaly from the result, pass it to {@link solveKepler}. To find a body at a
7
+ * given date, use {@link meanAnomalyAt} or {@link trueAnomalyAt}.
7
8
  *
8
9
  * **Mathematical Explanation:**
9
10
  *
10
11
  * The **mean anomaly** is a measure of the position of an orbiting body as if it moved
11
12
  * with uniform angular motion along a circular orbit with the same period as the actual
12
- * elliptical orbit. It is computed as:
13
+ * elliptical orbit. It grows linearly with time:
13
14
  *
14
- * $$ M = M_0 + n \cdot \Delta T $$
15
+ * $$ M = M_0 + n \cdot \Delta T, \qquad n = \frac{2\pi}{|P|} $$
15
16
  *
16
17
  * 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.
18
+ * - $M_0$ is the **initial mean anomaly**, converted from the true anomaly `angle`.
19
+ * - $n$ is the **mean motion**, from the period $P$ in days. The sign of $P$ is
20
+ * ignored, so a positive step always moves the body forward along its orbit.
21
21
  * - $\Delta T$ is the time step, converted to days from its unit.
22
22
  *
23
+ * The step can be any length, from a fraction of a second to many orbits, and
24
+ * negative to go back in time. The result is wrapped to $[0, 2\pi)$.
25
+ *
23
26
  * @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.
27
+ * @param {TemporalInterface} timeStep - How far to advance, in any temporal unit; negative goes back in time.
28
+ * @returns {Radians} The mean anomaly after the time step, in $[0, 2\pi)$.
26
29
  *
27
30
  * @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
31
  *
@@ -36,9 +39,9 @@ import type { OrbitInterface, Radians, TemporalInterface } from '@interstellar-t
36
39
  * period: { value: 687, unit: 'd' } // Orbital period in days
37
40
  * };
38
41
  *
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
+ * advanceMeanAnomaly(marsOrbit, { value: 1, unit: 'd' }); // one day on
43
+ * advanceMeanAnomaly(marsOrbit, { value: 10, unit: 'yr' }); // ten years on
44
+ * advanceMeanAnomaly(marsOrbit, { value: -1, unit: 'd' }); // one day back
42
45
  * ```
43
46
  *
44
47
  * @see {@link solveKepler} to convert the mean anomaly to the eccentric anomaly.
@@ -1 +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"}
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;AAOnC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AAEH,eAAO,MAAM,kBAAkB,GAC7B,OAAO,IAAI,CAAC,cAAc,EAAE,GAAG,GAAG,OAAO,GAAG,QAAQ,CAAC,EACrD,UAAU,iBAAiB,KAC1B,OAiBF,CAAC"}
@@ -1,33 +1,35 @@
1
1
  import { TWO_PI } from '@interstellar-tools/constants';
2
2
  import { convertTemporalUnit } from '@interstellar-tools/temporal';
3
- import { wrapAngle } from '../angle/wrap-angle.js';
3
+ import { norm2pi } from '../helpers/misc.js';
4
4
  import { trueToMeanAnomaly } from './true-to-mean-anomaly.js';
5
- import { areEqual } from './utils/are-equal.js';
6
5
  /* node:coverage disable */
7
6
  /**
8
7
  * Advances an orbit by a time step and returns its new **mean anomaly** ($M$).
9
8
  *
10
9
  * The orbit's `angle` (true anomaly) is the starting point. To get the eccentric
11
- * anomaly from the result, pass it to {@link solveKepler}.
10
+ * anomaly from the result, pass it to {@link solveKepler}. To find a body at a
11
+ * given date, use {@link meanAnomalyAt} or {@link trueAnomalyAt}.
12
12
  *
13
13
  * **Mathematical Explanation:**
14
14
  *
15
15
  * The **mean anomaly** is a measure of the position of an orbiting body as if it moved
16
16
  * with uniform angular motion along a circular orbit with the same period as the actual
17
- * elliptical orbit. It is computed as:
17
+ * elliptical orbit. It grows linearly with time:
18
18
  *
19
- * $$ M = M_0 + n \cdot \Delta T $$
19
+ * $$ M = M_0 + n \cdot \Delta T, \qquad n = \frac{2\pi}{|P|} $$
20
20
  *
21
21
  * where:
22
- * - $M_0$ is the **initial mean anomaly** (converted from true anomaly if necessary).
23
- * - $n$ is the **mean motion**, given by:
24
- * $$ n = \frac{2\pi}{P} $$
25
- * where $P$ is the orbital period in days.
22
+ * - $M_0$ is the **initial mean anomaly**, converted from the true anomaly `angle`.
23
+ * - $n$ is the **mean motion**, from the period $P$ in days. The sign of $P$ is
24
+ * ignored, so a positive step always moves the body forward along its orbit.
26
25
  * - $\Delta T$ is the time step, converted to days from its unit.
27
26
  *
27
+ * The step can be any length, from a fraction of a second to many orbits, and
28
+ * negative to go back in time. The result is wrapped to $[0, 2\pi)$.
29
+ *
28
30
  * @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.
30
- * @returns {Radians} The computed mean anomaly in radians.
31
+ * @param {TemporalInterface} timeStep - How far to advance, in any temporal unit; negative goes back in time.
32
+ * @returns {Radians} The mean anomaly after the time step, in $[0, 2\pi)$.
31
33
  *
32
34
  * @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$.
33
35
  *
@@ -41,9 +43,9 @@ import { areEqual } from './utils/are-equal.js';
41
43
  * period: { value: 687, unit: 'd' } // Orbital period in days
42
44
  * };
43
45
  *
44
- * const timeStep: TemporalInterface = { value: 1, unit: 'd' }; // 1-day step
45
- * const meanAnomaly = advanceMeanAnomaly(marsOrbit, timeStep);
46
- * console.log(meanAnomaly); // Output: Computed mean anomaly in radians
46
+ * advanceMeanAnomaly(marsOrbit, { value: 1, unit: 'd' }); // one day on
47
+ * advanceMeanAnomaly(marsOrbit, { value: 10, unit: 'yr' }); // ten years on
48
+ * advanceMeanAnomaly(marsOrbit, { value: -1, unit: 'd' }); // one day back
47
49
  * ```
48
50
  *
49
51
  * @see {@link solveKepler} to convert the mean anomaly to the eccentric anomaly.
@@ -61,21 +63,8 @@ export const advanceMeanAnomaly = (orbit, timeStep) => {
61
63
  const periodInDays = convertTemporalUnit(period, 'd').value;
62
64
  const timeStepInDays = convertTemporalUnit(timeStep, 'd').value;
63
65
  const meanMotion = TWO_PI / Math.abs(periodInDays);
64
- // Convert true anomaly (V) to mean anomaly (M0) if necessary
66
+ // Convert true anomaly (V) to mean anomaly (M0)
65
67
  const M0 = e === 0 ? angle : trueToMeanAnomaly(angle, e);
66
- if (timeStepInDays === 0) {
67
- return M0;
68
- }
69
- // Clamping small time steps to prevent unnecessary updates
70
- const minTimeStep = 1e-5; // Minimum allowed time step
71
- const maxTimeStepFactor = e >= 0.9 ? 1 : 10; // Stricter limit for highly eccentric orbits
72
- const clampedDeltaT = Math.max(minTimeStep, Math.min(timeStepInDays, maxTimeStepFactor * Math.abs(periodInDays)));
73
- // Compute new mean anomaly with hysteresis filter and sign preservation
74
- const prevM = M0;
75
- let newM = wrapAngle(M0 + meanMotion * clampedDeltaT);
76
- if (areEqual(newM, prevM)) {
77
- newM = prevM;
78
- }
79
- return newM;
68
+ return norm2pi(M0 + meanMotion * timeStepInDays);
80
69
  };
81
70
  //# sourceMappingURL=advance-mean-anomaly.js.map
@@ -1 +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,IAA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;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,gDAAgD;IAChD,MAAM,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,iBAAiB,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IAEzD,OAAO,OAAO,CAAC,EAAE,GAAG,UAAU,GAAG,cAAc,CAAY,CAAC;AAC9D,CAAC,CAAC"}
@@ -0,0 +1,61 @@
1
+ import type { OrbitInterface, Radians } from '@interstellar-tools/types';
2
+ /**
3
+ * The **mean anomaly** ($M$) of an orbit at a given date.
4
+ *
5
+ * Every `orbit.angle` in the datasets is the true anomaly at **J2000**
6
+ * (2000-01-01 12:00 TT), so this advances the orbit from J2000 to `date` with
7
+ * {@link advanceMeanAnomaly}. Dates before J2000 work too.
8
+ *
9
+ * $$ M = M_0 + \frac{2\pi}{|P|} \, (t - t_{J2000}) $$
10
+ *
11
+ * The time is measured in UTC, as JavaScript dates are, against
12
+ * {@link J2000_UTC}. Leap seconds since 2000 are ignored, which moves a body by
13
+ * a few seconds of its orbit at most.
14
+ *
15
+ * @param {Pick<OrbitInterface, 'e' | 'angle' | 'period'>} orbit - An orbit whose `angle` is the true anomaly at J2000, for example `body.orbit` from a dataset.
16
+ * @param {Date} date - The date to find the body at.
17
+ * @returns {Radians} The mean anomaly at `date`, in $[0, 2\pi)$.
18
+ * @throws {TypeError} If `date` is not a valid `Date`.
19
+ * @throws {RangeError} If the orbit's eccentricity is outside $0 \leq e < 1$.
20
+ *
21
+ * @example
22
+ * ```ts
23
+ * import { PLANETS } from '@interstellar-tools/constants';
24
+ * import { meanAnomalyAt } from '@interstellar-tools/equations';
25
+ *
26
+ * const earth = PLANETS.find((planet) => planet.id === 'earth')!;
27
+ *
28
+ * meanAnomalyAt(earth.orbit!, new Date('2026-10-17T12:00:00Z')); // ≈ 4.934 rad (282.7°)
29
+ * ```
30
+ *
31
+ * @see {@link trueAnomalyAt} for where the body actually is.
32
+ * @group Anomalies
33
+ */
34
+ export declare const meanAnomalyAt: (orbit: Pick<OrbitInterface, "e" | "angle" | "period">, date: Date) => Radians;
35
+ /**
36
+ * The **true anomaly** ($\nu$) of an orbit at a given date: where the body is.
37
+ *
38
+ * Takes the mean anomaly at `date` from {@link meanAnomalyAt}, solves Kepler's
39
+ * equation with {@link solveKepler}, and converts the result with
40
+ * {@link eccentricToTrueAnomaly}.
41
+ *
42
+ * @param {Pick<OrbitInterface, 'e' | 'angle' | 'period'>} orbit - An orbit whose `angle` is the true anomaly at J2000, for example `body.orbit` from a dataset.
43
+ * @param {Date} date - The date to find the body at.
44
+ * @returns {Radians} The true anomaly at `date`, in $[0, 2\pi)$.
45
+ * @throws {TypeError} If `date` is not a valid `Date`.
46
+ * @throws {RangeError} If the orbit's eccentricity is outside $0 \leq e < 1$.
47
+ *
48
+ * @example
49
+ * ```ts
50
+ * import { PLANETS } from '@interstellar-tools/constants';
51
+ * import { trueAnomalyAt } from '@interstellar-tools/equations';
52
+ *
53
+ * const earth = PLANETS.find((planet) => planet.id === 'earth')!;
54
+ *
55
+ * trueAnomalyAt(earth.orbit!, new Date('2026-10-17T12:00:00Z')); // ≈ 4.901 rad (280.8°)
56
+ * ```
57
+ *
58
+ * @group Anomalies
59
+ */
60
+ export declare const trueAnomalyAt: (orbit: Pick<OrbitInterface, "e" | "angle" | "period">, date: Date) => Radians;
61
+ //# sourceMappingURL=anomaly-at.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"anomaly-at.d.ts","sourceRoot":"","sources":["../../../src/categories/anomalies/anomaly-at.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAkBzE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,eAAO,MAAM,aAAa,GACxB,OAAO,IAAI,CAAC,cAAc,EAAE,GAAG,GAAG,OAAO,GAAG,QAAQ,CAAC,EACrD,MAAM,IAAI,KACT,OACoE,CAAC;AAGxE;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,eAAO,MAAM,aAAa,GACxB,OAAO,IAAI,CAAC,cAAc,EAAE,GAAG,GAAG,OAAO,GAAG,QAAQ,CAAC,EACrD,MAAM,IAAI,KACT,OAMF,CAAC"}
@@ -0,0 +1,81 @@
1
+ import { J2000_UTC, MILLISECONDS_PER_DAY } from '@interstellar-tools/constants';
2
+ import { norm2pi } from '../helpers/misc.js';
3
+ import { solveKepler } from '../kepler/solve-kepler.js';
4
+ import { advanceMeanAnomaly } from './advance-mean-anomaly.js';
5
+ import { eccentricToTrueAnomaly } from './eccentric-to-true-anomaly.js';
6
+ /** Days from J2000 to `date`, after checking it's a valid date. */
7
+ const daysSinceJ2000 = (date) => {
8
+ if (!(date instanceof Date) || !Number.isFinite(date.getTime())) {
9
+ throw new TypeError(`date must be a valid Date. Received: ${String(date)}`);
10
+ }
11
+ return (date.getTime() - J2000_UTC.getTime()) / MILLISECONDS_PER_DAY;
12
+ };
13
+ /* node:coverage disable */
14
+ /**
15
+ * The **mean anomaly** ($M$) of an orbit at a given date.
16
+ *
17
+ * Every `orbit.angle` in the datasets is the true anomaly at **J2000**
18
+ * (2000-01-01 12:00 TT), so this advances the orbit from J2000 to `date` with
19
+ * {@link advanceMeanAnomaly}. Dates before J2000 work too.
20
+ *
21
+ * $$ M = M_0 + \frac{2\pi}{|P|} \, (t - t_{J2000}) $$
22
+ *
23
+ * The time is measured in UTC, as JavaScript dates are, against
24
+ * {@link J2000_UTC}. Leap seconds since 2000 are ignored, which moves a body by
25
+ * a few seconds of its orbit at most.
26
+ *
27
+ * @param {Pick<OrbitInterface, 'e' | 'angle' | 'period'>} orbit - An orbit whose `angle` is the true anomaly at J2000, for example `body.orbit` from a dataset.
28
+ * @param {Date} date - The date to find the body at.
29
+ * @returns {Radians} The mean anomaly at `date`, in $[0, 2\pi)$.
30
+ * @throws {TypeError} If `date` is not a valid `Date`.
31
+ * @throws {RangeError} If the orbit's eccentricity is outside $0 \leq e < 1$.
32
+ *
33
+ * @example
34
+ * ```ts
35
+ * import { PLANETS } from '@interstellar-tools/constants';
36
+ * import { meanAnomalyAt } from '@interstellar-tools/equations';
37
+ *
38
+ * const earth = PLANETS.find((planet) => planet.id === 'earth')!;
39
+ *
40
+ * meanAnomalyAt(earth.orbit!, new Date('2026-10-17T12:00:00Z')); // ≈ 4.934 rad (282.7°)
41
+ * ```
42
+ *
43
+ * @see {@link trueAnomalyAt} for where the body actually is.
44
+ * @group Anomalies
45
+ */
46
+ /* node:coverage enable */
47
+ export const meanAnomalyAt = (orbit, date) => advanceMeanAnomaly(orbit, { value: daysSinceJ2000(date), unit: 'd' });
48
+ /* node:coverage disable */
49
+ /**
50
+ * The **true anomaly** ($\nu$) of an orbit at a given date: where the body is.
51
+ *
52
+ * Takes the mean anomaly at `date` from {@link meanAnomalyAt}, solves Kepler's
53
+ * equation with {@link solveKepler}, and converts the result with
54
+ * {@link eccentricToTrueAnomaly}.
55
+ *
56
+ * @param {Pick<OrbitInterface, 'e' | 'angle' | 'period'>} orbit - An orbit whose `angle` is the true anomaly at J2000, for example `body.orbit` from a dataset.
57
+ * @param {Date} date - The date to find the body at.
58
+ * @returns {Radians} The true anomaly at `date`, in $[0, 2\pi)$.
59
+ * @throws {TypeError} If `date` is not a valid `Date`.
60
+ * @throws {RangeError} If the orbit's eccentricity is outside $0 \leq e < 1$.
61
+ *
62
+ * @example
63
+ * ```ts
64
+ * import { PLANETS } from '@interstellar-tools/constants';
65
+ * import { trueAnomalyAt } from '@interstellar-tools/equations';
66
+ *
67
+ * const earth = PLANETS.find((planet) => planet.id === 'earth')!;
68
+ *
69
+ * trueAnomalyAt(earth.orbit!, new Date('2026-10-17T12:00:00Z')); // ≈ 4.901 rad (280.8°)
70
+ * ```
71
+ *
72
+ * @group Anomalies
73
+ */
74
+ /* node:coverage enable */
75
+ export const trueAnomalyAt = (orbit, date) => {
76
+ const M = meanAnomalyAt(orbit, date);
77
+ const E = solveKepler(M, orbit.e);
78
+ const nu = eccentricToTrueAnomaly(E, orbit.e);
79
+ return norm2pi(nu);
80
+ };
81
+ //# sourceMappingURL=anomaly-at.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"anomaly-at.js","sourceRoot":"","sources":["../../../src/categories/anomalies/anomaly-at.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAGhF,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAExE,mEAAmE;AACnE,MAAM,cAAc,GAAG,CAAC,IAAU,EAAU,EAAE;IAC5C,IAAI,CAAC,CAAC,IAAI,YAAY,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC;QAChE,MAAM,IAAI,SAAS,CAAC,wCAAwC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC9E,CAAC;IAED,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,SAAS,CAAC,OAAO,EAAE,CAAC,GAAG,oBAAoB,CAAC;AACvE,CAAC,CAAC;AAEF,2BAA2B;AAC3B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,0BAA0B;AAC1B,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,KAAqD,EACrD,IAAU,EACD,EAAE,CACX,kBAAkB,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,cAAc,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC;AAExE,2BAA2B;AAC3B;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,0BAA0B;AAC1B,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,KAAqD,EACrD,IAAU,EACD,EAAE;IACX,MAAM,CAAC,GAAG,aAAa,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IACrC,MAAM,CAAC,GAAG,WAAW,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;IAClC,MAAM,EAAE,GAAG,sBAAsB,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;IAE9C,OAAO,OAAO,CAAC,EAAE,CAAY,CAAC;AAChC,CAAC,CAAC"}
@@ -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/dist/index.d.ts CHANGED
@@ -20,6 +20,7 @@ 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
22
  export * from './categories/anomalies/advance-mean-anomaly.js';
23
+ export * from './categories/anomalies/anomaly-at.js';
23
24
  export * from './categories/anomalies/eccentric-to-true-anomaly.js';
24
25
  export * from './categories/anomalies/true-to-mean-anomaly.js';
25
26
  export * from './categories/kepler/solve-kepler-bisection.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;A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CAAC;AAEhE,cAAc,oDAAoD,CAAC;AAEnE,cAAc,mDAAmD,CAAC"}
package/dist/index.js CHANGED
@@ -24,6 +24,7 @@ export * from './categories/helpers/rot-3.js';
24
24
  export * from './categories/helpers/transpose-3.js';
25
25
  // categories/anomalies
26
26
  export * from './categories/anomalies/advance-mean-anomaly.js';
27
+ export * from './categories/anomalies/anomaly-at.js';
27
28
  export * from './categories/anomalies/eccentric-to-true-anomaly.js';
28
29
  export * from './categories/anomalies/true-to-mean-anomaly.js';
29
30
  // categories/kepler (solvers)
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,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;AA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"0.63.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",
@@ -1,10 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,13 +0,0 @@
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
@@ -1 +0,0 @@
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"}