@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.
Files changed (113) hide show
  1. package/CHANGELOG.md +149 -0
  2. package/README.md +18 -13
  3. package/dist/Angle.d.ts +44 -0
  4. package/dist/Angle.d.ts.map +1 -0
  5. package/dist/Angle.js +62 -0
  6. package/dist/Angle.js.map +1 -0
  7. package/dist/Box2.d.ts +16 -4
  8. package/dist/Box2.d.ts.map +1 -1
  9. package/dist/Box2.js +16 -1
  10. package/dist/Box2.js.map +1 -1
  11. package/dist/Collide2.d.ts +59 -15
  12. package/dist/Collide2.d.ts.map +1 -1
  13. package/dist/Collide2.js +156 -18
  14. package/dist/Collide2.js.map +1 -1
  15. package/dist/FlowField.d.ts +24 -38
  16. package/dist/FlowField.d.ts.map +1 -1
  17. package/dist/FlowField.js +18 -5
  18. package/dist/FlowField.js.map +1 -1
  19. package/dist/Scalar.d.ts +19 -166
  20. package/dist/Scalar.d.ts.map +1 -1
  21. package/dist/Scalar.js +51 -51
  22. package/dist/Scalar.js.map +1 -1
  23. package/dist/Segment2.d.ts +56 -0
  24. package/dist/Segment2.d.ts.map +1 -0
  25. package/dist/Segment2.js +32 -0
  26. package/dist/Segment2.js.map +1 -0
  27. package/dist/Vec2.d.ts +47 -7
  28. package/dist/Vec2.d.ts.map +1 -1
  29. package/dist/Vec2.js +56 -8
  30. package/dist/Vec2.js.map +1 -1
  31. package/dist/index.d.ts +10 -21
  32. package/dist/index.d.ts.map +1 -1
  33. package/dist/index.js +10 -21
  34. package/dist/index.js.map +1 -1
  35. package/package.json +3 -3
  36. package/src/Angle.ts +60 -0
  37. package/src/Box2.ts +20 -4
  38. package/src/Collide2.ts +171 -24
  39. package/src/FlowField.ts +34 -10
  40. package/src/Scalar.ts +43 -165
  41. package/src/Segment2.ts +71 -0
  42. package/src/Vec2.ts +58 -8
  43. package/src/index.ts +10 -21
  44. package/dist/Aabb.d.ts +0 -182
  45. package/dist/Aabb.d.ts.map +0 -1
  46. package/dist/Aabb.js +0 -109
  47. package/dist/Aabb.js.map +0 -1
  48. package/dist/InputAxis.d.ts +0 -44
  49. package/dist/InputAxis.d.ts.map +0 -1
  50. package/dist/InputAxis.js +0 -71
  51. package/dist/InputAxis.js.map +0 -1
  52. package/dist/Ops.d.ts +0 -209
  53. package/dist/Ops.d.ts.map +0 -1
  54. package/dist/Ops.js +0 -210
  55. package/dist/Ops.js.map +0 -1
  56. package/dist/Random.d.ts +0 -124
  57. package/dist/Random.d.ts.map +0 -1
  58. package/dist/Random.js +0 -126
  59. package/dist/Random.js.map +0 -1
  60. package/dist/Size2.d.ts +0 -118
  61. package/dist/Size2.d.ts.map +0 -1
  62. package/dist/Size2.js +0 -54
  63. package/dist/Size2.js.map +0 -1
  64. package/dist/SpatialGrid.d.ts +0 -68
  65. package/dist/SpatialGrid.d.ts.map +0 -1
  66. package/dist/SpatialGrid.js +0 -112
  67. package/dist/SpatialGrid.js.map +0 -1
  68. package/dist/Vector2.d.ts +0 -214
  69. package/dist/Vector2.d.ts.map +0 -1
  70. package/dist/Vector2.js +0 -134
  71. package/dist/Vector2.js.map +0 -1
  72. package/dist/internal/aabb.d.ts +0 -27
  73. package/dist/internal/aabb.d.ts.map +0 -1
  74. package/dist/internal/aabb.js +0 -52
  75. package/dist/internal/aabb.js.map +0 -1
  76. package/dist/internal/codec.d.ts +0 -9
  77. package/dist/internal/codec.d.ts.map +0 -1
  78. package/dist/internal/codec.js +0 -16
  79. package/dist/internal/codec.js.map +0 -1
  80. package/dist/internal/fdlibm.d.ts +0 -43
  81. package/dist/internal/fdlibm.d.ts.map +0 -1
  82. package/dist/internal/fdlibm.js +0 -1291
  83. package/dist/internal/fdlibm.js.map +0 -1
  84. package/dist/internal/inputAxis.d.ts +0 -11
  85. package/dist/internal/inputAxis.d.ts.map +0 -1
  86. package/dist/internal/inputAxis.js +0 -13
  87. package/dist/internal/inputAxis.js.map +0 -1
  88. package/dist/internal/scalar.d.ts +0 -11
  89. package/dist/internal/scalar.d.ts.map +0 -1
  90. package/dist/internal/scalar.js +0 -68
  91. package/dist/internal/scalar.js.map +0 -1
  92. package/dist/internal/size2.d.ts +0 -22
  93. package/dist/internal/size2.d.ts.map +0 -1
  94. package/dist/internal/size2.js +0 -38
  95. package/dist/internal/size2.js.map +0 -1
  96. package/dist/internal/vector2.d.ts +0 -39
  97. package/dist/internal/vector2.d.ts.map +0 -1
  98. package/dist/internal/vector2.js +0 -78
  99. package/dist/internal/vector2.js.map +0 -1
  100. package/src/Aabb.ts +0 -180
  101. package/src/InputAxis.ts +0 -81
  102. package/src/Ops.ts +0 -232
  103. package/src/Random.ts +0 -225
  104. package/src/Size2.ts +0 -122
  105. package/src/SpatialGrid.ts +0 -172
  106. package/src/Vector2.ts +0 -216
  107. package/src/internal/aabb.ts +0 -81
  108. package/src/internal/codec.ts +0 -21
  109. package/src/internal/fdlibm.ts +0 -1256
  110. package/src/internal/inputAxis.ts +0 -21
  111. package/src/internal/scalar.ts +0 -104
  112. package/src/internal/size2.ts +0 -54
  113. package/src/internal/vector2.ts +0 -121
