@flare-engine/math 0.3.1 → 0.4.1

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # @flare-engine/math
2
2
 
3
- 2D math primitives for the Flare engine — `Vec2`, `Rect`, `Circle`, `Transform2D`, `Mat3`, `Color`, 35 easing functions, seeded RNG, intersection tests, angle/steering helpers (`angleDelta`, `rotateTowards`, `Vec2.turnVelocityToward`, `Vec2.perp`, `Vec2.crossSV`), weighted random picks (`weightedIndex`, `weightedIndexBy`, `weightedPick`), deterministic hash utils (`hashU32`, `seededIndex`), and timed-window reward math (`cappedBonus`, `advanceWindowedStreak`, `windowExpired`, `remainingInWindow`). Plain-object types with static method namespaces; zero-alloc forms take an `out` parameter to avoid GC pressure in game loops.
3
+ 2D math primitives for the Flare engine — `Vec2`, `Rect`, `Circle`, `Transform2D`, `Mat3`, `Color`, 35 easing functions, seeded RNG, intersection tests, angle/steering helpers (`angleDelta`, `rotateTowards`, `Vec2.turnVelocityTowardInto`, `Vec2.scaleToLengthInto`, `Vec2.perp`, `Vec2.crossSV`), weighted random picks (`weightedIndex`, `weightedIndexBy`, `weightedPick`), deterministic hash utils (`hashU32`, `seededIndex`), and timed-window reward math (`cappedBonus`, `advanceWindowedStreak`, `windowExpired`, `remainingInWindow`). Plain-object types with static method namespaces; zero-alloc forms take an `out` parameter to avoid GC pressure in game loops.
4
4
 
5
5
  ## Install
6
6
 
@@ -22,6 +22,61 @@ const rng = new SeededRNG(42);
22
22
  const t = easeOutQuad(rng.float(0, 1));
