@interstellar-tools/types 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -8
- package/dist/distance.d.ts +5 -5
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/math.d.ts +24 -0
- package/dist/math.d.ts.map +1 -0
- package/dist/math.js +2 -0
- package/dist/math.js.map +1 -0
- package/dist/physics.d.ts +57 -0
- package/dist/physics.d.ts.map +1 -0
- package/dist/physics.js +2 -0
- package/dist/physics.js.map +1 -0
- package/dist/temporal.d.ts +2 -2
- package/package.json +75 -2
package/README.md
CHANGED
|
@@ -5,14 +5,6 @@
|
|
|
5
5
|
- [Node.js](https://nodejs.org/) version 22.9.0 or higher
|
|
6
6
|
- npm version 11.5.1 or higher
|
|
7
7
|
|
|
8
|
-
::: code-group
|
|
9
|
-
|
|
10
8
|
```shell [npm]
|
|
11
9
|
npm i --save @interstellar-tools/types
|
|
12
10
|
```
|
|
13
|
-
|
|
14
|
-
```shell [yarn]
|
|
15
|
-
yarn add @interstellar-tools/types
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
:::
|
package/dist/distance.d.ts
CHANGED
|
@@ -11,10 +11,10 @@ import { ValueInterface } from './numeric';
|
|
|
11
11
|
* - Uses **meters** as the [SI](https://en.wikipedia.org/wiki/International_System_of_Units) base; larger units have conventional scientific definitions.
|
|
12
12
|
*
|
|
13
13
|
* ## Conventions
|
|
14
|
-
* - **`au`**
|
|
15
|
-
* - **`ly` family**
|
|
14
|
+
* - **`au`** - Astronomical Unit (IAU 2012 B2): **149 597 870 700 m** (lowercase `au` is the IAU symbol).
|
|
15
|
+
* - **`ly` family** - Light-year based on the **Julian year**:
|
|
16
16
|
* `1 ly = c × 365.25 d = 9 460 730 472 580 800 m` (with `kly = 10³ ly`, `Mly = 10⁶ ly`, `Gly = 10⁹ ly`).
|
|
17
|
-
* - **`pc` family**
|
|
17
|
+
* - **`pc` family** - Parsec defined from the arcsecond parallax:
|
|
18
18
|
* `1 pc = au × (648000 / π) ≈ 3.085677581×10¹⁶ m` (`kpc/Mpc/Gpc` are ×10³/×10⁶/×10⁹).
|
|
19
19
|
*
|
|
20
20
|
* ## Members
|
|
@@ -33,7 +33,7 @@ import { ValueInterface } from './numeric';
|
|
|
33
33
|
* const d3: Distance = { value: 8, unit: 'kpc' };
|
|
34
34
|
* ```
|
|
35
35
|
*
|
|
36
|
-
* @see https://www.iau.org/static/resolutions/IAU2012_English.pdf (IAU 2012 B2
|
|
36
|
+
* @see https://www.iau.org/static/resolutions/IAU2012_English.pdf (IAU 2012 B2 - definition of the astronomical unit)
|
|
37
37
|
* @see https://en.wikipedia.org/wiki/Light-year (Light-year based on Julian year)
|
|
38
38
|
* @see https://en.wikipedia.org/wiki/Parsec (Parsec definition & meter equivalence)
|
|
39
39
|
* @category Distance
|
|
@@ -72,7 +72,7 @@ export type DistanceUnitType = 'm' | 'km' | 'au' | 'ly' | 'kly' | 'Mly' | 'Gly'
|
|
|
72
72
|
* ```
|
|
73
73
|
*
|
|
74
74
|
* @see DistanceUnitType for the canonical symbol set.
|
|
75
|
-
* @see https://www.iau.org/static/resolutions/IAU2012_English.pdf (IAU 2012 B2
|
|
75
|
+
* @see https://www.iau.org/static/resolutions/IAU2012_English.pdf (IAU 2012 B2 - astronomical unit, symbol "au")
|
|
76
76
|
* @see https://en.wikipedia.org/wiki/Light-year (Light-year; Julian-year convention)
|
|
77
77
|
* @see https://en.wikipedia.org/wiki/Parsec (Parsec definition)
|
|
78
78
|
* @category Distance
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAE3B,cAAc,YAAY,CAAC;AAE3B,cAAc,WAAW,CAAC;AAE1B,cAAc,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAE3B,cAAc,YAAY,CAAC;AAE3B,cAAc,WAAW,CAAC;AAE1B,cAAc,QAAQ,CAAC;AAEvB,cAAc,WAAW,CAAC;AAE1B,cAAc,oBAAoB,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAE3B,cAAc,YAAY,CAAC;AAE3B,cAAc,WAAW,CAAC;AAE1B,cAAc,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAE3B,cAAc,YAAY,CAAC;AAE3B,cAAc,WAAW,CAAC;AAE1B,cAAc,QAAQ,CAAC;AAEvB,cAAc,WAAW,CAAC;AAE1B,cAAc,oBAAoB,CAAC"}
|
package/dist/math.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A read-only 3D vector tuple `[x, y, z]`.
|
|
3
|
+
*
|
|
4
|
+
* Immutable container for Cartesian coordinates or any 3-component quantity
|
|
5
|
+
* (e.g., position in meters, velocity in m/s, acceleration in m/s²).
|
|
6
|
+
* The `readonly` modifier prevents in-place mutation.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* // Declaring a point/vector
|
|
11
|
+
* const p: Vector3DTupleType = [1, 2, 3];
|
|
12
|
+
* // p[0] = 9; // Error: cannot assign to read-only element
|
|
13
|
+
*
|
|
14
|
+
* // Using with functions
|
|
15
|
+
* const dot = (a: Vector3DTupleType, b: Vector3DTupleType) => a[0]*b[0] + a[1]*b[1] + a[2]*b[2];
|
|
16
|
+
* const v = [4, 5, 6] as const; // const assertion yields a readonly tuple
|
|
17
|
+
* console.log(dot(p, v)); // 32
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @see https://www.typescriptlang.org/docs/handbook/2/objects.html#tuple-types
|
|
21
|
+
* @see https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-4.html#const-assertions
|
|
22
|
+
*/
|
|
23
|
+
export type Vector3DTupleType = readonly [x: number, y: number, z: number];
|
|
24
|
+
//# sourceMappingURL=math.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"math.d.ts","sourceRoot":"","sources":["../src/math.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,MAAM,iBAAiB,GAAG,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC"}
|
package/dist/math.js
ADDED
package/dist/math.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"math.js","sourceRoot":"","sources":["../src/math.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Vector3DTupleType } from './math';
|
|
2
|
+
/**
|
|
3
|
+
* Result of a Newtonian gravitational force computation between two point masses.
|
|
4
|
+
*
|
|
5
|
+
* **Units:** SI (newtons for force). `vector` and `direction` point **from body 1 toward body 2**.
|
|
6
|
+
*
|
|
7
|
+
* **Relevant equations (invariants & definitions)**
|
|
8
|
+
*
|
|
9
|
+
* $$
|
|
10
|
+
* \mathbf F = \langle F_x, F_y, F_z \rangle,\qquad
|
|
11
|
+
* \|\mathbf F\| = \sqrt{F_x^2 + F_y^2 + F_z^2}
|
|
12
|
+
* $$
|
|
13
|
+
*
|
|
14
|
+
* $$
|
|
15
|
+
* \hat{\mathbf r}=\frac{\mathbf r_2-\mathbf r_1}{\|\mathbf r_2-\mathbf r_1\|},\qquad
|
|
16
|
+
* \|\hat{\mathbf r}\|=1
|
|
17
|
+
* $$
|
|
18
|
+
*
|
|
19
|
+
* $$
|
|
20
|
+
* \mathbf F = \|\mathbf F\|\,\hat{\mathbf r}
|
|
21
|
+
* $$
|
|
22
|
+
*
|
|
23
|
+
* And, for context (how the magnitude is obtained in Newtonian gravity):
|
|
24
|
+
*
|
|
25
|
+
* $$
|
|
26
|
+
* \|\mathbf F\| = G\,\frac{m_1 m_2}{\|\mathbf r_2-\mathbf r_1\|^2}
|
|
27
|
+
* $$
|
|
28
|
+
*
|
|
29
|
+
* **Mappings to fields**
|
|
30
|
+
* - `vector` ↔ \( \mathbf F \)
|
|
31
|
+
* - `magnitude` ↔ \( \|\mathbf F\| \)
|
|
32
|
+
* - `direction` ↔ \( \hat{\mathbf r} \)
|
|
33
|
+
*
|
|
34
|
+
* @property vector Force vector on body 1 due to body 2 (N).
|
|
35
|
+
* @property magnitude Scalar magnitude of the force (N).
|
|
36
|
+
* @property direction Unit direction from body 1 to body 2 (dimensionless).
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```ts
|
|
40
|
+
* const res: ForceResultInterface = gravitationalForce(m1, m2, r1, r2);
|
|
41
|
+
* // Invariant checks:
|
|
42
|
+
* const [Fx, Fy, Fz] = res.vector;
|
|
43
|
+
* const magFromVec = Math.hypot(Fx, Fy, Fz);
|
|
44
|
+
* console.assert(Math.abs(magFromVec - res.magnitude) / res.magnitude < 1e-9);
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* @see https://en.wikipedia.org/wiki/Newton%27s_law_of_universal_gravitation
|
|
48
|
+
*/
|
|
49
|
+
export interface ForceResultInterface {
|
|
50
|
+
/** Force vector on body 1 due to body 2 (newtons, N). */
|
|
51
|
+
readonly vector: Vector3DTupleType;
|
|
52
|
+
/** Magnitude (scalar) of the gravitational force (N). */
|
|
53
|
+
readonly magnitude: number;
|
|
54
|
+
/** Unit direction from body 1 to body 2 (dimensionless). */
|
|
55
|
+
readonly direction: Vector3DTupleType;
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=physics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"physics.d.ts","sourceRoot":"","sources":["../src/physics.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAE3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,MAAM,WAAW,oBAAoB;IACnC,yDAAyD;IACzD,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAC;IACnC,yDAAyD;IACzD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,4DAA4D;IAC5D,QAAQ,CAAC,SAAS,EAAE,iBAAiB,CAAC;CACvC"}
|
package/dist/physics.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"physics.js","sourceRoot":"","sources":["../src/physics.ts"],"names":[],"mappings":""}
|
package/dist/temporal.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ import { ValueInterface } from './numeric';
|
|
|
28
28
|
*
|
|
29
29
|
* :::
|
|
30
30
|
*
|
|
31
|
-
* @see https://www.bipm.org/en/publications/si-brochure ([SI](https://en.wikipedia.org/wiki/International_System_of_Units) Brochure
|
|
31
|
+
* @see https://www.bipm.org/en/publications/si-brochure ([SI](https://en.wikipedia.org/wiki/International_System_of_Units) Brochure - second & day)
|
|
32
32
|
* @see https://en.wikipedia.org/wiki/Julian_year_(astronomy) (Julian year used for `yr`)
|
|
33
33
|
* @category Temporal
|
|
34
34
|
*/
|
|
@@ -54,7 +54,7 @@ export type TemporalUnitType = 's' | 'ms' | 'μs' | 'ns' | 'ps' | 'fs' | 'as' |
|
|
|
54
54
|
* 2) Normalize to `TemporalUnitType`.
|
|
55
55
|
* 3) Use only canonical units for arithmetic, storage, and serialization.
|
|
56
56
|
*
|
|
57
|
-
* @see https://www.bipm.org/en/publications/si-brochure ([SI](https://en.wikipedia.org/wiki/International_System_of_Units) Brochure
|
|
57
|
+
* @see https://www.bipm.org/en/publications/si-brochure ([SI](https://en.wikipedia.org/wiki/International_System_of_Units) Brochure - second & day)
|
|
58
58
|
* @see https://en.wikipedia.org/wiki/Julian_year_(astronomy) (Julian year used for `yr`/`kyr`/`Myr`/`Gyr`)
|
|
59
59
|
* @see https://en.wikipedia.org/wiki/Year#SI_multiples (Usage of `ka`/`Ma`/`Ga` vs `kyr`/`Myr`/`Gyr`)
|
|
60
60
|
* @category Temporal
|
package/package.json
CHANGED
|
@@ -1,9 +1,82 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@interstellar-tools/types",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "types",
|
|
5
5
|
"keywords": [
|
|
6
|
-
"types"
|
|
6
|
+
"types",
|
|
7
|
+
"interstellar",
|
|
8
|
+
"tools",
|
|
9
|
+
"near",
|
|
10
|
+
"earth",
|
|
11
|
+
"objects",
|
|
12
|
+
"planets",
|
|
13
|
+
"orbit",
|
|
14
|
+
"rotation",
|
|
15
|
+
"stars",
|
|
16
|
+
"star",
|
|
17
|
+
"sun",
|
|
18
|
+
"planet",
|
|
19
|
+
"earth",
|
|
20
|
+
"moon",
|
|
21
|
+
"mercury",
|
|
22
|
+
"venus",
|
|
23
|
+
"mars",
|
|
24
|
+
"tellus",
|
|
25
|
+
"gaia",
|
|
26
|
+
"jupiter",
|
|
27
|
+
"saturn",
|
|
28
|
+
"neptune",
|
|
29
|
+
"pluto",
|
|
30
|
+
"dwarf",
|
|
31
|
+
"planets",
|
|
32
|
+
"trajectory",
|
|
33
|
+
"asteroids",
|
|
34
|
+
"comets",
|
|
35
|
+
"collision",
|
|
36
|
+
"satellite",
|
|
37
|
+
"satellites",
|
|
38
|
+
"sky map",
|
|
39
|
+
"nasa",
|
|
40
|
+
"jpl",
|
|
41
|
+
"esa",
|
|
42
|
+
"astrodynamics",
|
|
43
|
+
"orbital-mechanics",
|
|
44
|
+
"celestial-mechanics",
|
|
45
|
+
"two-body",
|
|
46
|
+
"n-body",
|
|
47
|
+
"gravity",
|
|
48
|
+
"newtonian-gravity",
|
|
49
|
+
"newtons-law-of-gravitation",
|
|
50
|
+
"gravitational-constant",
|
|
51
|
+
"G_SI",
|
|
52
|
+
"standard-gravitational-parameter",
|
|
53
|
+
"gravitational-parameter",
|
|
54
|
+
"mu",
|
|
55
|
+
"gravitational-force",
|
|
56
|
+
"gravitational-acceleration",
|
|
57
|
+
"specific-mechanical-energy",
|
|
58
|
+
"vis-viva",
|
|
59
|
+
"kepler-period",
|
|
60
|
+
"keplers-third-law",
|
|
61
|
+
"orbital-speed",
|
|
62
|
+
"trajectory",
|
|
63
|
+
"orbit",
|
|
64
|
+
"satellite",
|
|
65
|
+
"simulation",
|
|
66
|
+
"numerics",
|
|
67
|
+
"si-units",
|
|
68
|
+
"vector3",
|
|
69
|
+
"vec3",
|
|
70
|
+
"vector-math",
|
|
71
|
+
"typescript",
|
|
72
|
+
"javascript",
|
|
73
|
+
"interstellar-tools",
|
|
74
|
+
"spaceflight",
|
|
75
|
+
"space-dynamics",
|
|
76
|
+
"heliocentric",
|
|
77
|
+
"leo",
|
|
78
|
+
"geo",
|
|
79
|
+
"earth-sun"
|
|
7
80
|
],
|
|
8
81
|
"homepage": "https://phun-ky.net/projects/interstellar-tools",
|
|
9
82
|
"bugs": {
|