package/dist/Scalar.d.ts CHANGED
@@ -1,179 +1,32 @@
1
1
  /**
2
- * Validated scalar brands and pure scalar helpers.
3
- *
4
- * This module is the numeric foundation for the branded geometry helpers.
5
- * Plain `number` values enter through explicit constructors such as
6
- * {@link Finite} and {@link NonNegative}. Once validated, downstream helpers
7
- * operate only on branded values.
8
- *
9
- * In game code this is useful whenever "just a number" is too weak: viewport
10
- * sizes, speeds, distances, durations, and geometry values often need explicit
11
- * non-negative or finite guarantees before they should be stored in the world.
12
- *
13
- * @example
14
- * ```ts
15
- * // Validate raw numbers before geometry or gameplay code relies on them.
16
- * const speed = Scalar.Finite.result(12)
17
- * const min = Scalar.Finite.result(0)
18
- * const max = Scalar.Finite.result(8)
19
- * if (!speed.ok || !min.ok || !max.ok) return
20
- *
21
- * // Operate on the branded values after the boundary has been crossed.
22
- * const clamped = Scalar.clamp(speed.value, min.value, max.value)
23
- * ```
24
- *
25
- * @module Scalar
26
- * @docGroup data-structures
27
- *
28
- * @categoryDescription Scalar Types
29
- * Branded numeric shapes and shared scalar validation errors.
30
- *
31
- * @categoryDescription Constructors
32
- * Non-throwing validation boundaries for finite and constrained scalar values.
33
- *
34
- * @categoryDescription Operations
35
- * Pure scalar combinators that preserve branding after validation.
36
- */
37
- import type * as Brand from "@typeonce/ritmo/Brand";
38
- import type { StandardSchema } from "@typeonce/ritmo/Descriptor";
39
- import type * as Result from "@typeonce/ritmo/Result";
40
- /**
41
- * Finite number brand.
42
- *
43
- * Values of this type are guaranteed not to be `NaN`, `Infinity`, or
44
- * `-Infinity` when they come from a constructor (`result`, `option`) or a `codec`. The
45
- * arithmetic helpers here and in `Vector2` keep the brand without
46
- * re-validating, so their results are finite only while they stay within
47
- * `±Number.MAX_VALUE`: game-sized values never come close, but validate
48
- * again with `result` when inputs may be that large.
49
- *
50
- * @category Scalar Types
51
- */
52
- export type Finite = Brand.Branded<number, "Scalar/Finite">;
53
- /**
54
- * Finite number brand constrained to `>= 0`.
55
- *
56
- * @category Scalar Types
57
- */
58
- export type NonNegative = Brand.Branded<number, "Scalar/NonNegative">;
59
- /**
60
- * Finite number brand constrained to `> 0`.
61
- *
62
- * @category Scalar Types
63
- */
64
- export type Positive = Brand.Branded<number, "Scalar/Positive">;
65
- /**
66
- * Structured scalar validation failures.
67
- *
68
- * @category Scalar Types
69
- */
70
- export type Error = {
71
- readonly tag: "Scalar/NotFinite";
72
- readonly value: number;
73
- } | {
74
- readonly tag: "Scalar/Negative";
75
- readonly value: number;
76
- } | {
77
- readonly tag: "Scalar/NonPositive";
78
- readonly value: number;
79
- };
80
- /**
81
- * Structured interpolation failure.
82
- *
83
- * @category Scalar Types
84
- */
85
- export type InterpolationError = {
86
- readonly tag: "Scalar/ZeroRange";
87
- readonly start: number;
88
- readonly end: number;
89
- };
90
- /**
91
- * The constructors, guard, and schema of one scalar brand.
92
- *
93
- * @category Constructors
94
- */
95
- export interface Constructor<Value> {
96
- /** Validates one number and returns an explicit success/failure result. */
97
- readonly result: (raw: number) => Result.Result<Value, Error>;
98
- /** Validates one number and returns `null` on failure. */
99
- readonly option: (raw: number) => Value | null;
100
- /** Whether any value is a number of this brand. */
101
- readonly is: (raw: unknown) => raw is Value;
102
- /** The Standard Schema for `Descriptor.ConstructedComponent(...)`: the saved form is the number itself. */
103
- readonly codec: StandardSchema<number, Value>;
104
- }
105
- /**
106
- * Constructor for {@link Finite}: `result` (explicit failure), `option`
107
- * (`null` on failure), `is` (a type guard), and `codec`, for
108
- * `Descriptor.ConstructedComponent(Scalar.Finite.codec)`.
109
- *
110
- * @category Constructors
111
- */
112
- export declare const Finite: Constructor<Finite>;
113
- /**
114
- * Constructor for {@link NonNegative}: `result` (explicit failure), `option`
115
- * (`null` on failure), `is` (a type guard), and `codec`, for
116
- * `Descriptor.ConstructedComponent(Scalar.NonNegative.codec)`.
117
- *
118
- * @category Constructors
119
- */
120
- export declare const NonNegative: Constructor<NonNegative>;
121
- /**
122
- * Constructor for {@link Positive}: `result` (explicit failure), `option`
123
- * (`null` on failure), `is` (a type guard), and `codec`, for
124
- * `Descriptor.ConstructedComponent(Scalar.Positive.codec)`.
125
- *
126
- * @category Constructors
127
- */
128
- export declare const Positive: Constructor<Positive>;
129
- /**
130
- * Clamps one finite value between two finite bounds.
131
- *
132
- * The result stays branded because valid branded scalar input cannot produce an
133
- * invalid scalar output.
2
+ * Moves `current` toward `target` by at most `maxDelta`, never overshooting:
3
+ * `target` itself once the gap is `maxDelta` or less, and `current` unchanged
4
+ * when `maxDelta` is 0 or less. For a constant rate (acceleration, a meter
5
+ * filling); for an ease that slows near the target use {@link decayToward},
6
+ * for vectors `Vec2.moveToward`, for angles `Angle.turnToward`.
134
7
  *
135
8
  * @category Operations
136
9
  */
