@pawells/math-extended 1.0.5 → 2.0.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 (106) hide show
  1. package/README.md +5 -5
  2. package/build/angles.d.ts +43 -3
  3. package/build/angles.d.ts.map +1 -1
  4. package/build/angles.js +61 -34
  5. package/build/angles.js.map +1 -1
  6. package/build/clamp.d.ts +5 -3
  7. package/build/clamp.d.ts.map +1 -1
  8. package/build/clamp.js +5 -3
  9. package/build/clamp.js.map +1 -1
  10. package/build/interpolation.d.ts +444 -67
  11. package/build/interpolation.d.ts.map +1 -1
  12. package/build/interpolation.js +444 -67
  13. package/build/interpolation.js.map +1 -1
  14. package/build/matrices/_exports.d.ts +13 -0
  15. package/build/matrices/_exports.d.ts.map +1 -0
  16. package/build/matrices/_exports.js +13 -0
  17. package/build/matrices/_exports.js.map +1 -0
  18. package/build/matrices/arithmetic.d.ts +170 -181
  19. package/build/matrices/arithmetic.d.ts.map +1 -1
  20. package/build/matrices/arithmetic.js +192 -202
  21. package/build/matrices/arithmetic.js.map +1 -1
  22. package/build/matrices/asserts.d.ts +244 -116
  23. package/build/matrices/asserts.d.ts.map +1 -1
  24. package/build/matrices/asserts.js +291 -94
  25. package/build/matrices/asserts.js.map +1 -1
  26. package/build/matrices/core.d.ts +40 -41
  27. package/build/matrices/core.d.ts.map +1 -1
  28. package/build/matrices/core.js +12 -13
  29. package/build/matrices/core.js.map +1 -1
  30. package/build/matrices/decompositions.d.ts +121 -124
  31. package/build/matrices/decompositions.d.ts.map +1 -1
  32. package/build/matrices/decompositions.js +168 -226
  33. package/build/matrices/decompositions.js.map +1 -1
  34. package/build/matrices/index.d.ts +3 -2
  35. package/build/matrices/index.d.ts.map +1 -1
  36. package/build/matrices/index.js +5 -2
  37. package/build/matrices/index.js.map +1 -1
  38. package/build/matrices/linear-algebra.d.ts +18 -13
  39. package/build/matrices/linear-algebra.d.ts.map +1 -1
  40. package/build/matrices/linear-algebra.js +58 -23
  41. package/build/matrices/linear-algebra.js.map +1 -1
  42. package/build/matrices/normalization.d.ts +8 -8
  43. package/build/matrices/transformations.d.ts +184 -168
  44. package/build/matrices/transformations.d.ts.map +1 -1
  45. package/build/matrices/transformations.js +99 -83
  46. package/build/matrices/transformations.js.map +1 -1
  47. package/build/matrices/types.d.ts +12 -12
  48. package/build/matrices/types.d.ts.map +1 -1
  49. package/build/quaternions/_exports.d.ts +11 -0
  50. package/build/quaternions/_exports.d.ts.map +1 -0
  51. package/build/quaternions/_exports.js +11 -0
  52. package/build/quaternions/_exports.js.map +1 -0
  53. package/build/quaternions/asserts.d.ts +115 -7
  54. package/build/quaternions/asserts.d.ts.map +1 -1
  55. package/build/quaternions/asserts.js +162 -8
  56. package/build/quaternions/asserts.js.map +1 -1
  57. package/build/quaternions/conversions.d.ts +31 -21
  58. package/build/quaternions/conversions.d.ts.map +1 -1
  59. package/build/quaternions/conversions.js +28 -18
  60. package/build/quaternions/conversions.js.map +1 -1
  61. package/build/quaternions/core.d.ts +73 -41
  62. package/build/quaternions/core.d.ts.map +1 -1
  63. package/build/quaternions/core.js +84 -49
  64. package/build/quaternions/core.js.map +1 -1
  65. package/build/quaternions/index.d.ts +3 -2
  66. package/build/quaternions/index.d.ts.map +1 -1
  67. package/build/quaternions/index.js +5 -2
  68. package/build/quaternions/index.js.map +1 -1
  69. package/build/quaternions/interpolation.d.ts +15 -9
  70. package/build/quaternions/interpolation.d.ts.map +1 -1
  71. package/build/quaternions/interpolation.js +15 -9
  72. package/build/quaternions/interpolation.js.map +1 -1
  73. package/build/quaternions/predefined.d.ts +9 -3
  74. package/build/quaternions/predefined.d.ts.map +1 -1
  75. package/build/quaternions/predefined.js +9 -3
  76. package/build/quaternions/predefined.js.map +1 -1
  77. package/build/quaternions/types.d.ts +3 -3
  78. package/build/random.d.ts +5 -2
  79. package/build/random.d.ts.map +1 -1
  80. package/build/random.js +20 -17
  81. package/build/random.js.map +1 -1
  82. package/build/vectors/_exports.d.ts +10 -0
  83. package/build/vectors/_exports.d.ts.map +1 -0
  84. package/build/vectors/_exports.js +10 -0
  85. package/build/vectors/_exports.js.map +1 -0
  86. package/build/vectors/asserts.d.ts +153 -49
  87. package/build/vectors/asserts.d.ts.map +1 -1
  88. package/build/vectors/asserts.js +202 -52
  89. package/build/vectors/asserts.js.map +1 -1
  90. package/build/vectors/core.d.ts +216 -137
  91. package/build/vectors/core.d.ts.map +1 -1
  92. package/build/vectors/core.js +217 -158
  93. package/build/vectors/core.js.map +1 -1
  94. package/build/vectors/index.d.ts +1 -0
  95. package/build/vectors/index.d.ts.map +1 -1
  96. package/build/vectors/index.js +3 -0
  97. package/build/vectors/index.js.map +1 -1
  98. package/build/vectors/interpolation.d.ts +39 -27
  99. package/build/vectors/interpolation.d.ts.map +1 -1
  100. package/build/vectors/interpolation.js +39 -27
  101. package/build/vectors/interpolation.js.map +1 -1
  102. package/build/vectors/predefined.d.ts +48 -24
  103. package/build/vectors/predefined.d.ts.map +1 -1
  104. package/build/vectors/predefined.js +38 -18
  105. package/build/vectors/predefined.js.map +1 -1
  106. package/package.json +12 -15