23
23
  ```
24
24
 
25
+ ## Curves
26
+
27
+ Quadratic/cubic Bézier and Catmull-Rom sampling, each with an allocating form and an `…Into` twin
28
+ for per-frame use, plus approximate arc length:
29
+
30
+ ```ts
31
+ import { bezier3Into, catmullRom, bezier3Length, vec2 } from '@flare-engine/math';
32
+
33
+ // Sampling a path each frame — reuse one buffer, allocate nothing.
34
+ const point = vec2(0, 0);
35
+ bezier3Into(0, 0, 20, 60, 80, 60, 100, 0, 0.35, point);
36
+
37
+ // Catmull-Rom passes *through* p1 and p2, so a path hits its waypoints exactly.
38
+ const onPath = catmullRom(0, 0, 10, 5, 20, 5, 30, 0, 0.5);
39
+
40
+ // Arc length is a chord approximation, so always a slight underestimate.
41
+ const length = bezier3Length(0, 0, 20, 60, 80, 60, 100, 0, 32);
42
+ ```
43
+
44
+ Control points are loose numbers rather than `Vec2` objects, so coordinates already held in a
45
+ `Float32Array` can be sampled without building temporaries first. `t` is clamped to `[0, 1]` rather
46
+ than extrapolating.
47
+
48
+ ## Segment intersection
49
+
50
+ `intersection.ts` answers *whether* shapes intersect; these answer *where* two segments cross:
51
+
52
+ ```ts
53
+ import { segmentIntersection, segmentsIntersect, vec2, segmentIntersectionInto } from '@flare-engine/math';
54
+
55
+ segmentIntersection(5, 0, 5, 10, 0, 5, 10, 5); // → { x: 5, y: 5 }
56
+
57
+ // Zero-alloc form; `out` is left untouched when the result is null.
58
+ const hit = vec2(0, 0);
59
+ segmentIntersectionInto(0, 0, 10, 10, 0, 10, 10, 0, hit);
60
+ ```
61
+
62
+ **Collinear overlap returns `null`.** Two segments lying on top of each other do intersect — at
63
+ infinitely many points — so there is no single point to report. Ask `segmentsIntersect` when the
64
+ yes/no answer is what you want; it returns `true` for that case.
65
+
66
+ ## Deterministic saves and replays
67
+
68
+ `SeededRNG` exposes its whole state as one int32, so a run can be stored and resumed exactly:
69
+
70
+ ```ts
71
+ import { SeededRNG } from '@flare-engine/math';
72
+
73
+ const rng = new SeededRNG(1234);
74
+ const savedState = rng.getState(); // JSON-safe — store it beside the save
75
+
76
+ const restored = new SeededRNG(0);
77
+ restored.setState(savedState); // next() now continues the original sequence
78
+ ```
79
+
25
80
  See [API spec](https://github.com/grzott/flare-engine/blob/main/docs/design/api-specs.md#flare-enginemath--5kb-gzip).
26
81
 
27
82
  ## License
package/dist/index.d.mts CHANGED
@@ -27,8 +27,9 @@ declare const Vec2: {
27
27
  readonly scale: (v: Vec2, s: number, out?: Vec2) => Vec2;
28
28
  /** Returns a unit vector. Returns zero vector if length is 0. */
29
29
  readonly normalize: (v: Vec2, out?: Vec2) => Vec2;
30
- /** Zero-alloc; writes into `out`. Mandatory `out` so callers avoid temporaries in hot paths. */
31
- readonly normalizeOut: (dx: number, dy: number, speed: number, out: Vec2) => Vec2;
30
+ /** The direction of `(dx, dy)` scaled to `length`; writes zeros when `(dx, dy)` is shorter than
31
+ * 1e-6. Zero-alloc, mandatory `out`; scalar components so hot paths need no temporary Vec2. */
32
+ readonly scaleToLengthInto: (dx: number, dy: number, length: number, out: Vec2) => Vec2;
32
33
  /** Dot product. */
33
34
  readonly dot: (a: Vec2, b: Vec2) => number;
34
35
  /** 2D cross product (z-component of the 3D cross). */
@@ -64,7 +65,7 @@ declare const Vec2: {
64
65
  /** Zero-alloc homing steer: rotate velocity (vx,vy) toward direction (dx,dy) by at most maxStep
65
66
  * radians, preserving speed; writes into out. Mandatory out. Byte-identical to hand-rolled
66
67
  * homing-bullet steering (Math.hypot speed + atan2 + branch-form turn + cos/sin * speed). */
67
- readonly turnVelocityToward: (vx: number, vy: number, dx: number, dy: number, maxStep: number, out: Vec2) => Vec2;
68
+ readonly turnVelocityTowardInto: (vx: number, vy: number, dx: number, dy: number, maxStep: number, out: Vec2) => Vec2;
68
69
  };
69
70
  //#endregion
70
71
  //#region src/rect.d.ts
@@ -171,6 +172,56 @@ declare const Color: {
171
172
  readonly contrastRatio: (fg: Color, bg: Color) => number;
172
173
  };
173
174
  //#endregion
175
+ //#region src/curves.d.ts
176
+ /**
177
+ * Parametric curves — quadratic/cubic Bézier and Catmull-Rom — plus approximate
178
+ * arc length for each.
179
+ *
180
+ * Every sampler comes in two forms, per the repo's hot-path convention: an
181
+ * allocating one returning a fresh `Vec2`, and an `…Into` one writing to a
182
+ * caller-owned buffer. Sampling a path each frame is exactly the case the
183
+ * `…Into` forms exist for.
184
+ *
185
+ * Control points are passed as loose numbers rather than `Vec2` objects so a
186
+ * caller holding coordinates in a `Float32Array` — the documented storage for
187
+ * bulk numeric data — can sample without building temporaries first.
188
+ */
189
+ /** Quadratic Bézier at `t`, writing into `out`. `t` is clamped to [0, 1]. */
190
+ declare function bezier2Into(p0x: number, p0y: number, p1x: number, p1y: number, p2x: number, p2y: number, t: number, out: Vec2): Vec2;
191
+ /** Quadratic Bézier at `t`. Allocates — see `bezier2Into` for the hot path. */
192
+ declare function bezier2(p0x: number, p0y: number, p1x: number, p1y: number, p2x: number, p2y: number, t: number): Vec2;
193
+ /** Cubic Bézier at `t`, writing into `out`. `t` is clamped to [0, 1]. */
194
+ declare function bezier3Into(p0x: number, p0y: number, p1x: number, p1y: number, p2x: number, p2y: number, p3x: number, p3y: number, t: number, out: Vec2): Vec2;
195
+ /** Cubic Bézier at `t`. Allocates — see `bezier3Into` for the hot path. */
196
+ declare function bezier3(p0x: number, p0y: number, p1x: number, p1y: number, p2x: number, p2y: number, p3x: number, p3y: number, t: number): Vec2;
197
+ /**
198
+ * Centripetal-free (uniform) Catmull-Rom spline at `t`, writing into `out`.
199
+ *
200
+ * The curve passes **through** `p1` and `p2`; `p0` and `p3` are the neighbouring
201
+ * control points that set the tangents, and `t` runs from `p1` (0) to `p2` (1).
202
+ * That interpolating property is the reason to reach for this over a Bézier when
203
+ * a path must hit its waypoints exactly.
204
+ */
205
+ declare function catmullRomInto(p0x: number, p0y: number, p1x: number, p1y: number, p2x: number, p2y: number, p3x: number, p3y: number, t: number, out: Vec2): Vec2;
206
+ /** Catmull-Rom at `t`. Allocates — see `catmullRomInto` for the hot path. */
207
+ declare function catmullRom(p0x: number, p0y: number, p1x: number, p1y: number, p2x: number, p2y: number, p3x: number, p3y: number, t: number): Vec2;
208
+ /**
209
+ * Approximate arc length by sampling `segments` chords.
210
+ *
211
+ * Always an **underestimate**: a chord is the shortest path between its
212
+ * endpoints, so a polyline through the curve is never longer than the curve.
213
+ * Error falls roughly with the square of `segments`; 16 is a reasonable default
214
+ * for UI paths, more for anything a camera follows closely.
215
+ */
216
+ declare function bezier2Length(p0x: number, p0y: number, p1x: number, p1y: number, p2x: number, p2y: number, segments?: number): number;
217
+ /** Approximate arc length of a cubic Bézier. See `bezier2Length`. */
218
+ declare function bezier3Length(p0x: number, p0y: number, p1x: number, p1y: number, p2x: number, p2y: number, p3x: number, p3y: number, segments?: number): number;
219
+ /**
220
+ * Approximate arc length of the Catmull-Rom span between `p1` and `p2`.
221
+ * See `bezier2Length` for the accuracy note.
222
+ */
223
+ declare function catmullRomLength(p0x: number, p0y: number, p1x: number, p1y: number, p2x: number, p2y: number, p3x: number, p3y: number, segments?: number): number;
224
+ //#endregion
174
225
  //#region src/easings.d.ts
175
226
  declare function linear(t: number): number;
176
227
  declare function step(t: number): number;
@@ -226,6 +277,32 @@ declare function lineVsRect(x1: number, y1: number, x2: number, y2: number, r: R
226
277
  declare function lineVsCircle(x1: number, y1: number, x2: number, y2: number, c: Circle): boolean;
227
278
  /** Ray intersection with AABB. Returns t (distance) or null if no hit. */
228
279
  declare function rayVsRect(originX: number, originY: number, dirX: number, dirY: number, r: Rect): number | null;
280
+ /**
281
+ * Do two segments intersect, including collinear overlap?
282
+ *
283
+ * The companion to `segmentIntersection`: that returns *where* two segments
284
+ * cross and is `null` when there is no single crossing point, which includes
285
+ * collinear segments lying on top of each other. Those genuinely do intersect,
286
+ * so a caller who only needs the yes/no answer asks here instead.
287
+ */
288
+ declare function segmentsIntersect(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, x4: number, y4: number): boolean;
289
+ /**
290
+ * Where two segments cross, written into `out`.
291
+ *
292
+ * Returns `null` when there is no **single** crossing point — segments that miss
293
+ * each other, are parallel, or are collinear. Collinear overlap is the case
294
+ * worth knowing about: the segments do intersect, at infinitely many points, so
295
+ * there is no one answer to write into `out`. Use `segmentsIntersect` when the
296
+ * yes/no answer is what you need.
297
+ *
298
+ * `out` is left untouched when the result is `null`.
299
+ */
300
+ declare function segmentIntersectionInto(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, x4: number, y4: number, out: Vec2): Vec2 | null;
301
+ /**
302
+ * Where two segments cross. Allocates — see `segmentIntersectionInto` for the
303
+ * hot path.
304
+ */
305
+ declare function segmentIntersection(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, x4: number, y4: number): Vec2 | null;
229
306
  //#endregion
230
307
  //#region src/transform2d.d.ts
231
308
  /** 2D transform: position, rotation (radians), and scale. */
@@ -287,6 +364,21 @@ declare class SeededRNG {
287
364
  float(min: number, max: number): number;
288
365
  /** Returns an integer in [min, max] (inclusive). */
289
366
  int(min: number, max: number): number;
367
+ /**
368
+ * The generator's entire internal state, as a single int32.
369
+ *
370
+ * Enough to resume the exact sequence later, which is what makes a save file
371
+ * or a replay reproducible: store this alongside the save, hand it back to
372
+ * `setState`, and the next `next()` returns what it would have returned.
373
+ */
374
+ getState(): number;
375
+ /**
376
+ * Restore a state previously read from `getState`.
377
+ *
378
+ * Coerced to int32 exactly as the constructor coerces a seed, so any number
379
+ * is accepted and a round-trip through JSON is safe.
380
+ */
381
+ setState(state: number): void;
290
382
  }
291
383
  /** Returns a random float in [min, max). */
292
384
  declare function randomFloat(min: number, max: number): number;
@@ -391,5 +483,5 @@ declare function angleDelta(a: number, b: number): number;
391
483
  * angle (NOT re-wrapped). Branch-form step clamp — byte-identical to hand-rolled homing steering. */
392
484
  declare function rotateTowards(cur: number, target: number, maxStep: number): number;
393
485
  //#endregion
394
- export { Circle, Color, type EasingFn, Mat3, type Oklab, type Oklch, Rect, SeededRNG, Transform2D, Vec2, advanceWindowedStreak, angleDelta, approxEquals, cappedBonus, choose, circleVsCircle, clamp, degToRad, easeInBack, easeInBounce, easeInCirc, easeInCubic, easeInElastic, easeInExpo, easeInOutBack, easeInOutBounce, easeInOutCirc, easeInOutCubic, easeInOutElastic, easeInOutExpo, easeInOutQuad, easeInOutQuart, easeInOutQuint, easeInOutSine, easeInQuad, easeInQuart, easeInQuint, easeInSine, easeOutBack, easeOutBounce, easeOutCirc, easeOutCubic, easeOutElastic, easeOutExpo, easeOutQuad, easeOutQuart, easeOutQuint, easeOutSine, hashU32, inverseLerp, lerp, lineVsCircle, lineVsRect, linear, map, pingPong, pointInCircle, pointInRect, radToDeg, randomFloat, randomInt, randomPointInCircle, randomVec2InRect, rayVsRect, rectVsCircle, rectVsRect, remainingInWindow, rotateTowards, seededIndex, shuffle, sign, smoothStep, springIn, springInOut, springOut, step, vec2, weightedIndex, weightedIndexBy, weightedPick, windowExpired, wrap };
486
+ export { Circle, Color, type EasingFn, Mat3, type Oklab, type Oklch, Rect, SeededRNG, Transform2D, Vec2, advanceWindowedStreak, angleDelta, approxEquals, bezier2, bezier2Into, bezier2Length, bezier3, bezier3Into, bezier3Length, cappedBonus, catmullRom, catmullRomInto, catmullRomLength, choose, circleVsCircle, clamp, degToRad, easeInBack, easeInBounce, easeInCirc, easeInCubic, easeInElastic, easeInExpo, easeInOutBack, easeInOutBounce, easeInOutCirc, easeInOutCubic, easeInOutElastic, easeInOutExpo, easeInOutQuad, easeInOutQuart, easeInOutQuint, easeInOutSine, easeInQuad, easeInQuart, easeInQuint, easeInSine, easeOutBack, easeOutBounce, easeOutCirc, easeOutCubic, easeOutElastic, easeOutExpo, easeOutQuad, easeOutQuart, easeOutQuint, easeOutSine, hashU32, inverseLerp, lerp, lineVsCircle, lineVsRect, linear, map, pingPong, pointInCircle, pointInRect, radToDeg, randomFloat, randomInt, randomPointInCircle, randomVec2InRect, rayVsRect, rectVsCircle, rectVsRect, remainingInWindow, rotateTowards, seededIndex, segmentIntersection, segmentIntersectionInto, segmentsIntersect, shuffle, sign, smoothStep, springIn, springInOut, springOut, step, vec2, weightedIndex, weightedIndexBy, weightedPick, windowExpired, wrap };
395
487
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/vec2.ts","../src/rect.ts","../src/circle.ts","../src/color.ts","../src/easings.ts","../src/intersection.ts","../src/transform2d.ts","../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CpB,YAAY,MAAQ,SAAO;;mCAe3B,MAAQ,SAAO;;+BAiBnB,YAAY,MAAQ,SAAO;;uBAejC,MAAI,MAAQ,SAAO;;8BA+BZ,aAAW,MAAQ,SAAO;;;;;cClJhC;UACH;cAEI;;EAKZ;;EAQA,MAAM,aAAa;;EAKnB,IAAI,aAAa;;;iBAMH,YAAY,aAAa;;iBAKzB,UAAU,aAAa;;iBAKvB,iBAAiB,GAAG,OAAO;;iBAQ3B,oBAAoB,YAAY,YAAY,iBAAiB;;iBAW7D,QAAQ,GAAG,OAAO,MAAM;;iBAWxB,OAAO,GAAG,gBAAgB,MAAM;;;;;iBAShC,cAAc,4BAA4B;;;;;iBAiB1C,gBAAgB,GAC9B,gBAAgB,KAChB,SAAS,MAAM,cACf;;;;;iBAkBc,aAAa,GAC3B,gBAAgB,KAChB,SAAS,MAAM,cACf,iBACC;;;;;;;iBAWa,QAAQ;;;;;;iBAYR,YAAY,cAAc;;;;;;;;;;;;iBCvI1B,YAAY,aAAa,cAAc;;;;;;;iBAWvC,sBACd,cACA,iBACA,eACA;;;;;;iBAWc,cAAc,iBAAiB,eAAe;;;;;iBAQ9C,kBAAkB,iBAAiB;;;;iBC3CnC,MAAM,eAAe,aAAa;;iBAKlC,KAAK,WAAW,WAAW;;iBAK3B,YAAY,WAAW,WAAW;;iBAOlC,IACd,eACA,eACA,eACA,gBACA;;iBASc,SAAS;;iBAKT,SAAS;;iBAKT,aAAa,WAAW,WAAW;;iBAKnC,KAAK,eAAe,aAAa;;iBAOjC,SAAS,WAAW;;iBAOpB,WAAW,eAAe,eAAe;;iBAQzC,KAAK;;;;;iBASL,WAAW,WAAW;;;iBAStB,cAAc,aAAa,gBAAgB"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/vec2.ts","../src/rect.ts","../src/circle.ts","../src/color.ts","../src/curves.ts","../src/easings.ts","../src/intersection.ts","../src/transform2d.ts","../src/mat3.ts","../src/random.ts","../src/reward.ts","../src/scalar.ts"],"mappings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AC3B,gBAAgB,KAChB,SAAS,MAAM,cACf,iBACC;;;;;;;iBAWa,QAAQ;;;;;;iBAYR,YAAY,cAAc;;;;;;;;;;;;iBC5J1B,YAAY,aAAa,cAAc;;;;;;;iBAWvC,sBACd,cACA,iBACA,eACA;;;;;;iBAWc,cAAc,iBAAiB,eAAe;;;;;iBAQ9C,kBAAkB,iBAAiB;;;;iBC3CnC,MAAM,eAAe,aAAa;;iBAKlC,KAAK,WAAW,WAAW;;iBAK3B,YAAY,WAAW,WAAW;;iBAOlC,IACd,eACA,eACA,eACA,gBACA;;iBASc,SAAS;;iBAKT,SAAS;;iBAKT,aAAa,WAAW,WAAW;;iBAKnC,KAAK,eAAe,aAAa;;iBAOjC,SAAS,WAAW;;iBAOpB,WAAW,eAAe,eAAe;;iBAQzC,KAAK;;;;;iBASL,WAAW,WAAW;;;iBAStB,cAAc,aAAa,gBAAgB"}
package/dist/index.d.ts CHANGED
@@ -27,8 +27,9 @@ declare const Vec2: {
27
27
  readonly scale: (v: Vec2, s: number, out?: Vec2) => Vec2;
28
28
  /** Returns a unit vector. Returns zero vector if length is 0. */
29
29
  readonly normalize: (v: Vec2, out?: Vec2) => Vec2;
30
- /** Zero-alloc; writes into `out`. Mandatory `out` so callers avoid temporaries in hot paths. */
31
- readonly normalizeOut: (dx: number, dy: number, speed: number, out: Vec2) => Vec2;
30
+ /** The direction of `(dx, dy)` scaled to `length`; writes zeros when `(dx, dy)` is shorter than
31
+ * 1e-6. Zero-alloc, mandatory `out`; scalar components so hot paths need no temporary Vec2. */
32
+ readonly scaleToLengthInto: (dx: number, dy: number, length: number, out: Vec2) => Vec2;
32
33
  /** Dot product. */
33
34
  readonly dot: (a: Vec2, b: Vec2) => number;
34
35
  /** 2D cross product (z-component of the 3D cross). */
@@ -64,7 +65,7 @@ declare const Vec2: {
64
65
  /** Zero-alloc homing steer: rotate velocity (vx,vy) toward direction (dx,dy) by at most maxStep
65
66
  * radians, preserving speed; writes into out. Mandatory out. Byte-identical to hand-rolled
66
67
  * homing-bullet steering (Math.hypot speed + atan2 + branch-form turn + cos/sin * speed). */
67
- readonly turnVelocityToward: (vx: number, vy: number, dx: number, dy: number, maxStep: number, out: Vec2) => Vec2;
68
+ readonly turnVelocityTowardInto: (vx: number, vy: number, dx: number, dy: number, maxStep: number, out: Vec2) => Vec2;
68
69
  };
69
70
  //#endregion
70
71
  //#region src/rect.d.ts
@@ -171,6 +172,56 @@ declare const Color: {
171
172
  readonly contrastRatio: (fg: Color, bg: Color) => number;
172
173
  };
173
174
  //#endregion
175
+ //#region src/curves.d.ts
176
+ /**
177
+ * Parametric curves — quadratic/cubic Bézier and Catmull-Rom — plus approximate
178
+ * arc length for each.
179
+ *
180
+ * Every sampler comes in two forms, per the repo's hot-path convention: an
181
+ * allocating one returning a fresh `Vec2`, and an `…Into` one writing to a
182
+ * caller-owned buffer. Sampling a path each frame is exactly the case the
183
+ * `…Into` forms exist for.
184
+ *
185
+ * Control points are passed as loose numbers rather than `Vec2` objects so a
186
+ * caller holding coordinates in a `Float32Array` — the documented storage for
187
+ * bulk numeric data — can sample without building temporaries first.
188
+ */
189
+ /** Quadratic Bézier at `t`, writing into `out`. `t` is clamped to [0, 1]. */
190
+ declare function bezier2Into(p0x: number, p0y: number, p1x: number, p1y: number, p2x: number, p2y: number, t: number, out: Vec2): Vec2;
191
+ /** Quadratic Bézier at `t`. Allocates — see `bezier2Into` for the hot path. */
192
+ declare function bezier2(p0x: number, p0y: number, p1x: number, p1y: number, p2x: number, p2y: number, t: number): Vec2;
193
+ /** Cubic Bézier at `t`, writing into `out`. `t` is clamped to [0, 1]. */
194
+ declare function bezier3Into(p0x: number, p0y: number, p1x: number, p1y: number, p2x: number, p2y: number, p3x: number, p3y: number, t: number, out: Vec2): Vec2;
195
+ /** Cubic Bézier at `t`. Allocates — see `bezier3Into` for the hot path. */
196
+ declare function bezier3(p0x: number, p0y: number, p1x: number, p1y: number, p2x: number, p2y: number, p3x: number, p3y: number, t: number): Vec2;
197
+ /**
198
+ * Centripetal-free (uniform) Catmull-Rom spline at `t`, writing into `out`.
199
+ *
200
+ * The curve passes **through** `p1` and `p2`; `p0` and `p3` are the neighbouring
201
+ * control points that set the tangents, and `t` runs from `p1` (0) to `p2` (1).
202
+ * That interpolating property is the reason to reach for this over a Bézier when
203
+ * a path must hit its waypoints exactly.
204
+ */
205
+ declare function catmullRomInto(p0x: number, p0y: number, p1x: number, p1y: number, p2x: number, p2y: number, p3x: number, p3y: number, t: number, out: Vec2): Vec2;
206
+ /** Catmull-Rom at `t`. Allocates — see `catmullRomInto` for the hot path. */
207
+ declare function catmullRom(p0x: number, p0y: number, p1x: number, p1y: number, p2x: number, p2y: number, p3x: number, p3y: number, t: number): Vec2;
208
+ /**
209
+ * Approximate arc length by sampling `segments` chords.
210
+ *
211
+ * Always an **underestimate**: a chord is the shortest path between its
212
+ * endpoints, so a polyline through the curve is never longer than the curve.
213
+ * Error falls roughly with the square of `segments`; 16 is a reasonable default
214
+ * for UI paths, more for anything a camera follows closely.
215
+ */
216
+ declare function bezier2Length(p0x: number, p0y: number, p1x: number, p1y: number, p2x: number, p2y: number, segments?: number): number;
217
+ /** Approximate arc length of a cubic Bézier. See `bezier2Length`. */
218
+ declare function bezier3Length(p0x: number, p0y: number, p1x: number, p1y: number, p2x: number, p2y: number, p3x: number, p3y: number, segments?: number): number;
219
+ /**
220
+ * Approximate arc length of the Catmull-Rom span between `p1` and `p2`.
221
+ * See `bezier2Length` for the accuracy note.
222
+ */
223
+ declare function catmullRomLength(p0x: number, p0y: number, p1x: number, p1y: number, p2x: number, p2y: number, p3x: number, p3y: number, segments?: number): number;
224
+ //#endregion
174
225
  //#region src/easings.d.ts
175
226
  declare function linear(t: number): number;
176
227
  declare function step(t: number): number;
@@ -226,6 +277,32 @@ declare function lineVsRect(x1: number, y1: number, x2: number, y2: number, r: R
226
277
  declare function lineVsCircle(x1: number, y1: number, x2: number, y2: number, c: Circle): boolean;
227
278
  /** Ray intersection with AABB. Returns t (distance) or null if no hit. */
228
279
  declare function rayVsRect(originX: number, originY: number, dirX: number, dirY: number, r: Rect): number | null;
280
+ /**
281
+ * Do two segments intersect, including collinear overlap?
282
+ *
283
+ * The companion to `segmentIntersection`: that returns *where* two segments
284
+ * cross and is `null` when there is no single crossing point, which includes
285
+ * collinear segments lying on top of each other. Those genuinely do intersect,
286
+ * so a caller who only needs the yes/no answer asks here instead.
287
+ */
288
+ declare function segmentsIntersect(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, x4: number, y4: number): boolean;
289
+ /**
290
+ * Where two segments cross, written into `out`.
291
+ *
292
+ * Returns `null` when there is no **single** crossing point — segments that miss
293
+ * each other, are parallel, or are collinear. Collinear overlap is the case
294
+ * worth knowing about: the segments do intersect, at infinitely many points, so
295
+ * there is no one answer to write into `out`. Use `segmentsIntersect` when the
296
+ * yes/no answer is what you need.
297
+ *
298
+ * `out` is left untouched when the result is `null`.
299
+ */
300
+ declare function segmentIntersectionInto(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, x4: number, y4: number, out: Vec2): Vec2 | null;
301
+ /**
302
+ * Where two segments cross. Allocates — see `segmentIntersectionInto` for the
303
+ * hot path.
304
+ */
305
+ declare function segmentIntersection(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, x4: number, y4: number): Vec2 | null;
229
306
  //#endregion
230
307
  //#region src/transform2d.d.ts
231
308
  /** 2D transform: position, rotation (radians), and scale. */
@@ -287,6 +364,21 @@ declare class SeededRNG {
287
364
  float(min: number, max: number): number;
288
365
  /** Returns an integer in [min, max] (inclusive). */
289
366
  int(min: number, max: number): number;
367
+ /**
368
+ * The generator's entire internal state, as a single int32.
369
+ *
370
+ * Enough to resume the exact sequence later, which is what makes a save file
371
+ * or a replay reproducible: store this alongside the save, hand it back to
372
+ * `setState`, and the next `next()` returns what it would have returned.
373
+ */
374
+ getState(): number;
375
+ /**
376
+ * Restore a state previously read from `getState`.
377
+ *
378
+ * Coerced to int32 exactly as the constructor coerces a seed, so any number
379
+ * is accepted and a round-trip through JSON is safe.
380
+ */
381
+ setState(state: number): void;
290
382
  }
291
383
  /** Returns a random float in [min, max). */
292
384
  declare function randomFloat(min: number, max: number): number;
@@ -391,5 +483,5 @@ declare function angleDelta(a: number, b: number): number;
391
483
  * angle (NOT re-wrapped). Branch-form step clamp — byte-identical to hand-rolled homing steering. */
392
484
  declare function rotateTowards(cur: number, target: number, maxStep: number): number;
393
485
  //#endregion
394
- export { Circle, Color, type EasingFn, Mat3, type Oklab, type Oklch, Rect, SeededRNG, Transform2D, Vec2, advanceWindowedStreak, angleDelta, approxEquals, cappedBonus, choose, circleVsCircle, clamp, degToRad, easeInBack, easeInBounce, easeInCirc, easeInCubic, easeInElastic, easeInExpo, easeInOutBack, easeInOutBounce, easeInOutCirc, easeInOutCubic, easeInOutElastic, easeInOutExpo, easeInOutQuad, easeInOutQuart, easeInOutQuint, easeInOutSine, easeInQuad, easeInQuart, easeInQuint, easeInSine, easeOutBack, easeOutBounce, easeOutCirc, easeOutCubic, easeOutElastic, easeOutExpo, easeOutQuad, easeOutQuart, easeOutQuint, easeOutSine, hashU32, inverseLerp, lerp, lineVsCircle, lineVsRect, linear, map, pingPong, pointInCircle, pointInRect, radToDeg, randomFloat, randomInt, randomPointInCircle, randomVec2InRect, rayVsRect, rectVsCircle, rectVsRect, remainingInWindow, rotateTowards, seededIndex, shuffle, sign, smoothStep, springIn, springInOut, springOut, step, vec2, weightedIndex, weightedIndexBy, weightedPick, windowExpired, wrap };
486
+ export { Circle, Color, type EasingFn, Mat3, type Oklab, type Oklch, Rect, SeededRNG, Transform2D, Vec2, advanceWindowedStreak, angleDelta, approxEquals, bezier2, bezier2Into, bezier2Length, bezier3, bezier3Into, bezier3Length, cappedBonus, catmullRom, catmullRomInto, catmullRomLength, choose, circleVsCircle, clamp, degToRad, easeInBack, easeInBounce, easeInCirc, easeInCubic, easeInElastic, easeInExpo, easeInOutBack, easeInOutBounce, easeInOutCirc, easeInOutCubic, easeInOutElastic, easeInOutExpo, easeInOutQuad, easeInOutQuart, easeInOutQuint, easeInOutSine, easeInQuad, easeInQuart, easeInQuint, easeInSine, easeOutBack, easeOutBounce, easeOutCirc, easeOutCubic, easeOutElastic, easeOutExpo, easeOutQuad, easeOutQuart, easeOutQuint, easeOutSine, hashU32, inverseLerp, lerp, lineVsCircle, lineVsRect, linear, map, pingPong, pointInCircle, pointInRect, radToDeg, randomFloat, randomInt, randomPointInCircle, randomVec2InRect, rayVsRect, rectVsCircle, rectVsRect, remainingInWindow, rotateTowards, seededIndex, segmentIntersection, segmentIntersectionInto, segmentsIntersect, shuffle, sign, smoothStep, springIn, springInOut, springOut, step, vec2, weightedIndex, weightedIndexBy, weightedPick, windowExpired, wrap };
395
487
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/vec2.ts","../src/rect.ts","../src/circle.ts","../src/color.ts","../src/easings.ts","../src/intersection.ts","../src/transform2d.ts","../src/mat3.ts","../src/random.ts","../src/reward.ts","../src/scalar.ts"],"mappings":";;KAGY;EAAS;EAAW;;;iBAGhB,KAAK,YAAO,aAAQ;cAMvB;;uBAEH;;sBAID;;qBAID;;uBAIE;;uBAIA;;wBAIC;;oBAKF,MAAI,GAAK,MAAI,MAAQ,SAAO;;oBAU5B,MAAI,GAAK,MAAI,MAAQ,SAAO;;sBAU1B,MAAI,WAAW,MAAQ,SAAO;;0BAU1B,MAAI,MAAQ,SAAO;;sCAoBT,YAAY,eAAe,KAAO,SAAO;;oBAczD,MAAI,GAAK;;sBAKP,MAAI,GAAK;;;;qBAOV,MAAI,MAAQ,SAAO;;gCAYV,GAAK,MAAI,MAAQ,SAAO;;qBAYjC,MAAI,GAAK,MAAI,WAAW,MAAQ,SAAO;;sBAYtC,MAAI,GAAK,MAAI,WAAW,MAAQ,SAAO;;yBAsBpC,MAAI,GAAK;;2BAOP,MAAI,GAAK;;uBAOb;;yBAKE;;sBAKH;;uBAKC,MAAI,eAAe,MAAQ,SA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;;;;iBAWvC,sBACd,cACA,iBACA,eACA;;;;;;iBAWc,cAAc,iBAAiB,eAAe;;;;;iBAQ9C,kBAAkB,iBAAiB;;;;iBC3CnC,MAAM,eAAe,aAAa;;iBAKlC,KAAK,WAAW,WAAW;;iBAK3B,YAAY,WAAW,WAAW;;iBAOlC,IACd,eACA,eACA,eACA,gBACA;;iBASc,SAAS;;iBAKT,SAAS;;iBAKT,aAAa,WAAW,WAAW;;iBAKnC,KAAK,eAAe,aAAa;;iBAOjC,SAAS,WAAW;;iBAOpB,WAAW,eAAe,eAAe;;iBAQzC,KAAK;;;;;iBASL,WAAW,WAAW;;;iBAStB,cAAc,aAAa,gBAAgB"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/vec2.ts","../src/rect.ts","../src/circle.ts","../src/color.ts","../src/curves.ts","../src/easings.ts","../src/intersection.ts","../src/transform2d.ts","../src/mat3.ts","../src/random.ts","../src/reward.ts","../src/scalar.ts"],"mappings":";;KAGY;EAAS;EAAW;;;iBAGhB,KAAK,YAAO,aAAQ;cAMvB;;uBAEH;;sBAID;;qBAID;;uBAIE;;uBAIA;;wBAIC;;oBAKF,MAAI,GAAK,MAAI,MAAQ,SAAO;;oBAU5B,MAAI,GAAK,MAAI,MAAQ,SAAO;;sBAU1B,MAAI,WAAW,MAAQ,SAAO;;0BAU1B,MAAI,MAAQ,SAAO;;;2CAqBJ,YAAY,gBAAgB,KAAO,SAAO;;oBAc/D,MAAI,GAAK;;sBAKP,MAAI,GAAK;;;;qBAOV,MAAI,MAAQ,SAAO;;gCAYV,GAAK,MAAI,MAAQ,SAAO;;qBAYjC,MAAI,GAAK,MAAI,WAAW,MAAQ,SAAO;;sBAYtC,MAAI,GAAK,MAAI,WAAW,MAAQ,SAAO;;yBAsBpC,MAAI,GAAK;;2BAOP,MAAI,GAAK;;uBAOb;;yBAKE;;sBAKH;;uBAKC,MAAI,eAAe,MAAQ,SAAO;;uBAclC,MAAI,GAAK,MAAI;;sBAKd,SAAO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