137
- export declare const clamp: (value: Finite, min: Finite, max: Finite) => Finite;
10
+ export declare const moveToward: (current: number, target: number, maxDelta: number) => number;
138
11
  /**
139
- * Interpolates between two finite values by one finite amount.
140
- *
141
- * The amount is not clamped. This stays a pure interpolation primitive rather
142
- * than mixing interpolation with policy. The result keeps the `Finite` brand
143
- * without re-validating (see `Finite`).
12
+ * The number `amount` of the way from `start` (at 0) to `end` (at 1). The
13
+ * amount is not clamped, so 1.5 goes past `end`. For a fixed blend between
14
+ * two values; to approach a target over time use {@link moveToward} or
15
+ * {@link decayToward}, for vectors `Vec2.lerp`.
144
16
  *
145
17
  * @category Operations
146
18
  */
147
- export declare const lerp: (start: Finite, end: Finite, amount: Finite) => Finite;
19
+ export declare const lerp: (start: number, end: number, amount: number) => number;
148
20
  /**
149
- * Moves one finite value toward a target by at most one non-negative delta.
150
- *
151
- * Use this for explicit interpolation-style updates where overshooting the
152
- * target should be impossible.
21
+ * Moves `current` toward `target` by the share `rate` closes per second,
22
+ * over `dt` seconds: `target + (current - target) * exp(-rate * dt)`. The
23
+ * same total time gives the same result at any step rate, which `lerp` by a
24
+ * fixed amount per step does not. `current` unchanged when `rate * dt` is 0
25
+ * or less, `target` itself when `rate` is `Infinity` (and `dt` positive).
26
+ * It nears `target` without reaching it; when it must arrive, use
27
+ * {@link moveToward}. For vectors use `Vec2.decayToward`.
153
28
  *
154
29
  * @category Operations
155
30
  */