@@ -40,18 +40,32 @@ const BACK_INOUT_SCALE = 1.525; // scale factor for back ease-in-out overshoot (
40
40
  * @returns `a + (b - a) * t`
41
41
  *
42
42
  * @example
43
- * LinearInterpolation(0, 100, 0.5) // 50
44
- * LinearInterpolation(0, 100, 0) // 0
45
- * LinearInterpolation(0, 100, 1) // 100
46
- * LinearInterpolation(0, 100, 1.5) // 150 (extrapolation)
43
+ * ```typescript
44
+ * LinearInterpolation(0, 100, 0.5) // 50
45
+ * LinearInterpolation(0, 100, 0) // 0
46
+ * LinearInterpolation(0, 100, 1) // 100
47
+ * LinearInterpolation(0, 100, 1.5) // 150 (extrapolation)
48
+ * ```
47
49
  */
48
50
  export function LinearInterpolation(a, b, t) {
49
51
  // Do not clamp t, allow extrapolation for LERP
50
52
  return a + ((b - a) * t);
51
53
  }
52
54
  /**
53
- * Smooth step interpolation (3t² - 2t³)
54
- * Provides smooth acceleration and deceleration with zero derivatives at endpoints
55
+ * Smooth step interpolation (3t² 2t³).
56
+ * Provides smooth acceleration and deceleration with zero first derivatives at both endpoints.
57
+ *
58
+ * @param a - Start value (result when t = 0)
59
+ * @param b - End value (result when t = 1)
60
+ * @param t - Interpolation parameter — unclamped, allowing extrapolation
61
+ * @returns Interpolated value using cubic smooth-step curve
62
+ *
63
+ * @example
64
+ * ```typescript
65
+ * SmoothStep(0, 10, 0) // 0
66
+ * SmoothStep(0, 10, 1) // 10
67
+ * SmoothStep(0, 10, 0.25) // 1.5625 (slower start than LinearInterpolation's 2.5)
68
+ * ```
55
69
  */
