@typeonce/ritmo-math 0.13.0 → 0.15.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/CHANGELOG.md +149 -0
- package/README.md +18 -13
- package/dist/Angle.d.ts +44 -0
- package/dist/Angle.d.ts.map +1 -0
- package/dist/Angle.js +62 -0
- package/dist/Angle.js.map +1 -0
- package/dist/Box2.d.ts +16 -4
- package/dist/Box2.d.ts.map +1 -1
- package/dist/Box2.js +16 -1
- package/dist/Box2.js.map +1 -1
- package/dist/Collide2.d.ts +59 -15
- package/dist/Collide2.d.ts.map +1 -1
- package/dist/Collide2.js +156 -18
- package/dist/Collide2.js.map +1 -1
- package/dist/FlowField.d.ts +24 -38
- package/dist/FlowField.d.ts.map +1 -1
- package/dist/FlowField.js +18 -5
- package/dist/FlowField.js.map +1 -1
- package/dist/Scalar.d.ts +19 -166
- package/dist/Scalar.d.ts.map +1 -1
- package/dist/Scalar.js +51 -51
- package/dist/Scalar.js.map +1 -1
- package/dist/Segment2.d.ts +56 -0
- package/dist/Segment2.d.ts.map +1 -0
- package/dist/Segment2.js +32 -0
- package/dist/Segment2.js.map +1 -0
- package/dist/Vec2.d.ts +47 -7
- package/dist/Vec2.d.ts.map +1 -1
- package/dist/Vec2.js +56 -8
- package/dist/Vec2.js.map +1 -1
- package/dist/index.d.ts +10 -21
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -21
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/Angle.ts +60 -0
- package/src/Box2.ts +20 -4
- package/src/Collide2.ts +171 -24
- package/src/FlowField.ts +34 -10
- package/src/Scalar.ts +43 -165
- package/src/Segment2.ts +71 -0
- package/src/Vec2.ts +58 -8
- package/src/index.ts +10 -21
- package/dist/Aabb.d.ts +0 -182
- package/dist/Aabb.d.ts.map +0 -1
- package/dist/Aabb.js +0 -109
- package/dist/Aabb.js.map +0 -1
- package/dist/InputAxis.d.ts +0 -44
- package/dist/InputAxis.d.ts.map +0 -1
- package/dist/InputAxis.js +0 -71
- package/dist/InputAxis.js.map +0 -1
- package/dist/Ops.d.ts +0 -209
- package/dist/Ops.d.ts.map +0 -1
- package/dist/Ops.js +0 -210
- package/dist/Ops.js.map +0 -1
- package/dist/Random.d.ts +0 -124
- package/dist/Random.d.ts.map +0 -1
- package/dist/Random.js +0 -126
- package/dist/Random.js.map +0 -1
- package/dist/Size2.d.ts +0 -118
- package/dist/Size2.d.ts.map +0 -1
- package/dist/Size2.js +0 -54
- package/dist/Size2.js.map +0 -1
- package/dist/SpatialGrid.d.ts +0 -68
- package/dist/SpatialGrid.d.ts.map +0 -1
- package/dist/SpatialGrid.js +0 -112
- package/dist/SpatialGrid.js.map +0 -1
- package/dist/Vector2.d.ts +0 -214
- package/dist/Vector2.d.ts.map +0 -1
- package/dist/Vector2.js +0 -134
- package/dist/Vector2.js.map +0 -1
- package/dist/internal/aabb.d.ts +0 -27
- package/dist/internal/aabb.d.ts.map +0 -1
- package/dist/internal/aabb.js +0 -52
- package/dist/internal/aabb.js.map +0 -1
- package/dist/internal/codec.d.ts +0 -9
- package/dist/internal/codec.d.ts.map +0 -1
- package/dist/internal/codec.js +0 -16
- package/dist/internal/codec.js.map +0 -1
- package/dist/internal/fdlibm.d.ts +0 -43
- package/dist/internal/fdlibm.d.ts.map +0 -1
- package/dist/internal/fdlibm.js +0 -1291
- package/dist/internal/fdlibm.js.map +0 -1
- package/dist/internal/inputAxis.d.ts +0 -11
- package/dist/internal/inputAxis.d.ts.map +0 -1
- package/dist/internal/inputAxis.js +0 -13
- package/dist/internal/inputAxis.js.map +0 -1
- package/dist/internal/scalar.d.ts +0 -11
- package/dist/internal/scalar.d.ts.map +0 -1
- package/dist/internal/scalar.js +0 -68
- package/dist/internal/scalar.js.map +0 -1
- package/dist/internal/size2.d.ts +0 -22
- package/dist/internal/size2.d.ts.map +0 -1
- package/dist/internal/size2.js +0 -38
- package/dist/internal/size2.js.map +0 -1
- package/dist/internal/vector2.d.ts +0 -39
- package/dist/internal/vector2.d.ts.map +0 -1
- package/dist/internal/vector2.js +0 -78
- package/dist/internal/vector2.js.map +0 -1
- package/src/Aabb.ts +0 -180
- package/src/InputAxis.ts +0 -81
- package/src/Ops.ts +0 -232
- package/src/Random.ts +0 -225
- package/src/Size2.ts +0 -122
- package/src/SpatialGrid.ts +0 -172
- package/src/Vector2.ts +0 -216
- package/src/internal/aabb.ts +0 -81
- package/src/internal/codec.ts +0 -21
- package/src/internal/fdlibm.ts +0 -1256
- package/src/internal/inputAxis.ts +0 -21
- package/src/internal/scalar.ts +0 -104
- package/src/internal/size2.ts +0 -54
- package/src/internal/vector2.ts +0 -121
package/dist/Vector2.d.ts
DELETED
|
@@ -1,214 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Branded two-dimensional vectors with explicit validation.
|
|
3
|
-
*
|
|
4
|
-
* Raw `{ x, y }` input is validated once at the constructor boundary. All
|
|
5
|
-
* other helpers work on branded vectors only and remain pure and immutable.
|
|
6
|
-
*
|
|
7
|
-
* This is the common math value that game code threads through position,
|
|
8
|
-
* velocity, input direction, camera motion, and collision helpers. Use it when
|
|
9
|
-
* vectors should stay explicitly validated and reusable across ECS and helper
|
|
10
|
-
* modules. For per-frame arithmetic on numbers already known to be sane, use
|
|
11
|
-
* `Vec2` (a `Vector2` is a `Vec2`, so it passes without conversion).
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```ts
|
|
15
|
-
* // Validate one raw velocity before storing or reusing it elsewhere.
|
|
16
|
-
* const velocity = Vector2.result({ x: 3, y: 4 })
|
|
17
|
-
* if (!velocity.ok) return
|
|
18
|
-
*
|
|
19
|
-
* // Derive a movement direction from the branded vector.
|
|
20
|
-
* const direction = Vector2.normalizeOrZero(velocity.value)
|
|
21
|
-
* ```
|
|
22
|
-
*
|
|
23
|
-
* @module Vector2
|
|
24
|
-
* @docGroup data-structures
|
|
25
|
-
*
|
|
26
|
-
* @categoryDescription Vector Types
|
|
27
|
-
* Raw, branded, and error shapes used to describe validated two-dimensional vectors.
|
|
28
|
-
*
|
|
29
|
-
* @categoryDescription Construction
|
|
30
|
-
* Non-throwing constructor boundaries that validate raw input and produce branded vectors.
|
|
31
|
-
*
|
|
32
|
-
* @categoryDescription Accessors
|
|
33
|
-
* Pure readers and views that expose branded vector components without mutation.
|
|
34
|
-
*
|
|
35
|
-
* @categoryDescription Operations
|
|
36
|
-
* Immutable vector math and normalization helpers on already-validated values.
|
|
37
|
-
*/
|
|
38
|
-
import type * as Brand from "@typeonce/ritmo/Brand";
|
|
39
|
-
import type { StandardSchema } from "@typeonce/ritmo/Descriptor";
|
|
40
|
-
import type * as Result from "@typeonce/ritmo/Result";
|
|
41
|
-
import type * as Scalar from "./Scalar.ts";
|
|
42
|
-
/**
|
|
43
|
-
* Raw vector input accepted by the public constructors.
|
|
44
|
-
*
|
|
45
|
-
* @category Vector Types
|
|
46
|
-
*/
|
|
47
|
-
export type Raw = {
|
|
48
|
-
readonly x: number;
|
|
49
|
-
readonly y: number;
|
|
50
|
-
};
|
|
51
|
-
/**
|
|
52
|
-
* Validated two-dimensional vector.
|
|
53
|
-
*
|
|
54
|
-
* @category Vector Types
|
|
55
|
-
*/
|
|
56
|
-
export type Vector2 = Brand.Branded<{
|
|
57
|
-
readonly x: Scalar.Finite;
|
|
58
|
-
readonly y: Scalar.Finite;
|
|
59
|
-
}, "Vector2">;
|
|
60
|
-
/**
|
|
61
|
-
* Structured vector-construction failure.
|
|
62
|
-
*
|
|
63
|
-
* @category Vector Types
|
|
64
|
-
*/
|
|
65
|
-
export type Error = {
|
|
66
|
-
readonly tag: "Vector2/Invalid";
|
|
67
|
-
readonly x: Scalar.Error | null;
|
|
68
|
-
readonly y: Scalar.Error | null;
|
|
69
|
-
readonly input: Raw;
|
|
70
|
-
};
|
|
71
|
-
/**
|
|
72
|
-
* Explicit failure produced when a zero-length vector cannot be normalized.
|
|
73
|
-
*
|
|
74
|
-
* @category Vector Types
|
|
75
|
-
*/
|
|
76
|
-
export type NormalizeError = {
|
|
77
|
-
readonly tag: "Vector2/ZeroLength";
|
|
78
|
-
};
|
|
79
|
-
/**
|
|
80
|
-
* Validates one raw vector and returns an explicit result.
|
|
81
|
-
*
|
|
82
|
-
* @example
|
|
83
|
-
* ```ts
|
|
84
|
-
* const position = Vector2.result({ x: 16, y: 24 })
|
|
85
|
-
* ```
|
|
86
|
-
*
|
|
87
|
-
* @category Construction
|
|
88
|
-
*/
|
|
89
|
-
export declare const result: (raw: Raw) => Result.Result<Vector2, Error>;
|
|
90
|
-
/**
|
|
91
|
-
* The codec of `Vector2` (a Standard Schema, see `Descriptor.Codec`): give it to
|
|
92
|
-
* `Descriptor.ConstructedComponent(...)` so raw input and saves are validated.
|
|
93
|
-
* Its saved form is the raw shape, so it needs no `encode`. To put a `Vector2`
|
|
94
|
-
* inside your own object schema, use {@link is} with your library's guard
|
|
95
|
-
* schema (`Schema.declare`, `z.custom`).
|
|
96
|
-
*
|
|
97
|
-
* @example
|
|
98
|
-
* ```ts
|
|
99
|
-
* const Position = Descriptor.ConstructedComponent(Vector2.codec)("Game/Position")
|
|
100
|
-
* ```
|
|
101
|
-
*
|
|
102
|
-
* @category Construction
|
|
103
|
-
*/
|
|
104
|
-
export declare const codec: StandardSchema<Raw, Vector2>;
|
|
105
|
-
/**
|
|
106
|
-
* Validates one raw vector and returns `null` on failure.
|
|
107
|
-
*
|
|
108
|
-
* @category Construction
|
|
109
|
-
*/
|
|
110
|
-
export declare const option: (raw: Raw) => Vector2 | null;
|
|
111
|
-
/**
|
|
112
|
-
* Whether any value is a valid `Vector2`: a guard, also for building a
|
|
113
|
-
* `Vector2` field in your own schema (`Schema.declare(Vector2.is)`).
|
|
114
|
-
*
|
|
115
|
-
* @category Construction
|
|
116
|
-
*/
|
|
117
|
-
export declare const is: (raw: unknown) => raw is Vector2;
|
|
118
|
-
/**
|
|
119
|
-
* Converts one branded vector back to a fresh raw object.
|
|
120
|
-
*
|
|
121
|
-
* @category Accessors
|
|
122
|
-
*/
|
|
123
|
-
export declare const toRaw: (vector: Vector2) => Raw;
|
|
124
|
-
/**
|
|
125
|
-
* Exposes the branded components of one vector.
|
|
126
|
-
*
|
|
127
|
-
* @category Accessors
|
|
128
|
-
*/
|
|
129
|
-
export declare const components: (vector: Vector2) => {
|
|
130
|
-
readonly x: Scalar.Finite;
|
|
131
|
-
readonly y: Scalar.Finite;
|
|
132
|
-
};
|
|
133
|
-
/**
|
|
134
|
-
* Reads the `x` component of one branded vector.
|
|
135
|
-
*
|
|
136
|
-
* @category Accessors
|
|
137
|
-
*/
|
|
138
|
-
export declare const x: (vector: Vector2) => Scalar.Finite;
|
|
139
|
-
/**
|
|
140
|
-
* Reads the `y` component of one branded vector.
|
|
141
|
-
*
|
|
142
|
-
* @category Accessors
|
|
143
|
-
*/
|
|
144
|
-
export declare const y: (vector: Vector2) => Scalar.Finite;
|
|
145
|
-
/**
|
|
146
|
-
* Returns the canonical zero vector.
|
|
147
|
-
*
|
|
148
|
-
* @category Construction
|
|
149
|
-
*/
|
|
150
|
-
export declare const zero: () => Vector2;
|
|
151
|
-
/**
|
|
152
|
-
* Returns the sum of two branded vectors.
|
|
153
|
-
*
|
|
154
|
-
* Keeps the brands without re-validating: finite while the result stays
|
|
155
|
-
* within `±Number.MAX_VALUE` (see `Scalar.Finite`).
|
|
156
|
-
*
|
|
157
|
-
* @category Operations
|
|
158
|
-
*/
|
|
159
|
-
export declare const add: (left: Vector2, right: Vector2) => Vector2;
|
|
160
|
-
/**
|
|
161
|
-
* Returns the component-wise difference between two branded vectors.
|
|
162
|
-
*
|
|
163
|
-
* Keeps the brands without re-validating: finite while the result stays
|
|
164
|
-
* within `±Number.MAX_VALUE` (see `Scalar.Finite`).
|
|
165
|
-
*
|
|
166
|
-
* @category Operations
|
|
167
|
-
*/
|
|
168
|
-
export declare const subtract: (left: Vector2, right: Vector2) => Vector2;
|
|
169
|
-
/**
|
|
170
|
-
* Scales one vector by one validated finite scalar.
|
|
171
|
-
*
|
|
172
|
-
* Keeps the brands without re-validating: finite while the result stays
|
|
173
|
-
* within `±Number.MAX_VALUE` (see `Scalar.Finite`).
|
|
174
|
-
*
|
|
175
|
-
* @category Operations
|
|
176
|
-
*/
|
|
177
|
-
export declare const scale: (vector: Vector2, scalar: Scalar.Finite) => Vector2;
|
|
178
|
-
/**
|
|
179
|
-
* Returns the squared length of one vector.
|
|
180
|
-
*
|
|
181
|
-
* Keeps the brands without re-validating: finite while the result stays
|
|
182
|
-
* within `±Number.MAX_VALUE` (see `Scalar.Finite`).
|
|
183
|
-
*
|
|
184
|
-
* @category Operations
|
|
185
|
-
*/
|
|
186
|
-
export declare const lengthSquared: (vector: Vector2) => Scalar.NonNegative;
|
|
187
|
-
/**
|
|
188
|
-
* Returns the length of one vector.
|
|
189
|
-
*
|
|
190
|
-
* @category Operations
|
|
191
|
-
*/
|
|
192
|
-
export declare const length: (vector: Vector2) => Scalar.NonNegative;
|
|
193
|
-
/**
|
|
194
|
-
* Returns the normalized vector when its length is non-zero.
|
|
195
|
-
*
|
|
196
|
-
* @example
|
|
197
|
-
* ```ts
|
|
198
|
-
* const direction = Vector2.normalize(Vector2.zero())
|
|
199
|
-
* if (!direction.ok) {
|
|
200
|
-
* return
|
|
201
|
-
* }
|
|
202
|
-
* ```
|
|
203
|
-
*
|
|
204
|
-
* @category Operations
|
|
205
|
-
*/
|
|
206
|
-
export declare const normalize: (vector: Vector2) => Result.Result<Vector2, NormalizeError>;
|
|
207
|
-
/**
|
|
208
|
-
* Returns the normalized vector or the canonical zero vector when the input
|
|
209
|
-
* length is zero.
|
|
210
|
-
*
|
|
211
|
-
* @category Operations
|
|
212
|
-
*/
|
|
213
|
-
export declare const normalizeOrZero: (vector: Vector2) => Vector2;
|
|
214
|
-
//# sourceMappingURL=Vector2.d.ts.map
|
package/dist/Vector2.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Vector2.d.ts","sourceRoot":"","sources":["../src/Vector2.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C,CAAA;AAC5F;;;;GAIG;AACH,eAAO,MAAM,MAAM,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,MAAM,CAAC,WAA6B,CAAA;AAC9E;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,SAAS,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,cAAc,CAAsB,CAAA;AACxG;;;;;GAKG;AACH,eAAO,MAAM,eAAe,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,OAAkC,CAAA"}
|
package/dist/Vector2.js
DELETED
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import * as internal from "./internal/vector2.js";
|
|
2
|
-
/**
|
|
3
|
-
* Validates one raw vector and returns an explicit result.
|
|
4
|
-
*
|
|
5
|
-
* @example
|
|
6
|
-
* ```ts
|
|
7
|
-
* const position = Vector2.result({ x: 16, y: 24 })
|
|
8
|
-
* ```
|
|
9
|
-
*
|
|
10
|
-
* @category Construction
|
|
11
|
-
*/
|
|
12
|
-
export const result = internal.result;
|
|
13
|
-
/**
|
|
14
|
-
* The codec of `Vector2` (a Standard Schema, see `Descriptor.Codec`): give it to
|
|
15
|
-
* `Descriptor.ConstructedComponent(...)` so raw input and saves are validated.
|
|
16
|
-
* Its saved form is the raw shape, so it needs no `encode`. To put a `Vector2`
|
|
17
|
-
* inside your own object schema, use {@link is} with your library's guard
|
|
18
|
-
* schema (`Schema.declare`, `z.custom`).
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* ```ts
|
|
22
|
-
* const Position = Descriptor.ConstructedComponent(Vector2.codec)("Game/Position")
|
|
23
|
-
* ```
|
|
24
|
-
*
|
|
25
|
-
* @category Construction
|
|
26
|
-
*/
|
|
27
|
-
export const codec = internal.codec;
|
|
28
|
-
/**
|
|
29
|
-
* Validates one raw vector and returns `null` on failure.
|
|
30
|
-
*
|
|
31
|
-
* @category Construction
|
|
32
|
-
*/
|
|
33
|
-
export const option = internal.option;
|
|
34
|
-
/**
|
|
35
|
-
* Whether any value is a valid `Vector2`: a guard, also for building a
|
|
36
|
-
* `Vector2` field in your own schema (`Schema.declare(Vector2.is)`).
|
|
37
|
-
*
|
|
38
|
-
* @category Construction
|
|
39
|
-
*/
|
|
40
|
-
export const is = internal.is;
|
|
41
|
-
/**
|
|
42
|
-
* Converts one branded vector back to a fresh raw object.
|
|
43
|
-
*
|
|
44
|
-
* @category Accessors
|
|
45
|
-
*/
|
|
46
|
-
export const toRaw = internal.toRaw;
|
|
47
|
-
/**
|
|
48
|
-
* Exposes the branded components of one vector.
|
|
49
|
-
*
|
|
50
|
-
* @category Accessors
|
|
51
|
-
*/
|
|
52
|
-
export const components = internal.components;
|
|
53
|
-
/**
|
|
54
|
-
* Reads the `x` component of one branded vector.
|
|
55
|
-
*
|
|
56
|
-
* @category Accessors
|
|
57
|
-
*/
|
|
58
|
-
export const x = internal.x;
|
|
59
|
-
/**
|
|
60
|
-
* Reads the `y` component of one branded vector.
|
|
61
|
-
*
|
|
62
|
-
* @category Accessors
|
|
63
|
-
*/
|
|
64
|
-
export const y = internal.y;
|
|
65
|
-
/**
|
|
66
|
-
* Returns the canonical zero vector.
|
|
67
|
-
*
|
|
68
|
-
* @category Construction
|
|
69
|
-
*/
|
|
70
|
-
export const zero = internal.zero;
|
|
71
|
-
/**
|
|
72
|
-
* Returns the sum of two branded vectors.
|
|
73
|
-
*
|
|
74
|
-
* Keeps the brands without re-validating: finite while the result stays
|
|
75
|
-
* within `±Number.MAX_VALUE` (see `Scalar.Finite`).
|
|
76
|
-
*
|
|
77
|
-
* @category Operations
|
|
78
|
-
*/
|
|
79
|
-
export const add = internal.add;
|
|
80
|
-
/**
|
|
81
|
-
* Returns the component-wise difference between two branded vectors.
|
|
82
|
-
*
|
|
83
|
-
* Keeps the brands without re-validating: finite while the result stays
|
|
84
|
-
* within `±Number.MAX_VALUE` (see `Scalar.Finite`).
|
|
85
|
-
*
|
|
86
|
-
* @category Operations
|
|
87
|
-
*/
|
|
88
|
-
export const subtract = internal.subtract;
|
|
89
|
-
/**
|
|
90
|
-
* Scales one vector by one validated finite scalar.
|
|
91
|
-
*
|
|
92
|
-
* Keeps the brands without re-validating: finite while the result stays
|
|
93
|
-
* within `±Number.MAX_VALUE` (see `Scalar.Finite`).
|
|
94
|
-
*
|
|
95
|
-
* @category Operations
|
|
96
|
-
*/
|
|
97
|
-
export const scale = internal.scale;
|
|
98
|
-
/**
|
|
99
|
-
* Returns the squared length of one vector.
|
|
100
|
-
*
|
|
101
|
-
* Keeps the brands without re-validating: finite while the result stays
|
|
102
|
-
* within `±Number.MAX_VALUE` (see `Scalar.Finite`).
|
|
103
|
-
*
|
|
104
|
-
* @category Operations
|
|
105
|
-
*/
|
|
106
|
-
export const lengthSquared = internal.lengthSquared;
|
|
107
|
-
/**
|
|
108
|
-
* Returns the length of one vector.
|
|
109
|
-
*
|
|
110
|
-
* @category Operations
|
|
111
|
-
*/
|
|
112
|
-
export const length = internal.length;
|
|
113
|
-
/**
|
|
114
|
-
* Returns the normalized vector when its length is non-zero.
|
|
115
|
-
*
|
|
116
|
-
* @example
|
|
117
|
-
* ```ts
|
|
118
|
-
* const direction = Vector2.normalize(Vector2.zero())
|
|
119
|
-
* if (!direction.ok) {
|
|
120
|
-
* return
|
|
121
|
-
* }
|
|
122
|
-
* ```
|
|
123
|
-
*
|
|
124
|
-
* @category Operations
|
|
125
|
-
*/
|
|
126
|
-
export const normalize = internal.normalize;
|
|
127
|
-
/**
|
|
128
|
-
* Returns the normalized vector or the canonical zero vector when the input
|
|
129
|
-
* length is zero.
|
|
130
|
-
*
|
|
131
|
-
* @category Operations
|
|
132
|
-
*/
|
|
133
|
-
export const normalizeOrZero = internal.normalizeOrZero;
|
|
134
|
-
//# sourceMappingURL=Vector2.js.map
|
package/dist/Vector2.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Vector2.js","sourceRoot":"","sources":["../src/Vector2.ts"],"names":[],"mappings":"A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AAQ,CAAC,SAAS,CAAA;AACxG;;;;;GAKG;AACH,MAAM,CAAC,MAAM,eAAe,GAAiC,QAAQ,CAAC,eAAe,CAAA"}
|
package/dist/internal/aabb.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import * as Result from "@typeonce/ritmo/Result";
|
|
2
|
-
import * as Size2 from "../Size2.ts";
|
|
3
|
-
import * as Vector2 from "../Vector2.ts";
|
|
4
|
-
import type * as Aabb from "../Aabb.ts";
|
|
5
|
-
import type * as Scalar from "../Scalar.ts";
|
|
6
|
-
export declare const result: (raw: Aabb.Raw) => Result.Result<Aabb.Aabb, Aabb.Error>;
|
|
7
|
-
export declare const option: (raw: Aabb.Raw) => Aabb.Aabb | null;
|
|
8
|
-
export declare const is: (raw: unknown) => raw is Aabb.Aabb;
|
|
9
|
-
export declare const position: (aabb: Aabb.Aabb) => Vector2.Vector2;
|
|
10
|
-
export declare const size: (aabb: Aabb.Aabb) => Size2.Size2;
|
|
11
|
-
export declare const left: (aabb: Aabb.Aabb) => Scalar.Finite;
|
|
12
|
-
export declare const right: (aabb: Aabb.Aabb) => Scalar.Finite;
|
|
13
|
-
export declare const top: (aabb: Aabb.Aabb) => Scalar.Finite;
|
|
14
|
-
export declare const bottom: (aabb: Aabb.Aabb) => Scalar.Finite;
|
|
15
|
-
export declare const intersects: (first: Aabb.Aabb, second: Aabb.Aabb) => boolean;
|
|
16
|
-
export declare const overlapsHorizontally: (first: Aabb.Aabb, second: Aabb.Aabb) => boolean;
|
|
17
|
-
export declare const overlapsVertically: (first: Aabb.Aabb, second: Aabb.Aabb) => boolean;
|
|
18
|
-
export declare const translate: (aabb: Aabb.Aabb, delta: Vector2.Vector2) => Aabb.Aabb;
|
|
19
|
-
/** Untrusted input without the raw shape. */
|
|
20
|
-
type Malformed = {
|
|
21
|
-
readonly tag: "Aabb/Malformed";
|
|
22
|
-
readonly input: unknown;
|
|
23
|
-
};
|
|
24
|
-
export declare const decode: (raw: unknown) => Result.Result<Aabb.Aabb, Aabb.Error | Malformed>;
|
|
25
|
-
export declare const codec: import("@typeonce/ritmo/Descriptor").StandardSchema<Aabb.Raw, Aabb.Aabb>;
|
|
26
|
-
export {};
|
|
27
|
-
//# sourceMappingURL=aabb.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"aabb.d.ts","sourceRoot":"","sources":["../../src/internal/aabb.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,MAAM,wBAAwB,CAAA;AAChD,OAAO,KAAK,KAAK,MAAM,aAAa,CAAA;AACpC,OAAO,KAAK,OAAO,MAAM,eAAe,CAAA;AACxC,OAAO,KAAK,KAAK,IAAI,MAAM,YAAY,CAAA;AACvC,OAAO,KAAK,KAAK,MAAM,MAAM,cAAc,CAAA;AAO3C,eAAO,MAAM,MAAM,QAAS,IAAI,CAAC,GAAG,KAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAoBzE,CAAA;AAED,eAAO,MAAM,MAAM,QAAS,IAAI,CAAC,GAAG,KAAG,IAAI,CAAC,IAAI,GAAG,IAGlD,CAAA;AAED,eAAO,MAAM,EAAE,QAAS,OAAO,KAAG,GAAG,IAAI,IAAI,CAAC,IAAsB,CAAA;AAEpE,eAAO,MAAM,QAAQ,SAAU,IAAI,CAAC,IAAI,KAAG,OAAO,CAAC,OAAwB,CAAA;AAC3E,eAAO,MAAM,IAAI,SAAU,IAAI,CAAC,IAAI,KAAG,KAAK,CAAC,KAAkB,CAAA;AAE/D,eAAO,MAAM,IAAI,SAAU,IAAI,CAAC,IAAI,KAAG,MAAM,CAAC,MACc,CAAA;AAE5D,eAAO,MAAM,KAAK,SAAU,IAAI,CAAC,IAAI,KAAG,MAAM,CAAC,MACa,CAAA;AAE5D,eAAO,MAAM,GAAG,SAAU,IAAI,CAAC,IAAI,KAAG,MAAM,CAAC,MACgB,CAAA;AAE7D,eAAO,MAAM,MAAM,SAAU,IAAI,CAAC,IAAI,KAAG,MAAM,CAAC,MACa,CAAA;AAE7D,eAAO,MAAM,UAAU,UAAW,IAAI,CAAC,IAAI,UAAU,IAAI,CAAC,IAAI,KAAG,OAE4B,CAAA;AAE7F,eAAO,MAAM,oBAAoB,UAAW,IAAI,CAAC,IAAI,UAAU,IAAI,CAAC,IAAI,KAAG,OACf,CAAA;AAE5D,eAAO,MAAM,kBAAkB,UAAW,IAAI,CAAC,IAAI,UAAU,IAAI,CAAC,IAAI,KAAG,OACb,CAAA;AAE5D,eAAO,MAAM,SAAS,SAAU,IAAI,CAAC,IAAI,SAAS,OAAO,CAAC,OAAO,KAAG,IAAI,CAAC,IACrB,CAAA;AAEpD,6CAA6C;AAC7C,KAAK,SAAS,GAAG;IAAE,QAAQ,CAAC,GAAG,EAAE,gBAAgB,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAAA;AAE5E,eAAO,MAAM,MAAM,QAAS,OAAO,KAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,GAAG,SAAS,CAMpF,CAAA;AAED,eAAO,MAAM,KAAK,0EAAmH,CAAA"}
|
package/dist/internal/aabb.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { codecOf } from "./codec.js";
|
|
2
|
-
import * as Result from "@typeonce/ritmo/Result";
|
|
3
|
-
import * as Size2 from "../Size2.js";
|
|
4
|
-
import * as Vector2 from "../Vector2.js";
|
|
5
|
-
import { isRawShape as isSize2Shape } from "./size2.js";
|
|
6
|
-
import { isRawShape as isVector2Shape } from "./vector2.js";
|
|
7
|
-
const make = (position, size) => ({ position, size });
|
|
8
|
-
export const result = (raw) => {
|
|
9
|
-
const position = Vector2.result(raw.position);
|
|
10
|
-
if (!position.ok) {
|
|
11
|
-
return Result.failure({
|
|
12
|
-
tag: "Aabb/InvalidPosition",
|
|
13
|
-
error: position.error,
|
|
14
|
-
input: raw
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
const size = Size2.result(raw.size);
|
|
18
|
-
if (!size.ok) {
|
|
19
|
-
return Result.failure({
|
|
20
|
-
tag: "Aabb/InvalidSize",
|
|
21
|
-
error: size.error,
|
|
22
|
-
input: raw
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
return Result.success(make(position.value, size.value));
|
|
26
|
-
};
|
|
27
|
-
export const option = (raw) => {
|
|
28
|
-
const next = result(raw);
|
|
29
|
-
return next.ok ? next.value : null;
|
|
30
|
-
};
|
|
31
|
-
export const is = (raw) => decode(raw).ok;
|
|
32
|
-
export const position = (aabb) => aabb.position;
|
|
33
|
-
export const size = (aabb) => aabb.size;
|
|
34
|
-
export const left = (aabb) => (aabb.position.x - aabb.size.width * 0.5);
|
|
35
|
-
export const right = (aabb) => (aabb.position.x + aabb.size.width * 0.5);
|
|
36
|
-
export const top = (aabb) => (aabb.position.y - aabb.size.height * 0.5);
|
|
37
|
-
export const bottom = (aabb) => (aabb.position.y + aabb.size.height * 0.5);
|
|
38
|
-
export const intersects = (first, second) => Math.abs(first.position.x - second.position.x) * 2 < first.size.width + second.size.width &&
|
|
39
|
-
Math.abs(first.position.y - second.position.y) * 2 < first.size.height + second.size.height;
|
|
40
|
-
export const overlapsHorizontally = (first, second) => right(first) > left(second) && left(first) < right(second);
|
|
41
|
-
export const overlapsVertically = (first, second) => bottom(first) > top(second) && top(first) < bottom(second);
|
|
42
|
-
export const translate = (aabb, delta) => make(Vector2.add(aabb.position, delta), aabb.size);
|
|
43
|
-
export const decode = (raw) => {
|
|
44
|
-
if (typeof raw !== "object" || raw === null)
|
|
45
|
-
return Result.failure({ tag: "Aabb/Malformed", input: raw });
|
|
46
|
-
const { position, size } = raw;
|
|
47
|
-
return isVector2Shape(position) && isSize2Shape(size)
|
|
48
|
-
? result({ position, size })
|
|
49
|
-
: Result.failure({ tag: "Aabb/Malformed", input: raw });
|
|
50
|
-
};
|
|
51
|
-
export const codec = codecOf(decode, "a box { x, y, width, height } of finite numbers with a non-negative size");
|
|
52
|
-
//# sourceMappingURL=aabb.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"aabb.js","sourceRoot":"","sources":["../../src/internal/aabb.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AACpC,OAAO,KAAK,MAAM,MAAM,wBAAwB,CAAA;AAChD,OAAO,KAAK,KAAK,MAAM,aAAa,CAAA;AACpC,OAAO,KAAK,OAAO,MAAM,eAAe,CAAA;AAGxC,OAAO,EAAE,UAAU,IAAI,YAAY,EAAE,MAAM,YAAY,CAAA;AACvD,OAAO,EAAE,UAAU,IAAI,cAAc,EAAE,MAAM,cAAc,CAAA;AAE3D,MAAM,IAAI,GAAG,CAAC,QAAyB,EAAE,IAAiB,EAAa,EAAE,CACvE,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAc,CAAA;AAEnC,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,GAAa,EAAwC,EAAE;IAC5E,MAAM,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;IAC7C,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,OAAO,MAAM,CAAC,OAAO,CAAC;YACpB,GAAG,EAAE,sBAAsB;YAC3B,KAAK,EAAE,QAAQ,CAAC,KAAK;YACrB,KAAK,EAAE,GAAG;SACX,CAAC,CAAA;IACJ,CAAC;IAED,MAAM,IAAI,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;IACnC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC;QACb,OAAO,MAAM,CAAC,OAAO,CAAC;YACpB,GAAG,EAAE,kBAAkB;YACvB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,KAAK,EAAE,GAAG;SACX,CAAC,CAAA;IACJ,CAAC;IAED,OAAO,MAAM,CAAC,OAAO,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AK,IAAI;QAAE,OAAO,MAAM,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,gBAAgB,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAA;IACzG,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,GAA8B,CAAA;IACzD,OAAO,cAAc,CAAC,QAAQ,CAAC,IAAI,YAAY,CAAC,IAAI,CAAC;QACnD,CAAC,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;QAC5B,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,gBAAgB,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAA;AAC3D,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,KAAK,GAAG,OAAO,CAAsB,MAAM,EAAE,0EAA0E,CAAC,CAAA"}
|
package/dist/internal/codec.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { StandardSchema } from "@typeonce/ritmo/Descriptor";
|
|
2
|
-
import type * as Result from "@typeonce/ritmo/Result";
|
|
3
|
-
/**
|
|
4
|
-
* The codec of one math type, from its decode: a Standard Schema whose saved
|
|
5
|
-
* form is the raw shape. The value is already plain data, so it needs no
|
|
6
|
-
* `encode`.
|
|
7
|
-
*/
|
|
8
|
-
export declare const codecOf: <Raw, Value>(decode: (raw: unknown) => Result.Result<Value, unknown>, expected: string) => StandardSchema<Raw, Value>;
|
|
9
|
-
//# sourceMappingURL=codec.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"codec.d.ts","sourceRoot":"","sources":["../../src/internal/codec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAChE,OAAO,KAAK,KAAK,MAAM,MAAM,wBAAwB,CAAA;AAErD;;;;GAIG;AACH,eAAO,MAAM,OAAO,GAAI,GAAG,EAAE,KAAK,UACxB,CAAC,GAAG,EAAE,OAAO,KAAK,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,YAC7C,MAAM,KACf,cAAc,CAAC,GAAG,EAAE,KAAK,CAS1B,CAAA"}
|
package/dist/internal/codec.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The codec of one math type, from its decode: a Standard Schema whose saved
|
|
3
|
-
* form is the raw shape. The value is already plain data, so it needs no
|
|
4
|
-
* `encode`.
|
|
5
|
-
*/
|
|
6
|
-
export const codecOf = (decode, expected) => ({
|
|
7
|
-
"~standard": {
|
|
8
|
-
version: 1,
|
|
9
|
-
vendor: "ritmo-math",
|
|
10
|
-
validate: (raw) => {
|
|
11
|
-
const value = decode(raw);
|
|
12
|
-
return value.ok ? { value: value.value } : { issues: [{ message: `Expected ${expected}` }] };
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
//# sourceMappingURL=codec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"codec.js","sourceRoot":"","sources":["../../src/internal/codec.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,CACrB,MAAuD,EACvD,QAAgB,EACY,EAAE,CAAC,CAAC;IAChC,WAAW,EAAE;QACX,OAAO,EAAE,CAAC;QACV,MAAM,EAAE,YAAY;QACpB,QAAQ,EAAE,CAAC,GAAG,EAAE,EAAE;YAChB,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAA;YACzB,OAAO,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,OAAO,EAAE,YAAY,QAAQ,EAAE,EAAE,CAAC,EAAE,CAAA;QAC9F,CAAC;KACF;CACF,CAAC,CAAA"}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Pure-JavaScript ports of FreeBSD msun / musl libm (originally Sun fdlibm),
|
|
3
|
-
* built only from `+ - * /`, `Math.sqrt`, and bit access. ECMAScript rounds
|
|
4
|
-
* each of those exactly, so every engine and CPU returns the same bits.
|
|
5
|
-
*
|
|
6
|
-
* Copyright (C) 1993-2004 by Sun Microsystems, Inc. All rights reserved.
|
|
7
|
-
* Developed at SunSoft, a Sun Microsystems, Inc. business.
|
|
8
|
-
* Permission to use, copy, modify, and distribute this software is freely
|
|
9
|
-
* granted, provided that this notice is preserved.
|
|
10
|
-
*
|
|
11
|
-
* musl libm is MIT licensed, Copyright (c) 2005-2020 Rich Felker, et al.
|
|
12
|
-
*
|
|
13
|
-
* Changes from the C sources: results follow ECMAScript where it differs from
|
|
14
|
-
* C (`pow(1, NaN)` and `pow(±1, ±Infinity)` are NaN), arguments of sin,
|
|
15
|
-
* cos, and tan beyond 2^20·π/2 are reduced exactly with BigInt instead of
|
|
16
|
-
* `__rem_pio2_large`, and `exp(1)` returns `Math.E`.
|
|
17
|
-
*
|
|
18
|
-
* @internal
|
|
19
|
-
*/
|
|
20
|
-
export declare const sin: (x: number) => number;
|
|
21
|
-
export declare const cos: (x: number) => number;
|
|
22
|
-
export declare const tan: (x: number) => number;
|
|
23
|
-
export declare const asin: (x: number) => number;
|
|
24
|
-
export declare const acos: (x: number) => number;
|
|
25
|
-
export declare const atan: (xIn: number) => number;
|
|
26
|
-
export declare const atan2: (y: number, x: number) => number;
|
|
27
|
-
export declare const exp: (xIn: number) => number;
|
|
28
|
-
/** e^x − 1, accurate near 0. */
|
|
29
|
-
export declare const expm1: (xIn: number) => number;
|
|
30
|
-
export declare const tanh: (xIn: number) => number;
|
|
31
|
-
export declare const pow: (x: number, y: number) => number;
|
|
32
|
-
export declare const hypot: (xIn: number, yIn: number) => number;
|
|
33
|
-
export declare const log: (x: number) => number;
|
|
34
|
-
export declare const log2: (x: number) => number;
|
|
35
|
-
export declare const log10: (x: number) => number;
|
|
36
|
-
export declare const log1p: (x: number) => number;
|
|
37
|
-
export declare const sinh: (x: number) => number;
|
|
38
|
-
export declare const cosh: (xIn: number) => number;
|
|
39
|
-
export declare const asinh: (x: number) => number;
|
|
40
|
-
export declare const acosh: (x: number) => number;
|
|
41
|
-
export declare const atanh: (xIn: number) => number;
|
|
42
|
-
export declare const cbrt: (x: number) => number;
|
|
43
|
-
//# sourceMappingURL=fdlibm.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fdlibm.d.ts","sourceRoot":"","sources":["../../src/internal/fdlibm.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAoRH,eAAO,MAAM,GAAG,MAAO,MAAM,KAAG,MAkB/B,CAAA;AAED,eAAO,MAAM,GAAG,MAAO,MAAM,KAAG,MAkB/B,CAAA;AAED,eAAO,MAAM,GAAG,MAAO,MAAM,KAAG,MAS/B,CAAA;AAwBD,eAAO,MAAM,IAAI,MAAO,MAAM,KAAG,MA2BhC,CAAA;AAED,eAAO,MAAM,IAAI,MAAO,MAAM,KAAG,MA2BhC,CAAA;AA4BD,eAAO,MAAM,IAAI,QAAS,MAAM,KAAG,MA6ClC,CAAA;AAKD,eAAO,MAAM,KAAK,MAAO,MAAM,KAAK,MAAM,KAAG,MA8D5C,CAAA;AAcD,eAAO,MAAM,GAAG,QAAS,MAAM,KAAG,MAoCjC,CAAA;AASD,gCAAgC;AAChC,eAAO,MAAM,KAAK,QAAS,MAAM,KAAG,MA6DnC,CAAA;AAED,eAAO,MAAM,IAAI,QAAS,MAAM,KAAG,MAwBlC,CAAA;AA2BD,eAAO,MAAM,GAAG,MAAO,MAAM,KAAK,MAAM,KAAG,MAiL1C,CAAA;AASD,eAAO,MAAM,KAAK,QAAS,MAAM,OAAO,MAAM,KAAG,MA4ChD,CAAA;AAuDD,eAAO,MAAM,GAAG,MAAO,MAAM,KAAG,MAO/B,CAAA;AAKD,eAAO,MAAM,IAAI,MAAO,MAAM,KAAG,MAchC,CAAA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