156
- export declare const approach: (current: Finite, target: Finite, maxDelta: NonNegative) => Finite;
157
- /**
158
- * Returns the interpolation amount of one value within a finite input range.
159
- *
160
- * Fails explicitly when the input range has zero size.
161
- *
162
- * @category Operations
163
- */
164
- export declare const inverseLerp: (start: Finite, end: Finite, value: Finite) => Result.Result<Finite, InterpolationError>;
165
- /**
166
- * Remaps one finite value from one input range to one output range.
167
- *
168
- * Fails explicitly when the input range has zero size.
169
- *
170
- * @category Operations
171
- */
172
- export declare const remap: (value: Finite, inputStart: Finite, inputEnd: Finite, outputStart: Finite, outputEnd: Finite) => Result.Result<Finite, InterpolationError>;
173
- /**
174
- * Common result shape returned by the scalar constructors.
175
- *
176
- * @category Scalar Types
177
- */
178
- export type FiniteResult = Result.Result<Finite, Error>;
31
+ export declare const decayToward: (current: number, target: number, rate: number, dt: number) => number;
179
32
  //# sourceMappingURL=Scalar.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Scalar.d.ts","sourceRoot":"","sources":["../src/Scalar.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,OAAO,KAAK,KAAK,KAAK,MAAM,uBAAuB,CAAA;AAEnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAChE,OAAO,KAAK,KAAK,MAAM,MAAM,wBAAwB,CAAA;AAErD;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,eAAe,CAAC,CAAA;AAC3D;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAA;AACrE;;;;GAIG;AACH,MAAM,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAA;AAE/D;;;;GAIG;AACH,MAAM,MAAM,KAAK,GACb;IAAE,QAAQ,CAAC,GAAG,EAAE,kBAAkB,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAC5D;IAAE,QAAQ,CAAC,GAAG,EAAE,iBAAiB,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAC3D;IAAE,QAAQ,CAAC,GAAG,EAAE,oBAAoB,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAA;AAElE;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,CAAC,GAAG,EAAE,kBAAkB,CAAA;IAChC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,GAAG,EAAE,MAA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M,EACb,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,KACV,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAwB,CAAA;AACrE;;;;;;GAMG;AACH,eAAO,MAAM,KAAK,EAAE,CAClB,KAAK,EAAE,MAAM,EACb,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,KACd,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAkB,CAAA;AAE/D;;;;GAIG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA"}
1
+ {"version":3,"file":"Scalar.d.ts","sourceRoot":"","sources":["../src/Scalar.ts"],"names":[],"mappings":"AAyBA;;;;;;;;GAQG;AACH,eAAO,MAAM,UAAU,YAAa,MAAM,UAAU,MAAM,YAAY,MAAM,KAAG,MAK9E,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,IAAI,UAAW,MAAM,OAAO,MAAM,UAAU,MAAM,KAAG,MAAwC,CAAA;AAE1G;;;;;;;;;;GAUG;AACH,eAAO,MAAM,WAAW,YAAa,MAAM,UAAU,MAAM,QAAQ,MAAM,MAAM,MAAM,KAAG,MAKvF,CAAA"}
package/dist/Scalar.js CHANGED
@@ -1,70 +1,70 @@
1
- import * as internal from "./internal/scalar.js";
2
1
  /**
3
- * Constructor for {@link Finite}: `result` (explicit failure), `option`
4
- * (`null` on failure), `is` (a type guard), and `codec`, for
5
- * `Descriptor.ConstructedComponent(Scalar.Finite.codec)`.
2
+ * One-dimensional helpers on plain numbers, for values a system moves toward
3
+ * a target every step: a speed, a zoom, a meter.
6
4
  *
7
- * @category Constructors
8
- */
9
- export const Finite = internal.Finite;
10
- /**
11
- * Constructor for {@link NonNegative}: `result` (explicit failure), `option`
12
- * (`null` on failure), `is` (a type guard), and `codec`, for
13
- * `Descriptor.ConstructedComponent(Scalar.NonNegative.codec)`.
14
- *
15
- * @category Constructors
16
- */
17
- export const NonNegative = internal.NonNegative;
18
- /**
19
- * Constructor for {@link Positive}: `result` (explicit failure), `option`
20
- * (`null` on failure), `is` (a type guard), and `codec`, for
21
- * `Descriptor.ConstructedComponent(Scalar.Positive.codec)`.
22
- *
23
- * @category Constructors
24
- */
25
- export const Positive = internal.Positive;
26
- /**
27
- * Clamps one finite value between two finite bounds.
5
+ * Every function is total over finite numbers and returns a plain `number`.
6
+ * Clamping stays `Math.min(Math.max(value, min), max)`, which is exact on
7
+ * every engine. Angles have their own module, `Angle`, because they wrap;
8
+ * vectors use the matching `Vec2` helpers.
28
9
  *
29
- * The result stays branded because valid branded scalar input cannot produce an
30
- * invalid scalar output.
10
+ * @example
11
+ * ```ts
12
+ * // Accelerate toward the top speed by at most `acceleration * dt` per step.
13
+ * const speed = Scalar.moveToward(current, topSpeed, acceleration * dt)
14
+ * // Ease a zoom toward its target the same way at any step rate.
15
+ * const zoom = Scalar.decayToward(view.zoom, target, 8, dt)
16
+ * ```
31
17
  *
32
- * @category Operations
33
- */
34
- export const clamp = internal.clamp;
35
- /**
36
- * Interpolates between two finite values by one finite amount.
37
- *
38
- * The amount is not clamped. This stays a pure interpolation primitive rather
39
- * than mixing interpolation with policy. The result keeps the `Finite` brand
40
- * without re-validating (see `Finite`).
18
+ * @module Scalar
19
+ * @docGroup helpers
41
20
  *
42
- * @category Operations
21
+ * @categoryDescription Operations
22
+ * Moving one number toward another.
43
23
  */
