@fluixi/utils 1.0.0-alpha.53
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/LICENSE +21 -0
- package/README.md +73 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1 -0
- package/dist/index.mjs +1 -0
- package/dist/lib/array/advanced.cjs +1 -0
- package/dist/lib/array/advanced.d.ts +1116 -0
- package/dist/lib/array/advanced.d.ts.map +1 -0
- package/dist/lib/array/advanced.js +2429 -0
- package/dist/lib/array/advanced.mjs +1 -0
- package/dist/lib/array/array.cjs +1 -0
- package/dist/lib/array/array.d.ts +6 -0
- package/dist/lib/array/array.d.ts.map +1 -0
- package/dist/lib/array/array.js +31 -0
- package/dist/lib/array/array.mjs +1 -0
- package/dist/lib/array/index.cjs +1 -0
- package/dist/lib/array/index.d.ts +4 -0
- package/dist/lib/array/index.d.ts.map +1 -0
- package/dist/lib/array/index.js +3 -0
- package/dist/lib/array/index.mjs +1 -0
- package/dist/lib/array/utils.cjs +1 -0
- package/dist/lib/array/utils.d.ts +100 -0
- package/dist/lib/array/utils.d.ts.map +1 -0
- package/dist/lib/array/utils.js +165 -0
- package/dist/lib/array/utils.mjs +1 -0
- package/dist/lib/color/color.cjs +1 -0
- package/dist/lib/color/color.d.ts +366 -0
- package/dist/lib/color/color.d.ts.map +1 -0
- package/dist/lib/color/color.js +722 -0
- package/dist/lib/color/color.mjs +1 -0
- package/dist/lib/color/constants.cjs +1 -0
- package/dist/lib/color/constants.d.ts +361 -0
- package/dist/lib/color/constants.d.ts.map +1 -0
- package/dist/lib/color/constants.js +358 -0
- package/dist/lib/color/constants.mjs +1 -0
- package/dist/lib/color/conversions.cjs +1 -0
- package/dist/lib/color/conversions.d.ts +166 -0
- package/dist/lib/color/conversions.d.ts.map +1 -0
- package/dist/lib/color/conversions.js +766 -0
- package/dist/lib/color/conversions.mjs +1 -0
- package/dist/lib/color/helpers.cjs +1 -0
- package/dist/lib/color/helpers.d.ts +75 -0
- package/dist/lib/color/helpers.d.ts.map +1 -0
- package/dist/lib/color/helpers.js +419 -0
- package/dist/lib/color/helpers.mjs +1 -0
- package/dist/lib/color/index.cjs +1 -0
- package/dist/lib/color/index.d.ts +12 -0
- package/dist/lib/color/index.d.ts.map +1 -0
- package/dist/lib/color/index.js +15 -0
- package/dist/lib/color/index.mjs +1 -0
- package/dist/lib/color/types.cjs +1 -0
- package/dist/lib/color/types.d.ts +179 -0
- package/dist/lib/color/types.d.ts.map +1 -0
- package/dist/lib/color/types.js +1 -0
- package/dist/lib/color/types.mjs +0 -0
- package/dist/lib/color/utils.cjs +1 -0
- package/dist/lib/color/utils.d.ts +199 -0
- package/dist/lib/color/utils.d.ts.map +1 -0
- package/dist/lib/color/utils.js +858 -0
- package/dist/lib/color/utils.mjs +1 -0
- package/dist/lib/compare/comparators.cjs +1 -0
- package/dist/lib/compare/comparators.d.ts +65 -0
- package/dist/lib/compare/comparators.d.ts.map +1 -0
- package/dist/lib/compare/comparators.js +210 -0
- package/dist/lib/compare/comparators.mjs +1 -0
- package/dist/lib/compare/index.cjs +1 -0
- package/dist/lib/compare/index.d.ts +2 -0
- package/dist/lib/compare/index.d.ts.map +1 -0
- package/dist/lib/compare/index.js +1 -0
- package/dist/lib/compare/index.mjs +1 -0
- package/dist/lib/crypto/hash.cjs +1 -0
- package/dist/lib/crypto/hash.d.ts +6 -0
- package/dist/lib/crypto/hash.d.ts.map +1 -0
- package/dist/lib/crypto/hash.js +53 -0
- package/dist/lib/crypto/hash.mjs +1 -0
- package/dist/lib/crypto/index.cjs +1 -0
- package/dist/lib/crypto/index.d.ts +2 -0
- package/dist/lib/crypto/index.d.ts.map +1 -0
- package/dist/lib/crypto/index.js +1 -0
- package/dist/lib/crypto/index.mjs +1 -0
- package/dist/lib/dom/events.cjs +1 -0
- package/dist/lib/dom/events.d.ts +159 -0
- package/dist/lib/dom/events.d.ts.map +1 -0
- package/dist/lib/dom/events.js +50 -0
- package/dist/lib/dom/events.mjs +1 -0
- package/dist/lib/dom/index.cjs +1 -0
- package/dist/lib/dom/index.d.ts +3 -0
- package/dist/lib/dom/index.d.ts.map +1 -0
- package/dist/lib/dom/index.js +2 -0
- package/dist/lib/dom/index.mjs +1 -0
- package/dist/lib/dom/utils.cjs +1 -0
- package/dist/lib/dom/utils.d.ts +6 -0
- package/dist/lib/dom/utils.d.ts.map +1 -0
- package/dist/lib/dom/utils.js +37 -0
- package/dist/lib/dom/utils.mjs +1 -0
- package/dist/lib/functions/functions.cjs +1 -0
- package/dist/lib/functions/functions.d.ts +329 -0
- package/dist/lib/functions/functions.d.ts.map +1 -0
- package/dist/lib/functions/functions.js +585 -0
- package/dist/lib/functions/functions.mjs +1 -0
- package/dist/lib/functions/index.cjs +1 -0
- package/dist/lib/functions/index.d.ts +3 -0
- package/dist/lib/functions/index.d.ts.map +1 -0
- package/dist/lib/functions/index.js +1 -0
- package/dist/lib/functions/index.mjs +1 -0
- package/dist/lib/functions/types.cjs +1 -0
- package/dist/lib/functions/types.d.ts +2 -0
- package/dist/lib/functions/types.d.ts.map +1 -0
- package/dist/lib/functions/types.js +1 -0
- package/dist/lib/functions/types.mjs +0 -0
- package/dist/lib/helpers.cjs +1 -0
- package/dist/lib/helpers.d.ts +13 -0
- package/dist/lib/helpers.d.ts.map +1 -0
- package/dist/lib/helpers.js +66 -0
- package/dist/lib/helpers.mjs +1 -0
- package/dist/lib/index.cjs +1 -0
- package/dist/lib/index.d.ts +6 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/index.js +8 -0
- package/dist/lib/index.mjs +1 -0
- package/dist/lib/maths/constants.cjs +1 -0
- package/dist/lib/maths/constants.d.ts +84 -0
- package/dist/lib/maths/constants.d.ts.map +1 -0
- package/dist/lib/maths/constants.js +79 -0
- package/dist/lib/maths/constants.mjs +1 -0
- package/dist/lib/maths/fn/advanced.cjs +1 -0
- package/dist/lib/maths/fn/advanced.d.ts +149 -0
- package/dist/lib/maths/fn/advanced.d.ts.map +1 -0
- package/dist/lib/maths/fn/advanced.js +264 -0
- package/dist/lib/maths/fn/advanced.mjs +1 -0
- package/dist/lib/maths/fn/basic.cjs +1 -0
- package/dist/lib/maths/fn/basic.d.ts +182 -0
- package/dist/lib/maths/fn/basic.d.ts.map +1 -0
- package/dist/lib/maths/fn/basic.js +343 -0
- package/dist/lib/maths/fn/basic.mjs +1 -0
- package/dist/lib/maths/fn/complex.cjs +1 -0
- package/dist/lib/maths/fn/complex.d.ts +153 -0
- package/dist/lib/maths/fn/complex.d.ts.map +1 -0
- package/dist/lib/maths/fn/complex.js +383 -0
- package/dist/lib/maths/fn/complex.mjs +1 -0
- package/dist/lib/maths/fn/index.cjs +1 -0
- package/dist/lib/maths/fn/index.d.ts +10 -0
- package/dist/lib/maths/fn/index.d.ts.map +1 -0
- package/dist/lib/maths/fn/index.js +9 -0
- package/dist/lib/maths/fn/index.mjs +1 -0
- package/dist/lib/maths/fn/trigo.cjs +1 -0
- package/dist/lib/maths/fn/trigo.d.ts +147 -0
- package/dist/lib/maths/fn/trigo.d.ts.map +1 -0
- package/dist/lib/maths/fn/trigo.js +227 -0
- package/dist/lib/maths/fn/trigo.mjs +1 -0
- package/dist/lib/maths/fn/vector.cjs +1 -0
- package/dist/lib/maths/fn/vector.d.ts +512 -0
- package/dist/lib/maths/fn/vector.d.ts.map +1 -0
- package/dist/lib/maths/fn/vector.js +1136 -0
- package/dist/lib/maths/fn/vector.mjs +1 -0
- package/dist/lib/maths/formatter.cjs +1 -0
- package/dist/lib/maths/formatter.d.ts +35 -0
- package/dist/lib/maths/formatter.d.ts.map +1 -0
- package/dist/lib/maths/formatter.js +56 -0
- package/dist/lib/maths/formatter.mjs +1 -0
- package/dist/lib/maths/guards.cjs +1 -0
- package/dist/lib/maths/guards.d.ts +166 -0
- package/dist/lib/maths/guards.d.ts.map +1 -0
- package/dist/lib/maths/guards.js +315 -0
- package/dist/lib/maths/guards.mjs +1 -0
- package/dist/lib/maths/index.cjs +1 -0
- package/dist/lib/maths/index.d.ts +24 -0
- package/dist/lib/maths/index.d.ts.map +1 -0
- package/dist/lib/maths/index.js +29 -0
- package/dist/lib/maths/index.mjs +1 -0
- package/dist/lib/maths/parser.cjs +1 -0
- package/dist/lib/maths/parser.d.ts +20 -0
- package/dist/lib/maths/parser.d.ts.map +1 -0
- package/dist/lib/maths/parser.js +78 -0
- package/dist/lib/maths/parser.mjs +1 -0
- package/dist/lib/maths/random.cjs +1 -0
- package/dist/lib/maths/random.d.ts +27 -0
- package/dist/lib/maths/random.d.ts.map +1 -0
- package/dist/lib/maths/random.js +49 -0
- package/dist/lib/maths/random.mjs +1 -0
- package/dist/lib/maths/types/advanced.cjs +1 -0
- package/dist/lib/maths/types/advanced.d.ts +357 -0
- package/dist/lib/maths/types/advanced.d.ts.map +1 -0
- package/dist/lib/maths/types/advanced.js +5 -0
- package/dist/lib/maths/types/advanced.mjs +0 -0
- package/dist/lib/maths/types/basic.cjs +1 -0
- package/dist/lib/maths/types/basic.d.ts +95 -0
- package/dist/lib/maths/types/basic.d.ts.map +1 -0
- package/dist/lib/maths/types/basic.js +5 -0
- package/dist/lib/maths/types/basic.mjs +0 -0
- package/dist/lib/maths/types/index.cjs +1 -0
- package/dist/lib/maths/types/index.d.ts +4 -0
- package/dist/lib/maths/types/index.d.ts.map +1 -0
- package/dist/lib/maths/types/index.js +3 -0
- package/dist/lib/maths/types/index.mjs +0 -0
- package/dist/lib/maths/types/negative.cjs +1 -0
- package/dist/lib/maths/types/negative.d.ts +51 -0
- package/dist/lib/maths/types/negative.d.ts.map +1 -0
- package/dist/lib/maths/types/negative.js +5 -0
- package/dist/lib/maths/types/negative.mjs +0 -0
- package/dist/lib/maths/types/operations.cjs +1 -0
- package/dist/lib/maths/types/operations.d.ts +188 -0
- package/dist/lib/maths/types/operations.d.ts.map +1 -0
- package/dist/lib/maths/types/operations.js +6 -0
- package/dist/lib/maths/types/operations.mjs +0 -0
- package/dist/lib/object/clone.cjs +1 -0
- package/dist/lib/object/clone.d.ts +46 -0
- package/dist/lib/object/clone.d.ts.map +1 -0
- package/dist/lib/object/clone.js +104 -0
- package/dist/lib/object/clone.mjs +1 -0
- package/dist/lib/object/diff.cjs +1 -0
- package/dist/lib/object/diff.d.ts +203 -0
- package/dist/lib/object/diff.d.ts.map +1 -0
- package/dist/lib/object/diff.js +805 -0
- package/dist/lib/object/diff.mjs +1 -0
- package/dist/lib/object/getter-setter.cjs +1 -0
- package/dist/lib/object/getter-setter.d.ts +361 -0
- package/dist/lib/object/getter-setter.d.ts.map +1 -0
- package/dist/lib/object/getter-setter.js +1771 -0
- package/dist/lib/object/getter-setter.mjs +1 -0
- package/dist/lib/object/index.cjs +6 -0
- package/dist/lib/object/index.d.ts +13 -0
- package/dist/lib/object/index.d.ts.map +1 -0
- package/dist/lib/object/index.js +12 -0
- package/dist/lib/object/index.mjs +6 -0
- package/dist/lib/object/merge.cjs +1 -0
- package/dist/lib/object/merge.d.ts +93 -0
- package/dist/lib/object/merge.d.ts.map +1 -0
- package/dist/lib/object/merge.js +474 -0
- package/dist/lib/object/merge.mjs +1 -0
- package/dist/lib/object/object.cjs +1 -0
- package/dist/lib/object/object.d.ts +128 -0
- package/dist/lib/object/object.d.ts.map +1 -0
- package/dist/lib/object/object.js +432 -0
- package/dist/lib/object/object.mjs +1 -0
- package/dist/lib/object/omit.cjs +1 -0
- package/dist/lib/object/omit.d.ts +351 -0
- package/dist/lib/object/omit.d.ts.map +1 -0
- package/dist/lib/object/omit.js +656 -0
- package/dist/lib/object/omit.mjs +1 -0
- package/dist/lib/object/reconcile.cjs +1 -0
- package/dist/lib/object/reconcile.d.ts +7 -0
- package/dist/lib/object/reconcile.d.ts.map +1 -0
- package/dist/lib/object/reconcile.js +122 -0
- package/dist/lib/object/reconcile.mjs +1 -0
- package/dist/lib/object/selector.cjs +1 -0
- package/dist/lib/object/selector.d.ts +50 -0
- package/dist/lib/object/selector.d.ts.map +1 -0
- package/dist/lib/object/selector.js +371 -0
- package/dist/lib/object/selector.mjs +1 -0
- package/dist/lib/object/sort.cjs +1 -0
- package/dist/lib/object/sort.d.ts +149 -0
- package/dist/lib/object/sort.d.ts.map +1 -0
- package/dist/lib/object/sort.js +298 -0
- package/dist/lib/object/sort.mjs +1 -0
- package/dist/lib/object/transform.cjs +1 -0
- package/dist/lib/object/transform.d.ts +620 -0
- package/dist/lib/object/transform.d.ts.map +1 -0
- package/dist/lib/object/transform.js +1058 -0
- package/dist/lib/object/transform.mjs +1 -0
- package/dist/lib/object/types.cjs +1 -0
- package/dist/lib/object/types.d.ts +250 -0
- package/dist/lib/object/types.d.ts.map +1 -0
- package/dist/lib/object/types.js +1 -0
- package/dist/lib/object/types.mjs +0 -0
- package/dist/lib/object/utils.cjs +6 -0
- package/dist/lib/object/utils.d.ts +165 -0
- package/dist/lib/object/utils.d.ts.map +1 -0
- package/dist/lib/object/utils.js +444 -0
- package/dist/lib/object/utils.mjs +6 -0
- package/dist/lib/primitive/boolean/boolean.cjs +1 -0
- package/dist/lib/primitive/boolean/boolean.d.ts +276 -0
- package/dist/lib/primitive/boolean/boolean.d.ts.map +1 -0
- package/dist/lib/primitive/boolean/boolean.js +615 -0
- package/dist/lib/primitive/boolean/boolean.mjs +1 -0
- package/dist/lib/primitive/boolean/index.cjs +1 -0
- package/dist/lib/primitive/boolean/index.d.ts +3 -0
- package/dist/lib/primitive/boolean/index.d.ts.map +1 -0
- package/dist/lib/primitive/boolean/index.js +2 -0
- package/dist/lib/primitive/boolean/index.mjs +1 -0
- package/dist/lib/primitive/boolean/types.cjs +1 -0
- package/dist/lib/primitive/boolean/types.d.ts +14 -0
- package/dist/lib/primitive/boolean/types.d.ts.map +1 -0
- package/dist/lib/primitive/boolean/types.js +1 -0
- package/dist/lib/primitive/boolean/types.mjs +0 -0
- package/dist/lib/primitive/date/date.cjs +1 -0
- package/dist/lib/primitive/date/date.d.ts +641 -0
- package/dist/lib/primitive/date/date.d.ts.map +1 -0
- package/dist/lib/primitive/date/date.js +1998 -0
- package/dist/lib/primitive/date/date.mjs +1 -0
- package/dist/lib/primitive/date/index.cjs +1 -0
- package/dist/lib/primitive/date/index.d.ts +3 -0
- package/dist/lib/primitive/date/index.d.ts.map +1 -0
- package/dist/lib/primitive/date/index.js +2 -0
- package/dist/lib/primitive/date/index.mjs +1 -0
- package/dist/lib/primitive/date/types.cjs +1 -0
- package/dist/lib/primitive/date/types.d.ts +205 -0
- package/dist/lib/primitive/date/types.d.ts.map +1 -0
- package/dist/lib/primitive/date/types.js +7 -0
- package/dist/lib/primitive/date/types.mjs +0 -0
- package/dist/lib/primitive/index.cjs +5 -0
- package/dist/lib/primitive/index.d.ts +5 -0
- package/dist/lib/primitive/index.d.ts.map +1 -0
- package/dist/lib/primitive/index.js +4 -0
- package/dist/lib/primitive/index.mjs +5 -0
- package/dist/lib/primitive/string/index.cjs +5 -0
- package/dist/lib/primitive/string/index.d.ts +3 -0
- package/dist/lib/primitive/string/index.d.ts.map +1 -0
- package/dist/lib/primitive/string/index.js +2 -0
- package/dist/lib/primitive/string/index.mjs +5 -0
- package/dist/lib/primitive/string/parser-2.cjs +8 -0
- package/dist/lib/primitive/string/parser-2.d.ts +17 -0
- package/dist/lib/primitive/string/parser-2.d.ts.map +1 -0
- package/dist/lib/primitive/string/parser-2.js +656 -0
- package/dist/lib/primitive/string/parser-2.mjs +8 -0
- package/dist/lib/primitive/string/parser.cjs +3 -0
- package/dist/lib/primitive/string/parser.d.ts +9 -0
- package/dist/lib/primitive/string/parser.d.ts.map +1 -0
- package/dist/lib/primitive/string/parser.js +775 -0
- package/dist/lib/primitive/string/parser.mjs +3 -0
- package/dist/lib/primitive/string/string.cjs +5 -0
- package/dist/lib/primitive/string/string.d.ts +535 -0
- package/dist/lib/primitive/string/string.d.ts.map +1 -0
- package/dist/lib/primitive/string/string.js +1301 -0
- package/dist/lib/primitive/string/string.mjs +5 -0
- package/dist/lib/primitive/string/types.cjs +1 -0
- package/dist/lib/primitive/string/types.d.ts +318 -0
- package/dist/lib/primitive/string/types.d.ts.map +1 -0
- package/dist/lib/primitive/string/types.js +5 -0
- package/dist/lib/primitive/string/types.mjs +0 -0
- package/dist/lib/primitive/types.cjs +1 -0
- package/dist/lib/primitive/types.d.ts +27 -0
- package/dist/lib/primitive/types.d.ts.map +1 -0
- package/dist/lib/primitive/types.js +1 -0
- package/dist/lib/primitive/types.mjs +0 -0
- package/dist/lib/url/index.cjs +1 -0
- package/dist/lib/url/index.d.ts +3 -0
- package/dist/lib/url/index.d.ts.map +1 -0
- package/dist/lib/url/index.js +2 -0
- package/dist/lib/url/index.mjs +1 -0
- package/dist/lib/url/parser.cjs +1 -0
- package/dist/lib/url/parser.d.ts +216 -0
- package/dist/lib/url/parser.d.ts.map +1 -0
- package/dist/lib/url/parser.js +488 -0
- package/dist/lib/url/parser.mjs +1 -0
- package/dist/lib/url/types.cjs +1 -0
- package/dist/lib/url/types.d.ts +18 -0
- package/dist/lib/url/types.d.ts.map +1 -0
- package/dist/lib/url/types.js +1 -0
- package/dist/lib/url/types.mjs +0 -0
- package/dist/tsconfig.lib.tsbuildinfo +1 -0
- package/package.json +150 -0
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Trigonometric functions and angle conversions.
|
|
3
|
+
* @module TrigonometryFunctions
|
|
4
|
+
*/
|
|
5
|
+
import { Constants } from '../constants.js';
|
|
6
|
+
/**
|
|
7
|
+
* Converts degrees to radians.
|
|
8
|
+
* @param degrees - Angle in degrees
|
|
9
|
+
* @returns Angle in radians
|
|
10
|
+
*/
|
|
11
|
+
export function degToRad(degrees) {
|
|
12
|
+
// return degrees * (Math.PI / 180);
|
|
13
|
+
return (degrees * Constants.RADIANS_PER_DEGREE);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Converts radians to degrees.
|
|
17
|
+
* @param radians - Angle in radians
|
|
18
|
+
* @returns Angle in degrees
|
|
19
|
+
*/
|
|
20
|
+
export function radToDeg(radians) {
|
|
21
|
+
// return radians * (180 / Math.PI);
|
|
22
|
+
return (radians * Constants.DEGREES_PER_RADIAN);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Converts degrees to gradians.
|
|
26
|
+
* @param degrees - Angle in degrees
|
|
27
|
+
* @returns Angle in gradians
|
|
28
|
+
*/
|
|
29
|
+
export function degToGrad(degrees) {
|
|
30
|
+
return degrees * (Constants.GRADIANS_IN_CIRCLE / Constants.DEGREES_IN_CIRCLE);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Converts gradians to degrees.
|
|
34
|
+
* @param gradians - Angle in gradians
|
|
35
|
+
* @returns Angle in degrees
|
|
36
|
+
*/
|
|
37
|
+
export function gradToDeg(gradians) {
|
|
38
|
+
return (gradians * (Constants.DEGREES_IN_CIRCLE / Constants.GRADIANS_IN_CIRCLE));
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Normalizes an angle to the range [0, 2π) radians.
|
|
42
|
+
* @param radians - Angle in radians
|
|
43
|
+
* @returns Normalized angle in radians
|
|
44
|
+
*/
|
|
45
|
+
export function normalizeRadians(radians) {
|
|
46
|
+
const twoPi = Constants.RADIANS_IN_CIRCLE;
|
|
47
|
+
let normalized = radians % twoPi;
|
|
48
|
+
if (normalized < 0)
|
|
49
|
+
normalized += twoPi;
|
|
50
|
+
return normalized;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Normalizes an angle to the range [0, 360) degrees.
|
|
54
|
+
* @param degrees - Angle in degrees
|
|
55
|
+
* @returns Normalized angle in degrees
|
|
56
|
+
*/
|
|
57
|
+
export function normalizeDegrees(degrees) {
|
|
58
|
+
let normalized = degrees % Constants.DEGREES_IN_CIRCLE;
|
|
59
|
+
if (normalized < 0)
|
|
60
|
+
normalized += Constants.DEGREES_IN_CIRCLE;
|
|
61
|
+
return normalized;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Calculates the sine of an angle in radians.
|
|
65
|
+
* @param radians - Angle in radians
|
|
66
|
+
* @returns The sine value
|
|
67
|
+
*/
|
|
68
|
+
export function sin(radians) {
|
|
69
|
+
return Math.sin(radians);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Calculates the cosine of an angle in radians.
|
|
73
|
+
* @param radians - Angle in radians
|
|
74
|
+
* @returns The cosine value
|
|
75
|
+
*/
|
|
76
|
+
export function cos(radians) {
|
|
77
|
+
return Math.cos(radians);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Calculates the tangent of an angle in radians.
|
|
81
|
+
* @param radians - Angle in radians
|
|
82
|
+
* @returns The tangent value
|
|
83
|
+
* @throws {Error} If cosine is zero (angle is π/2 + nπ)
|
|
84
|
+
*/
|
|
85
|
+
export function tan(radians) {
|
|
86
|
+
const cosine = Math.cos(radians);
|
|
87
|
+
if (Math.abs(cosine) < 1e-10) {
|
|
88
|
+
throw new Error('Tangent undefined for this angle (cosine is zero)');
|
|
89
|
+
}
|
|
90
|
+
return Math.tan(radians);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Calculates the arcsine (inverse sine) in radians.
|
|
94
|
+
* @param value - Sine value between -1 and 1
|
|
95
|
+
* @returns Angle in radians
|
|
96
|
+
* @throws {Error} If value is outside [-1, 1]
|
|
97
|
+
*/
|
|
98
|
+
export function asin(value) {
|
|
99
|
+
if (value < -1 || value > 1) {
|
|
100
|
+
throw new Error('Arcsine is only defined for values between -1 and 1');
|
|
101
|
+
}
|
|
102
|
+
return Math.asin(value);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Calculates the arccosine (inverse cosine) in radians.
|
|
106
|
+
* @param value - Cosine value between -1 and 1
|
|
107
|
+
* @returns Angle in radians
|
|
108
|
+
* @throws {Error} If value is outside [-1, 1]
|
|
109
|
+
*/
|
|
110
|
+
export function acos(value) {
|
|
111
|
+
if (value < -1 || value > 1) {
|
|
112
|
+
throw new Error('Arccosine is only defined for values between -1 and 1');
|
|
113
|
+
}
|
|
114
|
+
return Math.acos(value);
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Calculates the arctangent (inverse tangent) in radians.
|
|
118
|
+
* @param value - Tangent value
|
|
119
|
+
* @returns Angle in radians between -π/2 and π/2
|
|
120
|
+
*/
|
|
121
|
+
export function atan(value) {
|
|
122
|
+
return Math.atan(value);
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Calculates the arctangent of y/x in radians, handling all quadrants.
|
|
126
|
+
* @param y - Numerator
|
|
127
|
+
* @param x - Denominator
|
|
128
|
+
* @returns Angle in radians between -π and π
|
|
129
|
+
*/
|
|
130
|
+
export function atan2(y, x) {
|
|
131
|
+
return Math.atan2(y, x);
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Calculates the hyperbolic sine.
|
|
135
|
+
* @param x - Input value
|
|
136
|
+
* @returns Hyperbolic sine
|
|
137
|
+
*/
|
|
138
|
+
export function sinh(x) {
|
|
139
|
+
return Math.sinh(x);
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Calculates the hyperbolic cosine.
|
|
143
|
+
* @param x - Input value
|
|
144
|
+
* @returns Hyperbolic cosine
|
|
145
|
+
*/
|
|
146
|
+
export function cosh(x) {
|
|
147
|
+
return Math.cosh(x);
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Calculates the hyperbolic tangent.
|
|
151
|
+
* @param x - Input value
|
|
152
|
+
* @returns Hyperbolic tangent
|
|
153
|
+
*/
|
|
154
|
+
export function tanh(x) {
|
|
155
|
+
return Math.tanh(x);
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Calculates the inverse hyperbolic sine.
|
|
159
|
+
* @param x - Input value
|
|
160
|
+
* @returns Inverse hyperbolic sine
|
|
161
|
+
*/
|
|
162
|
+
export function asinh(x) {
|
|
163
|
+
return Math.asinh(x);
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Calculates the inverse hyperbolic cosine.
|
|
167
|
+
* @param x - Input value >= 1
|
|
168
|
+
* @returns Inverse hyperbolic cosine
|
|
169
|
+
* @throws {Error} If x < 1
|
|
170
|
+
*/
|
|
171
|
+
export function acosh(x) {
|
|
172
|
+
if (x < 1) {
|
|
173
|
+
throw new Error('Inverse hyperbolic cosine is only defined for x >= 1');
|
|
174
|
+
}
|
|
175
|
+
return Math.acosh(x);
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Calculates the inverse hyperbolic tangent.
|
|
179
|
+
* @param x - Input value between -1 and 1 (exclusive)
|
|
180
|
+
* @returns Inverse hyperbolic tangent
|
|
181
|
+
* @throws {Error} If |x| >= 1
|
|
182
|
+
*/
|
|
183
|
+
export function atanh(x) {
|
|
184
|
+
if (Math.abs(x) >= 1) {
|
|
185
|
+
throw new Error('Inverse hyperbolic tangent is only defined for |x| < 1');
|
|
186
|
+
}
|
|
187
|
+
return Math.atanh(x);
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Calculates the secant of an angle.
|
|
191
|
+
* @param radians - Angle in radians
|
|
192
|
+
* @returns The secant value
|
|
193
|
+
* @throws {Error} If cosine is zero
|
|
194
|
+
*/
|
|
195
|
+
export function sec(radians) {
|
|
196
|
+
const cosine = Math.cos(radians);
|
|
197
|
+
if (Math.abs(cosine) < 1e-10) {
|
|
198
|
+
throw new Error('Secant undefined for this angle (cosine is zero)');
|
|
199
|
+
}
|
|
200
|
+
return 1 / cosine;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Calculates the cosecant of an angle.
|
|
204
|
+
* @param radians - Angle in radians
|
|
205
|
+
* @returns The cosecant value
|
|
206
|
+
* @throws {Error} If sine is zero
|
|
207
|
+
*/
|
|
208
|
+
export function csc(radians) {
|
|
209
|
+
const sine = Math.sin(radians);
|
|
210
|
+
if (Math.abs(sine) < 1e-10) {
|
|
211
|
+
throw new Error('Cosecant undefined for this angle (sine is zero)');
|
|
212
|
+
}
|
|
213
|
+
return 1 / sine;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Calculates the cotangent of an angle.
|
|
217
|
+
* @param radians - Angle in radians
|
|
218
|
+
* @returns The cotangent value
|
|
219
|
+
* @throws {Error} If tangent is zero
|
|
220
|
+
*/
|
|
221
|
+
export function cot(radians) {
|
|
222
|
+
const tangent = Math.tan(radians);
|
|
223
|
+
if (Math.abs(tangent) < 1e-10) {
|
|
224
|
+
throw new Error('Cotangent undefined for this angle (tangent is zero)');
|
|
225
|
+
}
|
|
226
|
+
return 1 / tangent;
|
|
227
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var r=3.141592653589793,s=2.718281828459045,a=1.618033988749894,i=1.4142135623730951,u=.7071067811865476,c=.6931471805599453,E=2.302585092994046,f=1.4426950408889634,b=.4342944819032518,h=360,R=2*r,m=400,p=180/r,d=r/180,t={PI:r,E:s,PHI:a,SQRT2:i,SQRT1_2:u,LN2:c,LN10:E,LOG2E:f,LOG10E:b,DEGREES_IN_CIRCLE:h,RADIANS_IN_CIRCLE:R,GRADIANS_IN_CIRCLE:m,DEGREES_PER_RADIAN:p,RADIANS_PER_DEGREE:d};function _(n){return n*t.RADIANS_PER_DEGREE}function D(n){return n*t.DEGREES_PER_RADIAN}function C(n){return n*(t.GRADIANS_IN_CIRCLE/t.DEGREES_IN_CIRCLE)}function M(n){return n*(t.DEGREES_IN_CIRCLE/t.GRADIANS_IN_CIRCLE)}function g(n){let e=t.RADIANS_IN_CIRCLE,o=n%e;return o<0&&(o+=e),o}function N(n){let e=n%t.DEGREES_IN_CIRCLE;return e<0&&(e+=t.DEGREES_IN_CIRCLE),e}function A(n){return Math.sin(n)}function w(n){return Math.cos(n)}function S(n){let e=Math.cos(n);if(Math.abs(e)<1e-10)throw new Error("Tangent undefined for this angle (cosine is zero)");return Math.tan(n)}function G(n){if(n<-1||n>1)throw new Error("Arcsine is only defined for values between -1 and 1");return Math.asin(n)}function l(n){if(n<-1||n>1)throw new Error("Arccosine is only defined for values between -1 and 1");return Math.acos(n)}function L(n){return Math.atan(n)}function y(n,e){return Math.atan2(n,e)}function z(n){return Math.sinh(n)}function P(n){return Math.cosh(n)}function T(n){return Math.tanh(n)}function O(n){return Math.asinh(n)}function Q(n){if(n<1)throw new Error("Inverse hyperbolic cosine is only defined for x >= 1");return Math.acosh(n)}function j(n){if(Math.abs(n)>=1)throw new Error("Inverse hyperbolic tangent is only defined for |x| < 1");return Math.atanh(n)}function H(n){let e=Math.cos(n);if(Math.abs(e)<1e-10)throw new Error("Secant undefined for this angle (cosine is zero)");return 1/e}function k(n){let e=Math.sin(n);if(Math.abs(e)<1e-10)throw new Error("Cosecant undefined for this angle (sine is zero)");return 1/e}function q(n){let e=Math.tan(n);if(Math.abs(e)<1e-10)throw new Error("Cotangent undefined for this angle (tangent is zero)");return 1/e}export{l as acos,Q as acosh,G as asin,O as asinh,L as atan,y as atan2,j as atanh,w as cos,P as cosh,q as cot,k as csc,C as degToGrad,_ as degToRad,M as gradToDeg,N as normalizeDegrees,g as normalizeRadians,D as radToDeg,H as sec,A as sin,z as sinh,S as tan,T as tanh};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var l=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var B=Object.prototype.hasOwnProperty;var N=(r,t)=>{for(var e in t)l(r,e,{get:t[e],enumerable:!0})},P=(r,t,e,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of j(t))!B.call(r,n)&&n!==e&&l(r,n,{get:()=>t[n],enumerable:!(o=C(t,n))||o.enumerable});return r};var A=r=>P(l({},"__esModule",{value:!0}),r);var kr={};N(kr,{addVectors2D:()=>Q,addVectors3D:()=>b,addVectors4D:()=>U,angleBetween2D:()=>q,angleBetween3D:()=>er,centroid2D:()=>$r,createVector2D:()=>R,createVector3D:()=>X,createVector4D:()=>Y,crossProduct3D:()=>O,cubicBezier2D:()=>ar,distance2D:()=>nr,distance3D:()=>ur,distance4D:()=>Dr,distanceSquared2D:()=>cr,distanceSquared3D:()=>xr,distanceSquared4D:()=>ir,dotProduct2D:()=>w,dotProduct3D:()=>M,dotProduct4D:()=>K,lerp2D:()=>yr,lerp3D:()=>T,lerp4D:()=>sr,lerpClamped2D:()=>Vr,lerpClamped3D:()=>mr,lerpClamped4D:()=>pr,magnitude2D:()=>z,magnitude3D:()=>p,magnitude4D:()=>S,magnitudeSquared2D:()=>E,magnitudeSquared3D:()=>Z,magnitudeSquared4D:()=>I,mapRange:()=>lr,mapRangeClamped:()=>gr,midpoint2D:()=>Tr,negateVector2D:()=>Cr,negateVector3D:()=>jr,negateVector4D:()=>Br,normalize2D:()=>L,normalize3D:()=>F,normalize4D:()=>H,perpendicular2D:()=>Nr,project2D:()=>Er,quadraticBezier2D:()=>hr,reflect2D:()=>Mr,rotate2D:()=>$,rotate2DDegrees:()=>Sr,safeNormalize2D:()=>k,safeNormalize3D:()=>G,safeNormalize4D:()=>J,scaleVector2D:()=>rr,scaleVector3D:()=>g,scaleVector4D:()=>tr,signedAngleBetween2D:()=>or,slerp3D:()=>zr,smootherstep2D:()=>wr,smoothstep2D:()=>fr,smoothstepClamped2D:()=>dr,subtractVectors2D:()=>W,subtractVectors3D:()=>_,subtractVectors4D:()=>v,unitX2D:()=>Xr,unitX3D:()=>Zr,unitY2D:()=>Yr,unitY3D:()=>Ir,unitZ3D:()=>Lr,vectorsEqual2D:()=>Fr,vectorsEqual3D:()=>br,vectorsEqual4D:()=>qr,zeroVector2D:()=>Pr,zeroVector3D:()=>Ar,zeroVector4D:()=>Rr});module.exports=A(kr);function u(r,t){if(typeof r!="number"||!Number.isFinite(r))throw new Error(`${t} must be a finite number, got ${r}`)}function y(r){return Math.abs(r)<1e-9}function m(r,t){return Math.abs(r-t)<1e-6}function c(r,t="Vector2D"){if(!r||typeof r!="object")throw new Error(`${t} must be an object`);u(r.x,`${t}.x`),u(r.y,`${t}.y`)}function x(r,t="Vector3D"){if(!r||typeof r!="object")throw new Error(`${t} must be an object`);u(r.x,`${t}.x`),u(r.y,`${t}.y`),u(r.z,`${t}.z`)}function i(r,t="Vector4D"){if(!r||typeof r!="object")throw new Error(`${t} must be an object`);u(r.x,`${t}.x`),u(r.y,`${t}.y`),u(r.z,`${t}.z`),u(r.w,`${t}.w`)}function R(r,t){return u(r,"x"),u(t,"y"),{x:r,y:t}}function X(r,t,e){return u(r,"x"),u(t,"y"),u(e,"z"),{x:r,y:t,z:e}}function Y(r,t,e,o){return u(r,"x"),u(t,"y"),u(e,"z"),u(o,"w"),{x:r,y:t,z:e,w:o}}function z(r){c(r);let t=Math.sqrt(r.x*r.x+r.y*r.y);return y(t)?0:t}function E(r){return c(r),r.x*r.x+r.y*r.y}function p(r){x(r);let t=Math.sqrt(r.x*r.x+r.y*r.y+r.z*r.z);return y(t)?0:t}function Z(r){return x(r),r.x*r.x+r.y*r.y+r.z*r.z}function S(r){i(r);let t=Math.sqrt(r.x*r.x+r.y*r.y+r.z*r.z+r.w*r.w);return y(t)?0:t}function I(r){return i(r),r.x*r.x+r.y*r.y+r.z*r.z+r.w*r.w}function L(r){c(r);let t=z(r);if(y(t))throw new Error("Cannot normalize zero or near-zero vector");return{x:r.x/t,y:r.y/t}}function k(r){c(r);let t=z(r);return y(t)?{x:0,y:0}:{x:r.x/t,y:r.y/t}}function F(r){x(r);let t=p(r);if(y(t))throw new Error("Cannot normalize zero or near-zero vector");return{x:r.x/t,y:r.y/t,z:r.z/t}}function G(r){x(r);let t=p(r);return y(t)?{x:0,y:0,z:0}:{x:r.x/t,y:r.y/t,z:r.z/t}}function H(r){i(r);let t=S(r);if(y(t))throw new Error("Cannot normalize zero or near-zero vector");return{x:r.x/t,y:r.y/t,z:r.z/t,w:r.w/t}}function J(r){i(r);let t=S(r);return y(t)?{x:0,y:0,z:0,w:0}:{x:r.x/t,y:r.y/t,z:r.z/t,w:r.w/t}}function w(r,t){return c(r,"First vector"),c(t,"Second vector"),r.x*t.x+r.y*t.y}function M(r,t){return x(r,"First vector"),x(t,"Second vector"),r.x*t.x+r.y*t.y+r.z*t.z}function K(r,t){return i(r,"First vector"),i(t,"Second vector"),r.x*t.x+r.y*t.y+r.z*t.z+r.w*t.w}function O(r,t){return x(r,"First vector"),x(t,"Second vector"),{x:r.y*t.z-r.z*t.y,y:r.z*t.x-r.x*t.z,z:r.x*t.y-r.y*t.x}}function Q(r,t){return c(r,"First vector"),c(t,"Second vector"),{x:r.x+t.x,y:r.y+t.y}}function b(r,t){return x(r,"First vector"),x(t,"Second vector"),{x:r.x+t.x,y:r.y+t.y,z:r.z+t.z}}function U(r,t){return i(r,"First vector"),i(t,"Second vector"),{x:r.x+t.x,y:r.y+t.y,z:r.z+t.z,w:r.w+t.w}}function W(r,t){return c(r,"First vector"),c(t,"Second vector"),{x:r.x-t.x,y:r.y-t.y}}function _(r,t){return x(r,"First vector"),x(t,"Second vector"),{x:r.x-t.x,y:r.y-t.y,z:r.z-t.z}}function v(r,t){return i(r,"First vector"),i(t,"Second vector"),{x:r.x-t.x,y:r.y-t.y,z:r.z-t.z,w:r.w-t.w}}function rr(r,t){return c(r),u(t,"scalar"),{x:r.x*t,y:r.y*t}}function g(r,t){return x(r),u(t,"scalar"),{x:r.x*t,y:r.y*t,z:r.z*t}}function tr(r,t){return i(r),u(t,"scalar"),{x:r.x*t,y:r.y*t,z:r.z*t,w:r.w*t}}function q(r,t){c(r,"First vector"),c(t,"Second vector");let e=w(r,t),o=z(r),n=z(t);if(y(o)||y(n))throw new Error("Cannot calculate angle with zero or near-zero vector");let D=Math.max(-1,Math.min(1,e/(o*n)));return Math.acos(D)}function er(r,t){x(r,"First vector"),x(t,"Second vector");let e=M(r,t),o=p(r),n=p(t);if(y(o)||y(n))throw new Error("Cannot calculate angle with zero or near-zero vector");let D=Math.max(-1,Math.min(1,e/(o*n)));return Math.acos(D)}function or(r,t){c(r,"First vector"),c(t,"Second vector");let e=q(r,t);return r.x*t.y-r.y*t.x>=0?e:-e}function nr(r,t){c(r,"First point"),c(t,"Second point");let e=t.x-r.x,o=t.y-r.y,n=Math.sqrt(e*e+o*o);return y(n)?0:n}function cr(r,t){c(r,"First point"),c(t,"Second point");let e=t.x-r.x,o=t.y-r.y;return e*e+o*o}function ur(r,t){x(r,"First point"),x(t,"Second point");let e=t.x-r.x,o=t.y-r.y,n=t.z-r.z,D=Math.sqrt(e*e+o*o+n*n);return y(D)?0:D}function xr(r,t){x(r,"First point"),x(t,"Second point");let e=t.x-r.x,o=t.y-r.y,n=t.z-r.z;return e*e+o*o+n*n}function Dr(r,t){i(r,"First point"),i(t,"Second point");let e=t.x-r.x,o=t.y-r.y,n=t.z-r.z,D=t.w-r.w,V=Math.sqrt(e*e+o*o+n*n+D*D);return y(V)?0:V}function ir(r,t){i(r,"First point"),i(t,"Second point");let e=t.x-r.x,o=t.y-r.y,n=t.z-r.z,D=t.w-r.w;return e*e+o*o+n*n+D*D}function yr(r,t,e){return c(r,"Start vector"),c(t,"End vector"),u(e,"t"),{x:r.x+(t.x-r.x)*e,y:r.y+(t.y-r.y)*e}}function Vr(r,t,e){c(r,"Start vector"),c(t,"End vector"),u(e,"t");let o=Math.max(0,Math.min(1,e));return{x:r.x+(t.x-r.x)*o,y:r.y+(t.y-r.y)*o}}function T(r,t,e){return x(r,"Start vector"),x(t,"End vector"),u(e,"t"),{x:r.x+(t.x-r.x)*e,y:r.y+(t.y-r.y)*e,z:r.z+(t.z-r.z)*e}}function mr(r,t,e){x(r,"Start vector"),x(t,"End vector"),u(e,"t");let o=Math.max(0,Math.min(1,e));return{x:r.x+(t.x-r.x)*o,y:r.y+(t.y-r.y)*o,z:r.z+(t.z-r.z)*o}}function sr(r,t,e){return i(r,"Start vector"),i(t,"End vector"),u(e,"t"),{x:r.x+(t.x-r.x)*e,y:r.y+(t.y-r.y)*e,z:r.z+(t.z-r.z)*e,w:r.w+(t.w-r.w)*e}}function pr(r,t,e){i(r,"Start vector"),i(t,"End vector"),u(e,"t");let o=Math.max(0,Math.min(1,e));return{x:r.x+(t.x-r.x)*o,y:r.y+(t.y-r.y)*o,z:r.z+(t.z-r.z)*o,w:r.w+(t.w-r.w)*o}}function zr(r,t,e){x(r,"Start vector"),x(t,"End vector"),u(e,"t");let o=p(r),n=p(t);if(Math.abs(o-1)>1e-8||Math.abs(n-1)>1e-8)throw new Error("SLERP requires unit vectors");let D=Math.max(0,Math.min(1,e)),V=M(r,t),f=Math.max(-1,Math.min(1,V));if(f>.9995)return F(T(r,t,D));let s=Math.acos(f),d=Math.sin(s),h=Math.sin((1-D)*s)/d,a=Math.sin(D*s)/d;return b(g(r,h),g(t,a))}function fr(r,t,e){c(r,"Start vector"),c(t,"End vector"),u(e,"t");let o=e*e*(3-2*e);return{x:r.x+(t.x-r.x)*o,y:r.y+(t.y-r.y)*o}}function dr(r,t,e){c(r,"Start vector"),c(t,"End vector"),u(e,"t");let o=Math.max(0,Math.min(1,e)),n=o*o*(3-2*o);return{x:r.x+(t.x-r.x)*n,y:r.y+(t.y-r.y)*n}}function wr(r,t,e){c(r,"Start vector"),c(t,"End vector"),u(e,"t");let o=e*e*e*(e*(e*6-15)+10);return{x:r.x+(t.x-r.x)*o,y:r.y+(t.y-r.y)*o}}function hr(r,t,e,o){c(r,"Start point"),c(t,"Control point"),c(e,"End point"),u(o,"t");let n=1-o,D=n*n*r.x+2*n*o*t.x+o*o*e.x,V=n*n*r.y+2*n*o*t.y+o*o*e.y;return{x:D,y:V}}function ar(r,t,e,o,n){c(r,"Start point"),c(t,"First control point"),c(e,"Second control point"),c(o,"End point"),u(n,"t");let D=1-n,V=D*D,f=V*D,s=n*n,d=s*n,h=f*r.x+3*V*n*t.x+3*D*s*e.x+d*o.x,a=f*r.y+3*V*n*t.y+3*D*s*e.y+d*o.y;return{x:h,y:a}}function lr(r,t,e,o,n){return u(r,"value"),u(t,"inMin"),u(e,"inMax"),u(o,"outMin"),u(n,"outMax"),m(t,e)?o:o+(n-o)*(r-t)/(e-t)}function gr(r,t,e,o,n){if(u(r,"value"),u(t,"inMin"),u(e,"inMax"),u(o,"outMin"),u(n,"outMax"),m(t,e))return o;let D=(r-t)/(e-t),V=Math.max(0,Math.min(1,D));return o+(n-o)*V}function $(r,t){c(r),u(t,"angle");let e=Math.cos(t),o=Math.sin(t);return{x:r.x*e-r.y*o,y:r.x*o+r.y*e}}function Sr(r,t){return $(r,t*(Math.PI/180))}function Mr(r,t){c(r,"Vector"),c(t,"Normal");let e=z(t);if(Math.abs(e-1)>1e-10)throw new Error("Normal vector must be unit length for reflection");let o=w(r,t);return{x:r.x-2*o*t.x,y:r.y-2*o*t.y}}function Er(r,t){c(r,"First vector"),c(t,"Second vector");let e=E(t);if(y(e))throw new Error("Cannot project onto zero or near-zero vector");let o=w(r,t)/e;return{x:t.x*o,y:t.y*o}}function Fr(r,t){return c(r,"First vector"),c(t,"Second vector"),m(r.x,t.x)&&m(r.y,t.y)}function br(r,t){return x(r,"First vector"),x(t,"Second vector"),m(r.x,t.x)&&m(r.y,t.y)&&m(r.z,t.z)}function qr(r,t){return i(r,"First vector"),i(t,"Second vector"),m(r.x,t.x)&&m(r.y,t.y)&&m(r.z,t.z)&&m(r.w,t.w)}function Tr(r,t){return c(r,"First point"),c(t,"Second point"),{x:(r.x+t.x)/2,y:(r.y+t.y)/2}}function $r(r){if(!Array.isArray(r)||r.length===0)throw new Error("Points array must not be empty");let t=0,e=0;for(let o=0;o<r.length;o++)c(r[o],`points[${o}]`),t+=r[o].x,e+=r[o].y;return{x:t/r.length,y:e/r.length}}function Cr(r){return c(r),{x:-r.x,y:-r.y}}function jr(r){return x(r),{x:-r.x,y:-r.y,z:-r.z}}function Br(r){return i(r),{x:-r.x,y:-r.y,z:-r.z,w:-r.w}}function Nr(r,t=!0){return c(r),t?{x:r.y,y:-r.x}:{x:-r.y,y:r.x}}function Pr(){return{x:0,y:0}}function Ar(){return{x:0,y:0,z:0}}function Rr(){return{x:0,y:0,z:0,w:0}}function Xr(){return{x:1,y:0}}function Yr(){return{x:0,y:1}}function Zr(){return{x:1,y:0,z:0}}function Ir(){return{x:0,y:1,z:0}}function Lr(){return{x:0,y:0,z:1}}
|