56
70
  export function SmoothStep(a, b, t) {
57
71
  // Allow extrapolation by not clamping t
@@ -59,8 +73,21 @@ export function SmoothStep(a, b, t) {
59
73
  return a + ((b - a) * smoothT);
60
74
  }
61
75
  /**
62
- * Smoother step interpolation (6t⁵ - 15t⁴ + 10t³)
63
- * Even smoother than SmoothStep with zero first and second derivatives at endpoints
76
+ * Smoother step interpolation (6t⁵ 15t⁴ + 10t³).
77
+ * Even smoother than SmoothStep with zero first and second derivatives at both endpoints
78
+ * (Ken Perlin's improvement).
79
+ *
80
+ * @param a - Start value (result when t = 0)
81
+ * @param b - End value (result when t = 1)
82
+ * @param t - Interpolation parameter — unclamped, allowing extrapolation
83
+ * @returns Interpolated value using quintic smoother-step curve
84
+ *
85
+ * @example
86
+ * ```typescript
87
+ * SmootherStep(0, 10, 0) // 0
88
+ * SmootherStep(0, 10, 1) // 10
89
+ * SmootherStep(0, 10, 0.25) // ~1.04 (smoother start than SmoothStep)
90
+ * ```
64
91
  */
65
92
  export function SmootherStep(a, b, t) {
66
93
  // Allow extrapolation by not clamping t
@@ -68,40 +95,100 @@ export function SmootherStep(a, b, t) {
68
95
  return a + ((b - a) * smoothT);
69
96
  }
70
97
  /**
71
- * Quadratic ease-in interpolation (t²)
72
- * Accelerates slowly at the beginning
98
+ * Quadratic ease-in interpolation (t²).
99
+ * Accelerates from rest — starts slowly and gains speed toward the end.
100
+ *
101
+ * @param a - Start value (result when t = 0)
102
+ * @param b - End value (result when t = 1)
103
+ * @param t - Interpolation parameter — unclamped, allowing extrapolation
104
+ * @returns Interpolated value with quadratic acceleration from start
105
+ *
106
+ * @example
107
+ * ```typescript
108
+ * QuadraticEaseIn(0, 10, 0) // 0
109
+ * QuadraticEaseIn(0, 10, 1) // 10
110
+ * QuadraticEaseIn(0, 10, 0.5) // 2.5 (only 25% progress at the midpoint)
111
+ * ```
73
112
  */
74
113
  export function QuadraticEaseIn(a, b, t) {
75
114
  // Allow extrapolation by not clamping t
76
115
  return a + ((b - a) * t * t);
77
116
  }
78
117
  /**
79
- * Quadratic ease-out interpolation (1 - (1-t)²)
80
- * Decelerates slowly at the end
118
+ * Quadratic ease-out interpolation (1 (1t)²).
119
+ * Decelerates to rest — starts quickly and slows toward the end.
120
+ *
121
+ * @param a - Start value (result when t = 0)
122
+ * @param b - End value (result when t = 1)
123
+ * @param t - Interpolation parameter — unclamped, allowing extrapolation
124
+ * @returns Interpolated value with quadratic deceleration toward end
125
+ *
126
+ * @example
127
+ * ```typescript
128
+ * QuadraticEaseOut(0, 10, 0) // 0
129
+ * QuadraticEaseOut(0, 10, 1) // 10
130
+ * QuadraticEaseOut(0, 10, 0.5) // 7.5 (already 75% progress at the midpoint)
131
+ * ```
81
132
  */
82
133
  export function QuadraticEaseOut(a, b, t) {
83
134
  // Allow extrapolation by not clamping t
84
135
  return a + ((b - a) * (1 - Math.pow(1 - t, 2)));
85
136
  }
86
137
  /**
87
- * Cubic ease-in interpolation (t³)
88
- * More pronounced acceleration than quadratic
138
+ * Cubic ease-in interpolation (t³).
139
+ * More pronounced acceleration than quadratic — starts very slowly.
140
+ *
141
+ * @param a - Start value (result when t = 0)
142
+ * @param b - End value (result when t = 1)
143
+ * @param t - Interpolation parameter — unclamped, allowing extrapolation
144
+ * @returns Interpolated value with cubic acceleration from start
145
+ *
146
+ * @example
147
+ * ```typescript
148
+ * CubicEaseIn(0, 10, 0) // 0
149
+ * CubicEaseIn(0, 10, 1) // 10
150
+ * CubicEaseIn(0, 10, 0.5) // 1.25 (only 12.5% progress at the midpoint)
151
+ * ```
89
152
  */
90
153
  export function CubicEaseIn(a, b, t) {
91
154
  // Allow extrapolation by not clamping t
92
155
  return a + ((b - a) * t * t * t);
93
156
  }
94
157
  /**
95
- * Cubic ease-out interpolation (1 - (1-t)³)
96
- * More pronounced deceleration than quadratic
158
+ * Cubic ease-out interpolation (1 (1t)³).
159
+ * More pronounced deceleration than quadratic — slows very gradually at the end.
160
+ *
161
+ * @param a - Start value (result when t = 0)
162
+ * @param b - End value (result when t = 1)
163
+ * @param t - Interpolation parameter — unclamped, allowing extrapolation
164
+ * @returns Interpolated value with cubic deceleration toward end
165
+ *
166
+ * @example
167
+ * ```typescript
168
+ * CubicEaseOut(0, 10, 0) // 0
169
+ * CubicEaseOut(0, 10, 1) // 10
170
+ * CubicEaseOut(0, 10, 0.5) // 8.75 (already 87.5% progress at the midpoint)
171
+ * ```
97
172
  */
98
173
  export function CubicEaseOut(a, b, t) {
99
174
  // Allow extrapolation by not clamping t
100
175
  return a + ((b - a) * (1 - Math.pow(1 - t, CUBIC)));
101
176
  }
102
177
  /**
103
- * Cosine interpolation - smooth curve using cosine function
104
- * Provides natural easing similar to SmoothStep but using trigonometry
178
+ * Cosine interpolation smooth curve using the cosine function.
179
+ * Provides natural easing similar to SmoothStep but using trigonometry.
180
+ *
181
+ * @param a - Start value (result when t = 0)
182
+ * @param b - End value (result when t = 1)
183
+ * @param t - Interpolation parameter — unclamped, allowing extrapolation
184
+ * @returns Interpolated value using cosine-based easing curve
185
+ *
186
+ * @example
187
+ * ```typescript
188
+ * CosineInterpolation(0, 10, 0) // 0
189
+ * CosineInterpolation(0, 10, 1) // 10
190
+ * CosineInterpolation(0, 10, 0.5) // 5 (same as LERP at midpoint; smooth near endpoints)
191
+ * ```
105
192
  */
106
193
  export function CosineInterpolation(a, b, t) {
107
194
  // Allow extrapolation by not clamping t
@@ -109,24 +196,60 @@ export function CosineInterpolation(a, b, t) {
109
196
  return a + ((b - a) * cosT);
110
197
  }
111
198
  /**
112
- * Sine ease-in interpolation
113
- * Slow start with smooth acceleration
199
+ * Sine ease-in interpolation.
200
+ * Slow start with smooth sinusoidal acceleration.
201
+ *
202
+ * @param a - Start value (result when t = 0)
203
+ * @param b - End value (result when t = 1)
204
+ * @param t - Interpolation parameter — unclamped, allowing extrapolation
205
+ * @returns Interpolated value with sine-based acceleration from start
206
+ *
207
+ * @example
208
+ * ```typescript
209
+ * SineEaseIn(0, 10, 0) // 0
210
+ * SineEaseIn(0, 10, 1) // 10
211
+ * SineEaseIn(0, 10, 0.5) // ~2.93 (slower than LinearInterpolation's 5 at midpoint)
212
+ * ```
114
213
  */
115
214
  export function SineEaseIn(a, b, t) {
116
215
  // Allow extrapolation by not clamping t
117
216
  return a + ((b - a) * (1 - Math.cos((t * Math.PI) / 2)));
118
217
  }
119
218
  /**
120
- * Sine ease-out interpolation
121
- * Smooth deceleration to the end
219
+ * Sine ease-out interpolation.
220
+ * Fast start with smooth sinusoidal deceleration to the end.
221
+ *
222
+ * @param a - Start value (result when t = 0)
223
+ * @param b - End value (result when t = 1)
224
+ * @param t - Interpolation parameter — unclamped, allowing extrapolation
225
+ * @returns Interpolated value with sine-based deceleration toward end
226
+ *
227
+ * @example
228
+ * ```typescript
229
+ * SineEaseOut(0, 10, 0) // 0
230
+ * SineEaseOut(0, 10, 1) // 10
231
+ * SineEaseOut(0, 10, 0.5) // ~7.07 (faster than LinearInterpolation's 5 at midpoint)
232
+ * ```
122
233
  */
123
234
  export function SineEaseOut(a, b, t) {
124
235
  // Allow extrapolation by not clamping t
125
236
  return a + ((b - a) * Math.sin((t * Math.PI) / 2));
126
237
  }
127
238
  /**
128
- * Exponential ease-in interpolation
129
- * Very slow start, then rapid acceleration
239
+ * Exponential ease-in interpolation (2^(10t−10)).
240
+ * Very slow start, then rapid exponential acceleration.
241
+ *
242
+ * @param a - Start value (result when t = 0)
243
+ * @param b - End value (result when t = 1)
244
+ * @param t - Interpolation parameter — unclamped, allowing extrapolation
245
+ * @returns Interpolated value with exponential acceleration from start
246
+ *
247
+ * @example
248
+ * ```typescript
249
+ * ExponentialEaseIn(0, 10, 0) // 0
250
+ * ExponentialEaseIn(0, 10, 1) // 10
251
+ * ExponentialEaseIn(0, 10, 0.5) // ~0.31 (barely moved at midpoint)
252
+ * ```
130
253
  */
131
254
  export function ExponentialEaseIn(a, b, t) {
132
255
  // Allow extrapolation by not clamping t
@@ -134,8 +257,20 @@ export function ExponentialEaseIn(a, b, t) {
134
257
  return a + ((b - a) * expT);
135
258
  }
136
259
  /**
137
- * Exponential ease-out interpolation
138
- * Rapid start, then very slow deceleration
260
+ * Exponential ease-out interpolation (1 − 2^(−10t)).
261
+ * Rapid start, then very slow exponential deceleration.
262
+ *
263
+ * @param a - Start value (result when t = 0)
264
+ * @param b - End value (result when t = 1)
265
+ * @param t - Interpolation parameter — unclamped, allowing extrapolation
266
+ * @returns Interpolated value with exponential deceleration toward end
267
+ *
268
+ * @example
269
+ * ```typescript
270
+ * ExponentialEaseOut(0, 10, 0) // 0
271
+ * ExponentialEaseOut(0, 10, 1) // 10
272
+ * ExponentialEaseOut(0, 10, 0.5) // ~9.69 (nearly done at midpoint)
273
+ * ```
139
274
  */
140
275
  export function ExponentialEaseOut(a, b, t) {
141
276
  // Allow extrapolation by not clamping t
@@ -143,8 +278,20 @@ export function ExponentialEaseOut(a, b, t) {
143
278
  return a + ((b - a) * expT);
144
279
  }
145
280
  /**
146
- * Elastic ease-out - bouncy spring-like motion
147
- * Creates an overshoot effect that bounces back
281
+ * Elastic ease-out bouncy spring-like motion.
282
+ * Creates an overshoot effect that oscillates before settling at the endpoint.
283
+ *
284
+ * @param a - Start value (result when t = 0)
285
+ * @param b - End value (result when t = 1)
286
+ * @param t - Interpolation parameter — clamped to [0, 1] at t=0 and t=1 boundaries
287
+ * @returns Interpolated value with elastic overshoot effect toward end
288
+ *
289
+ * @example
290
+ * ```typescript
291
+ * ElasticEaseOut(0, 10, 0) // 0
292
+ * ElasticEaseOut(0, 10, 1) // 10
293
+ * ElasticEaseOut(0, 10, 0.8) // ~10.86 (overshoots target before settling)
294
+ * ```
148
295
  */
149
296
  export function ElasticEaseOut(a, b, t) {
150
297
  // Allow extrapolation by not clamping t
@@ -156,8 +303,20 @@ export function ElasticEaseOut(a, b, t) {
156
303
  return a + ((b - a) * elasticT);
157
304
  }
158
305
  /**
159
- * Back ease-out - overshoots then settles
160
- * Creates a slight overshoot before settling at the target
306
+ * Back ease-out overshoots then settles.
307
+ * Creates a slight overshoot beyond the target before settling into place.
308
+ *
309
+ * @param a - Start value (result when t = 0)
310
+ * @param b - End value (result when t = 1)
311
+ * @param t - Interpolation parameter — unclamped, allowing extrapolation
312
+ * @returns Interpolated value with back overshoot effect toward end
313
+ *
314
+ * @example
315
+ * ```typescript
316
+ * BackEaseOut(0, 10, 0) // 0
317
+ * BackEaseOut(0, 10, 1) // 10
318
+ * BackEaseOut(0, 10, 0.75) // ~10.88 (overshoots before settling)
319
+ * ```
161
320
  */
162
321
  export function BackEaseOut(a, b, t) {
163
322
  // Allow extrapolation by not clamping t
@@ -167,8 +326,20 @@ export function BackEaseOut(a, b, t) {
167
326
  return a + ((b - a) * backT);
168
327
  }
169
328
  /**
170
- * Bounce ease-out - bouncing ball effect
171
- * Simulates a ball bouncing to rest
329
+ * Bounce ease-out simulates a ball bouncing to rest.
330
+ * Produces a series of bounces with decreasing amplitude before settling at the endpoint.
331
+ *
332
+ * @param a - Start value (result when t = 0)
333
+ * @param b - End value (result when t = 1)
334
+ * @param t - Interpolation parameter — unclamped, allowing extrapolation
335
+ * @returns Interpolated value with bouncing effect toward end
336
+ *
337
+ * @example
338
+ * ```typescript
339
+ * BounceEaseOut(0, 10, 0) // 0
340
+ * BounceEaseOut(0, 10, 1) // 10
341
+ * BounceEaseOut(0, 10, 0.5) // ~7.65 (mid-bounce)
342
+ * ```
172
343
  */
173
344
  export function BounceEaseOut(a, b, t) {
174
345
  // Allow extrapolation by not clamping t
@@ -193,8 +364,22 @@ export function BounceEaseOut(a, b, t) {
193
364
  return a + ((b - a) * bounceT);
194
365
  }
195
366
  /**
196
- * Catmull-Rom spline interpolation between 4 points
197
- * Useful for smooth curves through multiple points
367
+ * Catmull-Rom spline interpolation between four control points.
368
+ * Produces a smooth curve that passes through p1 and p2 with tangents influenced by p0 and p3.
369
+ *
370
+ * @param p0 - Previous control point (influences the tangent at p1)
371
+ * @param p1 - Start point (result when t = 0)
372
+ * @param p2 - End point (result when t = 1)
373
+ * @param p3 - Next control point (influences the tangent at p2)
374
+ * @param t - Interpolation parameter (typically [0, 1], supports extrapolation)
375
+ * @returns Smoothly interpolated value along the Catmull-Rom spline
376
+ *
377
+ * @example
378
+ * ```typescript
379
+ * CatmullRomInterpolation(0, 5, 10, 15, 0) // 5 (at p1)
380
+ * CatmullRomInterpolation(0, 5, 10, 15, 1) // 10 (at p2)
381
+ * CatmullRomInterpolation(0, 5, 10, 15, 0.5) // 7.5
382
+ * ```
198
383
  */
199
384
  export function CatmullRomInterpolation(p0, p1, p2, p3, t) {
200
385
  // Allow extrapolation by not clamping t
@@ -203,8 +388,22 @@ export function CatmullRomInterpolation(p0, p1, p2, p3, t) {
203
388
  return CATMULL_HALF * ((2 * p1) + ((-p0 + p2) * t) + (((2 * p0) - (CATMULL_5 * p1) + (QUARTIC * p2) - p3) * t2) + ((-p0 + (CUBIC * p1) - (CUBIC * p2) + p3) * t3));
204
389
  }
205
390
  /**
206
- * Hermite interpolation with tangent control
207
- * Provides precise control over curve tangents at endpoints
391
+ * Hermite spline interpolation with explicit tangent control.
392
+ * Provides precise control over the curve's tangent at both the start and end points.
393
+ *
394
+ * @param p0 - Start point (result when t = 0)
395
+ * @param p1 - End point (result when t = 1)
396
+ * @param t0 - Tangent (velocity) at the start point
397
+ * @param t1 - Tangent (velocity) at the end point
398
+ * @param t - Interpolation parameter (typically [0, 1], supports extrapolation)
399
+ * @returns Interpolated value along the Hermite spline
400
+ *
401
+ * @example
402
+ * ```typescript
403
+ * HermiteInterpolation(0, 10, 0, 0, 0) // 0 (at start)
404
+ * HermiteInterpolation(0, 10, 0, 0, 1) // 10 (at end)
405
+ * HermiteInterpolation(0, 10, 0, 0, 0.5) // 5 (flat tangents → same as LERP at midpoint)
406
+ * ```
208
407
  */
209
408
  export function HermiteInterpolation(p0, p1, t0, t1, t) {
210
409
  // Allow extrapolation by not clamping t
@@ -217,24 +416,61 @@ export function HermiteInterpolation(p0, p1, t0, t1, t) {
217
416
  return (h00 * p0) + (h10 * t0) + (h01 * p1) + (h11 * t1);
218
417
  }
219
418
  /**
220
- * Circular ease-in interpolation
221
- * Creates an accelerating curve based on quarter circle
419
+ * Circular ease-in interpolation (1 − √(1−t²)).
420
+ * Creates an accelerating curve based on the first quarter of a circle.
421
+ *
422
+ * @param a - Start value (result when t = 0)
423
+ * @param b - End value (result when t = 1)
424
+ * @param t - Interpolation parameter — clamped to [0, 1] for a valid circular arc
425
+ * @returns Interpolated value with circular acceleration from start
426
+ *
427
+ * @example
428
+ * ```typescript
429
+ * CircularEaseIn(0, 10, 0) // 0
430
+ * CircularEaseIn(0, 10, 1) // 10
431
+ * CircularEaseIn(0, 10, 0.5) // ~1.34 (very slow start along circular arc)
432
+ * ```
222
433
  */
223
434
  export function CircularEaseIn(a, b, t) {
224
435
  // Allow extrapolation by not clamping t
225
436
  return a + ((b - a) * (1 - Math.sqrt(1 - (t * t))));
226
437
  }
227
438
  /**
228
- * Circular ease-out interpolation
229
- * Creates a decelerating curve based on quarter circle
439
+ * Circular ease-out interpolation (√(1−(t−1)²)).
440
+ * Creates a decelerating curve based on the first quarter of a circle.
441
+ *
442
+ * @param a - Start value (result when t = 0)
443
+ * @param b - End value (result when t = 1)
444
+ * @param t - Interpolation parameter — clamped to [0, 1] for a valid circular arc
445
+ * @returns Interpolated value with circular deceleration toward end
446
+ *
447
+ * @example
448
+ * ```typescript
449
+ * CircularEaseOut(0, 10, 0) // 0
450
+ * CircularEaseOut(0, 10, 1) // 10
451
+ * CircularEaseOut(0, 10, 0.5) // ~8.66 (very fast start along circular arc)
452
+ * ```
230
453
  */
231
454
  export function CircularEaseOut(a, b, t) {
232
455
  // Allow extrapolation by not clamping t
233
456
  return a + ((b - a) * Math.sqrt(1 - Math.pow(t - 1, 2)));
234
457
  }
235
458
  /**
236
- * Quadratic ease-in-out interpolation (2t² for t<0.5, 1−(−2t+2)²/2 for t≥0.5)
237
- * Symmetrically accelerates at the start and decelerates at the end
459
+ * Quadratic ease-in-out interpolation (2t² for t < 0.5, 1 (−2t+2)²/2 for t 0.5).
460
+ * Symmetrically accelerates at the start and decelerates at the end.
461
+ *
462
+ * @param a - Start value (result when t = 0)
463
+ * @param b - End value (result when t = 1)
464
+ * @param t - Interpolation parameter (typically [0, 1])
465
+ * @returns Interpolated value with quadratic symmetric easing
466
+ *
467
+ * @example
468
+ * ```typescript
469
+ * QuadraticEaseInOut(0, 10, 0) // 0
470
+ * QuadraticEaseInOut(0, 10, 1) // 10
471
+ * QuadraticEaseInOut(0, 10, 0.25) // 1.25 (slow start)
472
+ * QuadraticEaseInOut(0, 10, 0.75) // 8.75 (slow end)
473
+ * ```
238
474
  */
239
475
  export function QuadraticEaseInOut(a, b, t) {
240
476
  const smoothT = t < EASE_INOUT_HALF
@@ -243,8 +479,21 @@ export function QuadraticEaseInOut(a, b, t) {
243
479
  return a + ((b - a) * smoothT);
244
480
  }
245
481
  /**
246
- * Cubic ease-in-out interpolation (4t³ for t<0.5, 1−(−2t+2)³/2 for t≥0.5)
247
- * More pronounced symmetrical acceleration/deceleration than quadratic
482
+ * Cubic ease-in-out interpolation (4t³ for t < 0.5, 1 (−2t+2)³/2 for t 0.5).
483
+ * More pronounced symmetrical acceleration/deceleration than quadratic ease-in-out.
484
+ *
485
+ * @param a - Start value (result when t = 0)
486
+ * @param b - End value (result when t = 1)
487
+ * @param t - Interpolation parameter (typically [0, 1])
488
+ * @returns Interpolated value with cubic symmetric easing
489
+ *
490
+ * @example
491
+ * ```typescript
492
+ * CubicEaseInOut(0, 10, 0) // 0
493
+ * CubicEaseInOut(0, 10, 1) // 10
494
+ * CubicEaseInOut(0, 10, 0.25) // 0.625 (very slow start)
495
+ * CubicEaseInOut(0, 10, 0.75) // 9.375 (very slow end)
496
+ * ```
248
497
  */
249
498
  export function CubicEaseInOut(a, b, t) {
250
499
  const smoothT = t < EASE_INOUT_HALF
@@ -253,16 +502,40 @@ export function CubicEaseInOut(a, b, t) {
253
502
  return a + ((b - a) * smoothT);
254
503
  }
255
504
  /**
256
- * Sine ease-in-out interpolation (−(cos(πt)−1)/2)
257
- * Smooth symmetric easing using cosine — gentle and natural feeling
505
+ * Sine ease-in-out interpolation (−(cos(πt) 1) / 2).
506
+ * Smooth symmetric easing using cosine — gentle and natural feeling.
507
+ *
508
+ * @param a - Start value (result when t = 0)
509
+ * @param b - End value (result when t = 1)
510
+ * @param t - Interpolation parameter (typically [0, 1])
511
+ * @returns Interpolated value with sine-based symmetric easing
512
+ *
513
+ * @example
514
+ * ```typescript
515
+ * SineEaseInOut(0, 10, 0) // 0
516
+ * SineEaseInOut(0, 10, 1) // 10
517
+ * SineEaseInOut(0, 10, 0.5) // 5 (symmetric midpoint)
518
+ * ```
258
519
  */
259
520
  export function SineEaseInOut(a, b, t) {
260
521
  const smoothT = -(Math.cos(t * Math.PI) - 1) / 2;
261
522
  return a + ((b - a) * smoothT);
262
523
  }
263
524
  /**
264
- * Exponential ease-in-out interpolation
265
- * Very slow at both ends, extremely rapid in the middle
525
+ * Exponential ease-in-out interpolation.
526
+ * Very slow at both ends with an extremely rapid transition in the middle.
527
+ *
528
+ * @param a - Start value (result when t = 0)
529
+ * @param b - End value (result when t = 1)
530
+ * @param t - Interpolation parameter (typically [0, 1])
531
+ * @returns Interpolated value with exponential symmetric easing
532
+ *
533
+ * @example
534
+ * ```typescript
535
+ * ExponentialEaseInOut(0, 10, 0) // 0
536
+ * ExponentialEaseInOut(0, 10, 1) // 10
537
+ * ExponentialEaseInOut(0, 10, 0.25) // ~0.16 (barely moving in the first quarter)
538
+ * ```
266
539
  */
267
540
  export function ExponentialEaseInOut(a, b, t) {
268
541
  if (t === 0)
@@ -275,8 +548,20 @@ export function ExponentialEaseInOut(a, b, t) {
275
548
  return a + ((b - a) * expT);
276
549
  }
277
550
  /**
278
- * Circular ease-in-out interpolation
279
- * Smooth symmetric arc-based easing
551
+ * Circular ease-in-out interpolation.
552
+ * Smooth symmetric arc-based easing using a circular curve.
553
+ *
554
+ * @param a - Start value (result when t = 0)
555
+ * @param b - End value (result when t = 1)
556
+ * @param t - Interpolation parameter (typically [0, 1])
557
+ * @returns Interpolated value with circular symmetric easing
558
+ *
559
+ * @example
560
+ * ```typescript
561
+ * CircularEaseInOut(0, 10, 0) // 0
562
+ * CircularEaseInOut(0, 10, 1) // 10
563
+ * CircularEaseInOut(0, 10, 0.25) // ~0.67 (very slow circular start)
564
+ * ```
280
565
  */
281
566
  export function CircularEaseInOut(a, b, t) {
282
567
  const smoothT = t < EASE_INOUT_HALF
@@ -285,8 +570,20 @@ export function CircularEaseInOut(a, b, t) {
285
570
  return a + ((b - a) * smoothT);
286
571
  }
287
572
  /**
288
- * Elastic ease-in interpolation
289
- * Spring-like acceleration from rest — starts with a bounce-back then launches forward
573
+ * Elastic ease-in interpolation.
574
+ * Spring-like acceleration from rest — starts with a backward oscillation then launches forward.
575
+ *
576
+ * @param a - Start value (result when t = 0)
577
+ * @param b - End value (result when t = 1)
578
+ * @param t - Interpolation parameter — clamped to [0, 1] at t=0 and t=1 boundaries
579
+ * @returns Interpolated value with elastic spring acceleration from start
580
+ *
581
+ * @example
582
+ * ```typescript
583
+ * ElasticEaseIn(0, 10, 0) // 0
584
+ * ElasticEaseIn(0, 10, 1) // 10
585
+ * ElasticEaseIn(0, 10, 0.5) // ~-0.16 (backward oscillation at midpoint before launching)
586
+ * ```
290
587
  */
291
588
  export function ElasticEaseIn(a, b, t) {
292
589
  if (t === 0 || t === 1)
@@ -296,8 +593,20 @@ export function ElasticEaseIn(a, b, t) {
296
593
  return a + ((b - a) * elasticT);
297
594
  }
298
595
  /**
299
- * Elastic ease-in-out interpolation
300
- * Spring-like oscillation at both the start and end
596
+ * Elastic ease-in-out interpolation.
597
+ * Spring-like oscillation at both the start and end of the motion.
598
+ *
599
+ * @param a - Start value (result when t = 0)
600
+ * @param b - End value (result when t = 1)
601
+ * @param t - Interpolation parameter — clamped to [0, 1] at t=0 and t=1 boundaries
602
+ * @returns Interpolated value with elastic oscillation at both ends
603
+ *
604
+ * @example
605
+ * ```typescript
606
+ * ElasticEaseInOut(0, 10, 0) // 0
607
+ * ElasticEaseInOut(0, 10, 1) // 10
608
+ * ElasticEaseInOut(0, 10, 0.4) // ~-1.17 (backward oscillation before midpoint)
609
+ * ```
301
610
  */
302
611
  export function ElasticEaseInOut(a, b, t) {
303
612
  if (t === 0 || t === 1)
@@ -309,8 +618,20 @@ export function ElasticEaseInOut(a, b, t) {
309
618
  return a + ((b - a) * elasticT);
310
619
  }
311
620
  /**
312
- * Back ease-in interpolation (c3t³ − c1t²)
313
- * Slight backward pull before launching forward
621
+ * Back ease-in interpolation (c3t³ − c1t²).
622
+ * Slight backward pull before launching forward — like winding up before a throw.
623
+ *
624
+ * @param a - Start value (result when t = 0)
625
+ * @param b - End value (result when t = 1)
626
+ * @param t - Interpolation parameter — unclamped, allowing extrapolation
627
+ * @returns Interpolated value with back overshoot at start
628
+ *
629
+ * @example
630
+ * ```typescript
631
+ * BackEaseIn(0, 10, 0) // 0
632
+ * BackEaseIn(0, 10, 1) // 10
633
+ * BackEaseIn(0, 10, 0.25) // ~-0.64 (dips below start before accelerating forward)
634
+ * ```
314
635
  */
315
636
  export function BackEaseIn(a, b, t) {
316
637
  const c1 = 1.70158;
@@ -319,8 +640,20 @@ export function BackEaseIn(a, b, t) {
319
640
  return a + ((b - a) * backT);
320
641
  }
321
642
  /**
322
- * Back ease-in-out interpolation
323
- * Slight backward pull at both ends before and after the main motion
643
+ * Back ease-in-out interpolation.
644
+ * Slight backward pull at both ends before and after the main forward motion.
645
+ *
646
+ * @param a - Start value (result when t = 0)
647
+ * @param b - End value (result when t = 1)
648
+ * @param t - Interpolation parameter — unclamped, allowing extrapolation
649
+ * @returns Interpolated value with back overshoot at both start and end
650
+ *
651
+ * @example
652
+ * ```typescript
653
+ * BackEaseInOut(0, 10, 0) // 0
654
+ * BackEaseInOut(0, 10, 1) // 10
655
+ * BackEaseInOut(0, 10, 0.25) // ~-1.00 (dips backward at start)
656
+ * ```
324
657
  */
325
658
  export function BackEaseInOut(a, b, t) {
326
659
  const c1 = 1.70158;
@@ -331,15 +664,39 @@ export function BackEaseInOut(a, b, t) {
331
664
  return a + ((b - a) * backT);
332
665
  }
333
666
  /**
334
- * Bounce ease-in interpolation
335
- * Bouncing ball effect with bounces at the start before settling at the target
667
+ * Bounce ease-in interpolation.
668
+ * Bouncing ball effect at the start — multiple bounces before launching toward the target.
669
+ *
670
+ * @param a - Start value (result when t = 0)
671
+ * @param b - End value (result when t = 1)
672
+ * @param t - Interpolation parameter — unclamped, allowing extrapolation
673
+ * @returns Interpolated value with bounce effect at start
674
+ *
675
+ * @example
676
+ * ```typescript
677
+ * BounceEaseIn(0, 10, 0) // 0
678
+ * BounceEaseIn(0, 10, 1) // 10
679
+ * BounceEaseIn(0, 10, 0.5) // ~2.34 (still bouncing at midpoint)
680
+ * ```
336
681
  */
337
682
  export function BounceEaseIn(a, b, t) {
338
683
  return a + ((b - a) * (1 - BounceEaseOut(0, 1, 1 - t)));
339
684
  }
340
685
  /**
341
- * Bounce ease-in-out interpolation
342
- * Bouncing ball effect at both the start and the end
686
+ * Bounce ease-in-out interpolation.
687
+ * Bouncing ball effect at both the start and end of the motion.
688
+ *
689
+ * @param a - Start value (result when t = 0)
690
+ * @param b - End value (result when t = 1)
691
+ * @param t - Interpolation parameter — unclamped, allowing extrapolation
692
+ * @returns Interpolated value with bounce effect at both start and end
693
+ *
694
+ * @example
695
+ * ```typescript
696
+ * BounceEaseInOut(0, 10, 0) // 0
697
+ * BounceEaseInOut(0, 10, 1) // 10
698
+ * BounceEaseInOut(0, 10, 0.25) // ~1.17 (bouncing at start quarter)
699
+ * ```
343
700
  */
344
701
  export function BounceEaseInOut(a, b, t) {
345
702
  const bounceT = t < EASE_INOUT_HALF
@@ -348,8 +705,22 @@ export function BounceEaseInOut(a, b, t) {
348
705
  return a + ((b - a) * bounceT);
349
706
  }
350
707
  /**
351
- * Step interpolation - instant transition at threshold
352
- * Useful for discrete state changes
708
+ * Step interpolation instant transition at a configurable threshold.
709
+ * Returns `a` when `t` is below the threshold, and `b` at or above it.
710
+ * Useful for discrete state changes and on/off animations.
711
+ *
712
+ * @param a - Start value (returned when t < threshold)
713
+ * @param b - End value (returned when t ≥ threshold)
714
+ * @param t - Interpolation parameter (clamped to [0, 1])
715
+ * @param threshold - Normalized transition point (default: 0.5; clamped to [0, 1])
716
+ * @returns Either `a` or `b` depending on `t` relative to `threshold`
717
+ *
718
+ * @example
719
+ * ```typescript
720
+ * StepInterpolation(0, 10, 0.3) // 0 (below default threshold of 0.5)
721
+ * StepInterpolation(0, 10, 0.7) // 10 (at or above default threshold of 0.5)
722
+ * StepInterpolation(0, 10, 0.3, 0.25) // 10 (above custom threshold of 0.25)
723
+ * ```
353
724
  */
354
725
  export function StepInterpolation(a, b, t, threshold = 0.5) {
355
726
  const clampedT = Clamp(t, 0, 1);
@@ -357,9 +728,15 @@ export function StepInterpolation(a, b, t, threshold = 0.5) {
357
728
  return clampedT < clampedThreshold ? a : b;
358
729
  }
359
730
  /**
360
- * Spherical linear interpolation for scalar values
361
- * Provides smooth interpolation along a spherical arc
362
- * Note: For true SLERP with vectors, use VectorSphericalLinearInterpolation
731
+ * Spherical linear interpolation for scalar values.
732
+ * For scalar inputs, this is mathematically equivalent to {@link LinearInterpolation}.
733
+ * For true spherical rotation interpolation, use `QuaternionSLERP` from the quaternions module.
734
+ *
735
+ * @param a - Start value (result when t = 0)
736
+ * @param b - End value (result when t = 1)
737
+ * @param t - Interpolation parameter — unclamped, allowing extrapolation
738
+ * @returns Linearly interpolated value (identical to `LinearInterpolation(a, b, t)`)
739
+ *
363
740
  * @deprecated This function is identical to LinearInterpolation and is not a true spherical interpolation. For quaternion spherical interpolation, use QuaternionSLERP from the quaternions module.
364
741
  */
365
742
  export function SphericalLinearInterpolation(a, b, t) {