44
- export const lerp = internal.lerp;
24
+ import * as Ops from "@typeonce/ritmo/Ops";
45
25
  /**
46
- * Moves one finite value toward a target by at most one non-negative delta.
47
- *
48
- * Use this for explicit interpolation-style updates where overshooting the
49
- * target should be impossible.
26
+ * Moves `current` toward `target` by at most `maxDelta`, never overshooting:
27
+ * `target` itself once the gap is `maxDelta` or less, and `current` unchanged
28
+ * when `maxDelta` is 0 or less. For a constant rate (acceleration, a meter
29
+ * filling); for an ease that slows near the target use {@link decayToward},
30
+ * for vectors `Vec2.moveToward`, for angles `Angle.turnToward`.
50
31
  *
51
32
  * @category Operations
52
33
  */
53
- export const approach = internal.approach;
34
+ export const moveToward = (current, target, maxDelta) => {
35
+ if (!(maxDelta > 0))
36
+ return current;
37
+ const gap = target - current;
38
+ if (Math.abs(gap) <= maxDelta)
39
+ return target;
40
+ return gap > 0 ? current + maxDelta : current - maxDelta;
41
+ };
54
42
  /**
55
- * Returns the interpolation amount of one value within a finite input range.
56
- *
57
- * Fails explicitly when the input range has zero size.
43
+ * The number `amount` of the way from `start` (at 0) to `end` (at 1). The
44
+ * amount is not clamped, so 1.5 goes past `end`. For a fixed blend between
45
+ * two values; to approach a target over time use {@link moveToward} or
46
+ * {@link decayToward}, for vectors `Vec2.lerp`.
58
47
  *
59
48
  * @category Operations
60
49
  */
61
- export const inverseLerp = internal.inverseLerp;
50
+ export const lerp = (start, end, amount) => start + (end - start) * amount;
62
51
  /**
63
- * Remaps one finite value from one input range to one output range.
64
- *
65
- * Fails explicitly when the input range has zero size.
52
+ * Moves `current` toward `target` by the share `rate` closes per second,
53
+ * over `dt` seconds: `target + (current - target) * exp(-rate * dt)`. The
54
+ * same total time gives the same result at any step rate, which `lerp` by a
55
+ * fixed amount per step does not. `current` unchanged when `rate * dt` is 0
56
+ * or less, `target` itself when `rate` is `Infinity` (and `dt` positive).
57
+ * It nears `target` without reaching it; when it must arrive, use
58
+ * {@link moveToward}. For vectors use `Vec2.decayToward`.
66
59
  *
67
60
  * @category Operations
68
61
  */
69
- export const remap = internal.remap;
62
+ export const decayToward = (current, target, rate, dt) => {
63
+ const k = rate * dt;
64
+ if (!(k > 0))
65
+ return current;
66
+ if (k === Infinity)
67
+ return target;
68
+ return target + (current - target) * Ops.exp(-k);
69
+ };
70
70
  //# sourceMappingURL=Scalar.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Scalar.js","sourceRoot":"","sources":["../src/Scalar.ts"],"names":[],"mappings":"AAqCA,OAAO,KAAK,QA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AO,GAAG,QAAQ,CAAA;AAC1D,CAAC,CAAA;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,KAAa,EAAE,GAAW,EAAE,MAAc,EAAU,EAAE,CAAC,KAAK,GAAG,CAAC,GAAG,GAAG,KAAK,CAAC,GAAG,MAAM,CAAA;AAE1G;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,OAAe,EAAE,MAAc,EAAE,IAAY,EAAE,EAAU,EAAU,EAAE;IAC/F,MAAM,CAAC,GAAG,IAAI,GAAG,EAAE,CAAA;IACnB,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QAAE,OAAO,OAAO,CAAA;IAC5B,IAAI,CAAC,KAAK,QAAQ;QAAE,OAAO,MAAM,CAAA;IACjC,OAAO,MAAM,GAAG,CAAC,OAAO,GAAG,MAAM,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;AAClD,CAAC,CAAA"}
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Plain line segments stored by their ends, for hot-path collision against
3
+ * walls that are not axis-aligned (a map traced from survey data, a slanted
4
+ * fence, a polygon's edges).
5
+ *
6
+ * Like `Box2`, it is the plain form the collision helpers (`Collide2`) read
7
+ * every frame, built once from whatever the game stores. A wall is
8
+ * two-sided: a circle is kept off it on both sides and around both ends.
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * const fence = Segment2.between({ x: 0, y: 0 }, { x: 40, y: 30 })
13
+ * const moved = Collide2.moveCircle(position, delta, radius, { segments: [fence] })
14
+ * ```
15
+ *
16
+ * @module Segment2
17
+ * @docGroup helpers
18
+ *
19
+ * @categoryDescription Segment Types
20
+ * The structural segment shape.
21
+ *
22
+ * @categoryDescription Operations
23
+ * Building segments and measuring them against points and circles.
24
+ */
25
+ import type { Vec2 } from "./Vec2.ts";
26
+ /**
27
+ * The segment from (`ax`, `ay`) to (`bx`, `by`). Both ends may be the same
28
+ * point, which is then a round post.
29
+ *
30
+ * @category Segment Types
31
+ */
32
+ export interface Segment2 {
33
+ readonly ax: number;
34
+ readonly ay: number;
35
+ readonly bx: number;
36
+ readonly by: number;
37
+ }
38
+ /**
39
+ * The segment from `a` to `b`.
40
+ *
41
+ * @category Operations
42
+ */
43
+ export declare const between: (a: Vec2, b: Vec2) => Segment2;
44
+ /**
45
+ * The point of the segment nearest to `point`.
46
+ *
47
+ * @category Operations
48
+ */
49
+ export declare const closestPoint: (segment: Segment2, point: Vec2) => Vec2;
50
+ /**
51
+ * Whether a circle overlaps (or touches) the segment.
52
+ *
53
+ * @category Operations
54
+ */
55
+ export declare const overlapsCircle: (segment: Segment2, center: Vec2, radius: number) => boolean;
56
+ //# sourceMappingURL=Segment2.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Segment2.d.ts","sourceRoot":"","sources":["../src/Segment2.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAErC;;;;;GAKG;AACH,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;CACpB;AAED;;;;GAIG;AACH,eAAO,MAAM,OAAO,MAAO,IAAI,KAAK,IAAI,KAAG,QAAoD,CAAA;AAE/F;;;;GAIG;AACH,eAAO,MAAM,YAAY,YAAa,QAAQ,SAAS,IAAI,KAAG,IAO7D,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,cAAc,YAAa,QAAQ,UAAU,IAAI,UAAU,MAAM,KAAG,OAKhF,CAAA"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * The segment from `a` to `b`.
3
+ *
4
+ * @category Operations
5
+ */
6
+ export const between = (a, b) => ({ ax: a.x, ay: a.y, bx: b.x, by: b.y });
7
+ /**
8
+ * The point of the segment nearest to `point`.
9
+ *
10
+ * @category Operations
11
+ */
12
+ export const closestPoint = (segment, point) => {
13
+ const ex = segment.bx - segment.ax;
14
+ const ey = segment.by - segment.ay;
15
+ const lengthSquared = ex * ex + ey * ey;
16
+ if (lengthSquared < 1e-12)
17
+ return { x: segment.ax, y: segment.ay };
18
+ const along = Math.max(0, Math.min(1, ((point.x - segment.ax) * ex + (point.y - segment.ay) * ey) / lengthSquared));
19
+ return { x: segment.ax + ex * along, y: segment.ay + ey * along };
20
+ };
21
+ /**
22
+ * Whether a circle overlaps (or touches) the segment.
23
+ *
24
+ * @category Operations
25
+ */
26
+ export const overlapsCircle = (segment, center, radius) => {
27
+ const nearest = closestPoint(segment, center);
28
+ const dx = center.x - nearest.x;
29
+ const dy = center.y - nearest.y;
30
+ return dx * dx + dy * dy <= radius * radius;
31
+ };
32
+ //# sourceMappingURL=Segment2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Segment2.js","sourceRoot":"","sources":["../src/Segment2.ts"],"names":[],"mappings":"AAuCA;;;;GAIG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,CAAO,EAAE,CAAO,EAAY,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAA;AAE/F;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,OAAiB,EAAE,KAAW,EAAQ,EAAE;IACnE,MAAM,EAAE,GAAG,OAAO,CAAC,EAAE,GAAG,OAAO,CAAC,EAAE,CAAA;IAClC,MAAM,EAAE,GAAG,OAAO,CAAC,EAAE,GAAG,OAAO,CAAC,EAAE,CAAA;IAClC,MAAM,aAAa,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAA;IACvC,IAAI,aAAa,GAAG,KAAK;QAAE,OAAO,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,EAAE,CAAA;IAClE,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,GAAG,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,aAAa,CAAC,CAAC,CAAA;IACnH,OAAO,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,GAAG,KAAK,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,GAAG,KAAK,EAAE,CAAA;AACnE,CAAC,CAAA;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,OAAiB,EAAE,MAAY,EAAE,MAAc,EAAW,EAAE;IACzF,MAAM,OAAO,GAAG,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;IAC7C,MAAM,EAAE,GAAG,MAAM,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAA;IAC/B,MAAM,EAAE,GAAG,MAAM,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAA;IAC/B,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,MAAM,GAAG,MAAM,CAAA;AAC7C,CAAC,CAAA"}
package/dist/Vec2.d.ts CHANGED
@@ -1,11 +1,10 @@
1
1
  /**
2
2
  * Plain two-dimensional vector arithmetic for hot paths.
3
3
  *
4
- * `Vector2` validates values at a boundary (authored data, saves, components);
5
- * `Vec2` is the arithmetic that runs every frame on numbers already known to
6
- * be sane. Values are immutable `{ x, y }` records and every helper returns a
7
- * new one. A branded `Vector2` is a `Vec2`, so validated values flow into
8
- * these helpers without conversion.
4
+ * Values are immutable `{ x, y }` records and every helper returns a new
5
+ * one, so a component's value (validated once by the game's schema when it
6
+ * entered the world) passes straight in. Lengths and angles go through
7
+ * `Ops`, so the results replay the same on every engine.
9
8
  *
10
9
  * @example
11
10
  * ```ts
@@ -57,17 +56,46 @@ export declare const subtract: (a: Vec2, b: Vec2) => Vec2;
57
56
  */
58
57
  export declare const scale: (a: Vec2, factor: number) => Vec2;
59
58
  /**
60
- * `a` turned by `angle` radians (counter-clockwise for a y-up frame).
59
+ * `a` turned by `angle` radians (counter-clockwise for a y-up frame). For a
60
+ * quarter turn use {@link perpendicular}, which is exact.
61
61
  *
62
62
  * @category Operations
63
63
  */
64
64
  export declare const rotate: (a: Vec2, angle: number) => Vec2;
65
65
  /**
66
- * Dot product.
66
+ * `a` turned a quarter turn counter-clockwise (for a y-up frame):
67
+ * `{ x: -a.y, y: a.x }`. Exact. For the normal of a wall or a direction, a
68
+ * sideways push, and the signed side of a point: `dot(perpendicular(forward),
69
+ * offset)` is positive on the left of `forward`, negative on its right.
70
+ *
71
+ * @category Operations
72
+ */
73
+ export declare const perpendicular: (a: Vec2) => Vec2;
74
+ /**
75
+ * Dot product. With {@link perpendicular} it is also the 2D cross product:
76
+ * `dot(perpendicular(a), b)`.
67
77
  *
68
78
  * @category Operations
69
79
  */
70
80
  export declare const dot: (a: Vec2, b: Vec2) => number;
81
+ /**
82
+ * The unit vector at `angle` radians from the x axis (counter-clockwise for a
83
+ * y-up frame), through `Ops.cos` and `Ops.sin`. Multiply by a length with
84
+ * {@link scale}. The inverse of {@link angle}.
85
+ *
86
+ * @category Operations
87
+ */
88
+ export declare const fromAngle: (angle: number) => Vec2;
89
+ /**
90
+ * The angle of `a` from the x axis in radians, in (-π, π], through
91
+ * `Ops.atan2` (so no `y, x` argument order to get wrong). The zero vector
92
+ * gives 0, and so does `-0` in either coordinate where `Ops.atan2` would give
93
+ * `-0` or flip to -π. To keep it in `Angle`'s range [-π, π), use
94
+ * `Angle.wrap`; to turn toward it, `Angle.turnToward`.
95
+ *
96
+ * @category Operations
97
+ */
98
+ export declare const angle: (a: Vec2) => number;
71
99
  /**
72
100
  * Length of `a`.
73
101
  *
@@ -118,4 +146,16 @@ export declare const moveToward: (current: Vec2, target: Vec2, maxDelta: number)
118
146
  * @category Operations
119
147
  */
120
148
  export declare const clampLength: (a: Vec2, max: number) => Vec2;
149
+ /**
150
+ * Moves `current` toward `target` by the share `rate` closes per second, over
151
+ * `dt` seconds, with one shared factor `exp(-rate * dt)` so the point moves
152
+ * along the straight line: the same total time gives the same result at any
153
+ * step rate. `current` unchanged when `rate * dt` is 0 or less, `target`
154
+ * itself when `rate` is `Infinity` (and `dt` positive). It nears `target`
155
+ * without reaching it; when it must arrive, use {@link moveToward}. For
156
+ * plain numbers use `Scalar.decayToward`.
157
+ *
158
+ * @category Operations
159
+ */
160
+ export declare const decayToward: (current: Vec2, target: Vec2, rate: number, dt: number) => Vec2;
121
161
  //# sourceMappingURL=Vec2.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Vec2.d.ts","sourceRoot":"","sources":["../src/Vec2.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAIH;;;;GAIG;AACH,MAAM,WAAW,IAAI;IACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAA;CACnB;AAED;;;;GAIG;AACH,eAAO,MAAM,IAAI,EAAE,IAAoC,CAAA;AAEvD;;;;GAIG;AACH,eAAO,MAAM,GAAG,MAAO,IAAI,KAAK,IAAI,KAAG,IAAwC,CAAA;AAE/E;;;;GAIG;AACH,eAAO,MAAM,QAAQ,MAAO,IAAI,KAAK,IAAI,KAAG,IAAwC,CAAA;AAEpF;;;;GAIG;AACH,eAAO,MAAM,KAAK,MAAO,IAAI,UAAU,MAAM,KAAG,IAA8C,CAAA;AA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YAAa,IAAI,UAAU,IAAI,QAAQ,MAAM,MAAM,MAAM,KAAG,IAMnF,CAAA"}
package/dist/Vec2.js CHANGED
@@ -1,11 +1,10 @@
1
1
  /**
2
2
  * Plain two-dimensional vector arithmetic for hot paths.
3
3
  *
4
- * `Vector2` validates values at a boundary (authored data, saves, components);
5
- * `Vec2` is the arithmetic that runs every frame on numbers already known to
6
- * be sane. Values are immutable `{ x, y }` records and every helper returns a
7
- * new one. A branded `Vector2` is a `Vec2`, so validated values flow into
8
- * these helpers without conversion.
4
+ * Values are immutable `{ x, y }` records and every helper returns a new
5
+ * one, so a component's value (validated once by the game's schema when it
6
+ * entered the world) passes straight in. Lengths and angles go through
7
+ * `Ops`, so the results replay the same on every engine.
9
8
  *
10
9
  * @example
11
10
  * ```ts
@@ -23,7 +22,7 @@
23
22
  * @categoryDescription Operations
24
23
  * Immutable arithmetic, measurement, and steering helpers.
25
24
  */
26
- import * as Ops from "./Ops.js";
25
+ import * as Ops from "@typeonce/ritmo/Ops";
27
26
  /**
28
27
  * The zero vector (frozen, safe to share).
29
28
  *
@@ -49,7 +48,8 @@ export const subtract = (a, b) => ({ x: a.x - b.x, y: a.y - b.y });
49
48
  */
50
49
  export const scale = (a, factor) => ({ x: a.x * factor, y: a.y * factor });
51
50
  /**
52
- * `a` turned by `angle` radians (counter-clockwise for a y-up frame).
51
+ * `a` turned by `angle` radians (counter-clockwise for a y-up frame). For a
52
+ * quarter turn use {@link perpendicular}, which is exact.
53
53
  *
54
54
  * @category Operations
55
55
  */
@@ -59,11 +59,39 @@ export const rotate = (a, angle) => {
59
59
  return { x: a.x * cos - a.y * sin, y: a.x * sin + a.y * cos };
60
60
  };
61
61
  /**
62
- * Dot product.
62
+ * `a` turned a quarter turn counter-clockwise (for a y-up frame):
63
+ * `{ x: -a.y, y: a.x }`. Exact. For the normal of a wall or a direction, a
64
+ * sideways push, and the signed side of a point: `dot(perpendicular(forward),
65
+ * offset)` is positive on the left of `forward`, negative on its right.
66
+ *
67
+ * @category Operations
68
+ */
69
+ export const perpendicular = (a) => ({ x: -a.y, y: a.x });
70
+ /**
71
+ * Dot product. With {@link perpendicular} it is also the 2D cross product:
72
+ * `dot(perpendicular(a), b)`.
63
73
  *
64
74
  * @category Operations
65
75
  */
66
76
  export const dot = (a, b) => a.x * b.x + a.y * b.y;
77
+ /**
78
+ * The unit vector at `angle` radians from the x axis (counter-clockwise for a
79
+ * y-up frame), through `Ops.cos` and `Ops.sin`. Multiply by a length with
80
+ * {@link scale}. The inverse of {@link angle}.
81
+ *
82
+ * @category Operations
83
+ */
84
+ export const fromAngle = (angle) => ({ x: Ops.cos(angle), y: Ops.sin(angle) });
85
+ /**
86
+ * The angle of `a` from the x axis in radians, in (-π, π], through
87
+ * `Ops.atan2` (so no `y, x` argument order to get wrong). The zero vector
88
+ * gives 0, and so does `-0` in either coordinate where `Ops.atan2` would give
89
+ * `-0` or flip to -π. To keep it in `Angle`'s range [-π, π), use
90
+ * `Angle.wrap`; to turn toward it, `Angle.turnToward`.
91
+ *
92
+ * @category Operations
93
+ */
94
+ export const angle = (a) => Ops.atan2(a.y + 0, a.x + 0);
67
95
  /**
68
96
  * Length of `a`.
69
97
  *
@@ -131,4 +159,24 @@ export const clampLength = (a, max) => {
131
159
  const len = Ops.hypot(a.x, a.y);
132
160
  return len <= max ? a : { x: (a.x / len) * max, y: (a.y / len) * max };
133
161
  };
162
+ /**
163
+ * Moves `current` toward `target` by the share `rate` closes per second, over
164
+ * `dt` seconds, with one shared factor `exp(-rate * dt)` so the point moves
165
+ * along the straight line: the same total time gives the same result at any
166
+ * step rate. `current` unchanged when `rate * dt` is 0 or less, `target`
167
+ * itself when `rate` is `Infinity` (and `dt` positive). It nears `target`
168
+ * without reaching it; when it must arrive, use {@link moveToward}. For
169
+ * plain numbers use `Scalar.decayToward`.
170
+ *
171
+ * @category Operations
172
+ */
173
+ export const decayToward = (current, target, rate, dt) => {
174
+ const k = rate * dt;
175
+ if (!(k > 0))
176
+ return current;
177
+ if (k === Infinity)
178
+ return target;
179
+ const factor = Ops.exp(-k);
180
+ return { x: target.x + (current.x - target.x) * factor, y: target.y + (current.y - target.y) * factor };
181
+ };
134
182
  //# sourceMappingURL=Vec2.js.map
package/dist/Vec2.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Vec2.js","sourceRoot":"","sources":["../src/Vec2.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA;AAY/B;;;;GAIG;AACH,MAAM,CAAC,MAAM,IAAI,GAAS,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAA;AAEvD;;;;GAIG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,CAAO,EAAE,CAAO,EAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAA;AAE/E;;;;GAIG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,CAAO,EAAE,CAAO,EAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAA;AAEpF;;;;GAIG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,CAAO,EAAE,MAAc,EAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,MAAM,EAAE,CAAC,CAAA;AAE9F;;;;GAIG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,CAAO,EAAE,KA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