@pawells/math-extended 1.1.1 → 3.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 (113) hide show
  1. package/README.md +15 -21
  2. package/build/angles.d.ts +28 -18
  3. package/build/angles.d.ts.map +1 -1
  4. package/build/angles.js +28 -18
  5. package/build/angles.js.map +1 -1
  6. package/build/clamp.d.ts +2 -0
  7. package/build/clamp.d.ts.map +1 -1
  8. package/build/clamp.js +2 -0
  9. package/build/clamp.js.map +1 -1
  10. package/build/core.d.ts +23 -0
  11. package/build/core.d.ts.map +1 -0
  12. package/build/core.js +25 -0
  13. package/build/core.js.map +1 -0
  14. package/build/index.d.ts +1 -4
  15. package/build/index.d.ts.map +1 -1
  16. package/build/index.js +1 -6
  17. package/build/index.js.map +1 -1
  18. package/build/interpolation.d.ts +62 -13
  19. package/build/interpolation.d.ts.map +1 -1
  20. package/build/interpolation.js +66 -23
  21. package/build/interpolation.js.map +1 -1
  22. package/build/matrices/arithmetic.d.ts +65 -76
  23. package/build/matrices/arithmetic.d.ts.map +1 -1
  24. package/build/matrices/arithmetic.js +65 -107
  25. package/build/matrices/arithmetic.js.map +1 -1
  26. package/build/matrices/asserts.d.ts +26 -273
  27. package/build/matrices/asserts.d.ts.map +1 -1
  28. package/build/matrices/asserts.js +106 -350
  29. package/build/matrices/asserts.js.map +1 -1
  30. package/build/matrices/core.d.ts +150 -79
  31. package/build/matrices/core.d.ts.map +1 -1
  32. package/build/matrices/core.js +128 -104
  33. package/build/matrices/core.js.map +1 -1
  34. package/build/matrices/decompositions.d.ts +41 -44
  35. package/build/matrices/decompositions.d.ts.map +1 -1
  36. package/build/matrices/decompositions.js +51 -94
  37. package/build/matrices/decompositions.js.map +1 -1
  38. package/build/matrices/index.d.ts +2 -2
  39. package/build/matrices/index.d.ts.map +1 -1
  40. package/build/matrices/index.js +2 -2
  41. package/build/matrices/index.js.map +1 -1
  42. package/build/matrices/linear-algebra.d.ts +56 -19
  43. package/build/matrices/linear-algebra.d.ts.map +1 -1
  44. package/build/matrices/linear-algebra.js +80 -36
  45. package/build/matrices/linear-algebra.js.map +1 -1
  46. package/build/matrices/normalization.d.ts +36 -15
  47. package/build/matrices/normalization.d.ts.map +1 -1
  48. package/build/matrices/normalization.js +32 -23
  49. package/build/matrices/normalization.js.map +1 -1
  50. package/build/matrices/transformations.d.ts +39 -52
  51. package/build/matrices/transformations.d.ts.map +1 -1
  52. package/build/matrices/transformations.js +8 -11
  53. package/build/matrices/transformations.js.map +1 -1
  54. package/build/matrices/types.d.ts +39 -67
  55. package/build/matrices/types.d.ts.map +1 -1
  56. package/build/matrices/types.js +63 -1
  57. package/build/matrices/types.js.map +1 -1
  58. package/build/quaternions/asserts.d.ts +114 -15
  59. package/build/quaternions/asserts.d.ts.map +1 -1
  60. package/build/quaternions/asserts.js +189 -51
  61. package/build/quaternions/asserts.js.map +1 -1
  62. package/build/quaternions/conversions.d.ts +18 -8
  63. package/build/quaternions/conversions.d.ts.map +1 -1
  64. package/build/quaternions/conversions.js +14 -4
  65. package/build/quaternions/conversions.js.map +1 -1
  66. package/build/quaternions/core.d.ts +31 -2
  67. package/build/quaternions/core.d.ts.map +1 -1
  68. package/build/quaternions/core.js +32 -4
  69. package/build/quaternions/core.js.map +1 -1
  70. package/build/quaternions/index.d.ts +2 -2
  71. package/build/quaternions/index.d.ts.map +1 -1
  72. package/build/quaternions/index.js +3 -2
  73. package/build/quaternions/index.js.map +1 -1
  74. package/build/quaternions/interpolation.d.ts +7 -1
  75. package/build/quaternions/interpolation.d.ts.map +1 -1
  76. package/build/quaternions/interpolation.js +12 -6
  77. package/build/quaternions/interpolation.js.map +1 -1
  78. package/build/quaternions/predefined.d.ts +7 -1
  79. package/build/quaternions/predefined.d.ts.map +1 -1
  80. package/build/quaternions/predefined.js +6 -0
  81. package/build/quaternions/predefined.js.map +1 -1
  82. package/build/quaternions/types.d.ts +24 -13
  83. package/build/quaternions/types.d.ts.map +1 -1
  84. package/build/quaternions/types.js +51 -1
  85. package/build/quaternions/types.js.map +1 -1
  86. package/build/random.d.ts +66 -20
  87. package/build/random.d.ts.map +1 -1
  88. package/build/random.js +73 -20
  89. package/build/random.js.map +1 -1
  90. package/build/vectors/asserts.d.ts +33 -99
  91. package/build/vectors/asserts.d.ts.map +1 -1
  92. package/build/vectors/asserts.js +145 -181
  93. package/build/vectors/asserts.js.map +1 -1
  94. package/build/vectors/core.d.ts +76 -44
  95. package/build/vectors/core.d.ts.map +1 -1
  96. package/build/vectors/core.js +128 -119
  97. package/build/vectors/core.js.map +1 -1
  98. package/build/vectors/index.d.ts.map +1 -1
  99. package/build/vectors/index.js +1 -0
  100. package/build/vectors/index.js.map +1 -1
  101. package/build/vectors/interpolation.d.ts +13 -1
  102. package/build/vectors/interpolation.d.ts.map +1 -1
  103. package/build/vectors/interpolation.js +48 -47
  104. package/build/vectors/interpolation.js.map +1 -1
  105. package/build/vectors/predefined.d.ts +73 -25
  106. package/build/vectors/predefined.d.ts.map +1 -1
  107. package/build/vectors/predefined.js +62 -18
  108. package/build/vectors/predefined.js.map +1 -1
  109. package/build/vectors/types.d.ts +26 -4
  110. package/build/vectors/types.d.ts.map +1 -1
  111. package/build/vectors/types.js +50 -1
  112. package/build/vectors/types.js.map +1 -1
  113. package/package.json +4 -3
@@ -3,66 +3,22 @@
3
3
  * Provides comprehensive validation functions to ensure vector data integrity
4
4
  * and catch errors early in mathematical operations.
5
5
  */
6
- import { IAssertException, IAssertNumberArgs, IAssertArrayArgs } from '@pawells/typescript-common';
7
- import { TVector, TVector2, TVector3, TVector4 } from './types.js';
6
+ import { type TVector, type TVector2, type TVector3, type TVector4 } from './types.js';
7
+ import z from 'zod';
8
8
  /**
9
- * Configuration options for vector assertion functions.
10
- * Allows flexible validation of vector properties and constraints.
11
- */
12
- export type TAssertVectorArgs = IAssertNumberArgs & IAssertArrayArgs;
13
- /**
14
- * Extended configuration for validating multiple vectors.
15
- * Includes all single vector options plus multi-vector constraints.
16
- */
17
- interface IAssertVectorsArgs extends TAssertVectorArgs {
18
- /**
19
- * Minimum vector size allowed.
20
- * If specified, vectors must have at least this many components.
21
- */
22
- minSize?: number;
23
- /**
24
- * Whether all vectors must have the same size.
25
- * Default: true when using individual arguments, configurable when using array syntax.
26
- */
27
- sameSize?: boolean;
28
- /**
29
- * Whether all vector elements must be finite numbers.
30
- * If true, validates that each element is not Infinity or -Infinity.
31
- */
32
- finite?: boolean;
33
- }
34
- /**
35
- * Extended exception interface for vector-specific error information.
36
- * Provides additional context about which vector component caused the error.
37
- */
38
- interface IAssertVectorException extends IAssertException {
39
- /**
40
- * Index of the vector component that caused the validation failure.
41
- * Useful for debugging which specific element is invalid.
42
- */
43
- index?: number;
44
- }
45
- type TAssertVectorValueArgs = IAssertNumberArgs;
46
- /**
47
- * Specialized error class for vector-related operations and validations.
48
- * Thrown when vector assertions fail or vector operations encounter invalid data.
9
+ * Vector error class for validation failures and vector operations.
10
+ * Extends Error to provide detailed error information with optional cause chain.
49
11
  *
50
12
  * @example
51
- * try {
52
- * AssertVector("not a vector");
53
- * } catch (error) {
54
- * if (error instanceof VectorError) {
55
- * console.log("Vector validation failed:", error.message);
56
- * }
57
- * }
13
+ * ```typescript
14
+ * throw new VectorError('Invalid vector dimensions', { cause: originalError });
15
+ * ```
58
16
  */
59
17
  export declare class VectorError extends Error {
60
- /**
61
- * Creates a new VectorError instance.
62
- *
63
- * @param message - Optional error message describing the validation failure
64
- */
65
- constructor(message?: string);
18
+ readonly code: string;
19
+ constructor(message: string, options?: {
20
+ cause?: unknown;
21
+ });
66
22
  }
67
23
  /**
68
24
  * Validates that an unknown value is a valid vector (array of numbers).
@@ -79,15 +35,14 @@ export declare class VectorError extends Error {
79
35
  * ```typescript
80
36
  * // Basic validation — passes silently for a valid vector
81
37
  * AssertVector([1, 2, 3]);
82
- *
83
38
  * // Validate with size constraint
84
39
  * AssertVector([1, 2], { size: 2 });
85
- *
86
40
  * // Throws VectorError for non-array input
87
41
  * AssertVector("not a vector"); // throws VectorError
88
42
  * ```
89
43
  */
90
- export declare function AssertVector(vector: unknown, args?: TAssertVectorArgs, exception?: IAssertVectorException): asserts vector is TVector;
44
+ export declare function AssertVector(vector: unknown): asserts vector is TVector;
45
+ export declare function ValidateVector(vector: unknown): boolean;
91
46
  /**
92
47
  * Validates that an unknown value is a valid 2D vector (exactly 2 numeric components).
93
48
  *
@@ -102,7 +57,8 @@ export declare function AssertVector(vector: unknown, args?: TAssertVectorArgs,
102
57
  * AssertVector2("not a vec"); // throws
103
58
  * ```
104
59
  */
105
- export declare function AssertVector2(vector: unknown, exception?: IAssertVectorException): asserts vector is TVector2;
60
+ export declare function AssertVector2(vector: unknown): asserts vector is TVector2;
61
+ export declare function ValidateVector2(vector: unknown): boolean;
106
62
  /**
107
63
  * Validates that an unknown value is a valid 3D vector (exactly 3 numeric components).
108
64
  *
@@ -117,7 +73,8 @@ export declare function AssertVector2(vector: unknown, exception?: IAssertVector
117
73
  * AssertVector3(null); // throws
118
74
  * ```
119
75
  */
120
- export declare function AssertVector3(vector: unknown, exception?: IAssertVectorException): asserts vector is TVector3;
76
+ export declare function AssertVector3(vector: unknown): asserts vector is TVector3;
77
+ export declare function ValidateVector3(vector: unknown): boolean;
121
78
  /**
122
79
  * Validates that an unknown value is a valid 4D vector (exactly 4 numeric components).
123
80
  *
@@ -132,51 +89,28 @@ export declare function AssertVector3(vector: unknown, exception?: IAssertVector
132
89
  * AssertVector4(undefined); // throws
133
90
  * ```
134
91
  */
135
- export declare function AssertVector4(vector: unknown, exception?: IAssertVectorException): asserts vector is TVector4;
92
+ export declare function AssertVector4(vector: unknown): asserts vector is TVector4;
93
+ export declare function ValidateVector4(vector: unknown): boolean;
94
+ export declare const VECTOR_SAME_SIZE_SCHEMA: z.ZodArray<z.ZodArray<z.ZodNumber>>;
95
+ export type TVectorSameSize = z.infer<typeof VECTOR_SAME_SIZE_SCHEMA>;
96
+ export declare function AssertVectorSameSize(vectors: unknown[]): asserts vectors is TVectorSameSize;
97
+ export declare function ValidateVectorSameSize(vectors: unknown[]): boolean;
136
98
  /**
137
- * Validates that an unknown value is a valid vector element (a finite, non-NaN number).
138
- *
139
- * Supports optional numeric constraints such as range bounds, integer enforcement,
140
- * and finiteness checks. Throws `VectorError` with the component index when available.
99
+ * Validates that the given vector is not a zero vector (all components are not zero).
100
+ * Throws a VectorError if the vector is zero.
141
101
  *
142
- * @param value - The value to validate as a vector element
143
- * @param args - Numeric constraints (finite, integer, gt, gte, lt, lte, eq)
144
- * @param exception - Custom exception details, optionally including a component `index`
145
- * @throws {VectorError} If the value is not a valid number or violates any constraint
102
+ * @param vector - The vector to validate
103
+ * @param label - The label for the vector used in the error message (default: 'Vector')
104
+ * @throws {VectorError} If the vector is a zero vector
146
105
  *
147
106
  * @example
148
107
  * ```typescript
149
- * AssertVectorValue(3.14); // passes
150
- * AssertVectorValue(3.14, { finite: true }); // passes
151
- * AssertVectorValue(Infinity, { finite: true }); // throws
152
- * AssertVectorValue(NaN); // throws
153
- * AssertVectorValue(5, { gte: 0, lte: 10 }); // passes
154
- * ```
155
- */
156
- export declare function AssertVectorValue(value: unknown, args?: TAssertVectorValueArgs, exception?: IAssertVectorException): asserts value is number;
157
- /**
158
- * Validates an array of vectors, ensuring each vector is valid and optionally
159
- * enforcing that all vectors share the same size.
160
- *
161
- * @param vectors - The array of vectors to validate (must be non-empty)
162
- * @param args - Validation constraints applied to each vector; set `sameSize: true`
163
- * to require all vectors to have identical lengths
164
- * @param exception - Custom exception details if validation fails
165
- * @throws {VectorError} If the array is empty, any vector is invalid, or sizes
166
- * differ when `sameSize` is `true`
167
- *
168
- * @example
169
- * ```typescript
170
- * // Validate an array of 3D vectors
171
- * AssertVectors([[1, 2, 3], [4, 5, 6]]);
172
- *
173
- * // Require all vectors to share the same length
174
- * AssertVectors([[1, 2], [3, 4]], { sameSize: true });
108
+ * const v = [1, 2, 3];
109
+ * AssertVectorNonZero(v); // Valid
175
110
  *
176
- * // Throws because vectors have different sizes
177
- * AssertVectors([[1, 2], [1, 2, 3]], { sameSize: true }); // throws
111
+ * const zero = [0, 0, 0];
112
+ * AssertVectorNonZero(zero, 'Direction'); // Throws VectorError: Direction must not be zero
178
113
  * ```
179
114
  */
180
- export declare function AssertVectors(vectors: unknown[], args?: IAssertVectorsArgs, exception?: IAssertVectorException): void;
181
- export {};
115
+ export declare function AssertVectorNonZero(vector: TVector, label?: string): void;
182
116
  //# sourceMappingURL=asserts.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"asserts.d.ts","sourceRoot":"","sources":["../../src/vectors/asserts.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,gBAAgB,EAAuC,MAAM,4BAA4B,CAAC;AACxI,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEnE;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG,iBAAiB,GAAG,gBAAgB,CAAC;AAErE;;;GAGG;AACH,UAAU,kBAAmB,SAAQ,iBAAiB;IACrD;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CACjB;AACD;;;GAGG;AACH,UAAU,sBAAuB,SAAQ,gBAAgB;IACxD;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CACf;AACD,KAAK,sBAAsB,GAAG,iBAAiB,CAAC;AAEhD;;;;;;;;;;;;GAYG;AACH,qBAAa,WAAY,SAAQ,KAAK;IACrC;;;;OAIG;gBACS,OAAO,CAAC,EAAE,MAAM;CAK5B;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,GAAE,iBAAsB,EAAE,SAAS,GAAE,sBAA2B,GAAG,O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;CAO1D;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,IAAI,OAAO,CASvE;AACD,wBAAgB,cAAc,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAOvD;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,IAAI,QAAQ,CASzE;AACD,wBAAgB,eAAe,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAOxD;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,IAAI,QAAQ,CASzE;AACD,wBAAgB,eAAe,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAOxD;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,IAAI,QAAQ,CASzE;AACD,wBAAgB,eAAe,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAOxD;AAED,eAAO,MAAM,uBAAuB,qCAmClC,CAAC;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AACtE,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,OAAO,IAAI,eAAe,CAS3F;AACD,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,OAAO,CAOlE;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,GAAE,MAAiB,GAAG,IAAI,CAOnF"}
@@ -3,30 +3,25 @@
3
3
  * Provides comprehensive validation functions to ensure vector data integrity
4
4
  * and catch errors early in mathematical operations.
5
5
  */
6
- import { SetExceptionMessage, ThrowException } from '@pawells/typescript-common';
6
+ import { VECTOR2_SCHEMA, VECTOR3_SCHEMA, VECTOR4_SCHEMA, VECTOR_SCHEMA } from './types.js';
7
+ import z from 'zod';
7
8
  /**
8
- * Specialized error class for vector-related operations and validations.
9
- * Thrown when vector assertions fail or vector operations encounter invalid data.
9
+ * Vector error class for validation failures and vector operations.
10
+ * Extends Error to provide detailed error information with optional cause chain.
10
11
  *
11
12
  * @example
12
- * try {
13
- * AssertVector("not a vector");
14
- * } catch (error) {
15
- * if (error instanceof VectorError) {
16
- * console.log("Vector validation failed:", error.message);
17
- * }
18
- * }
13
+ * ```typescript
14
+ * throw new VectorError('Invalid vector dimensions', { cause: originalError });
15
+ * ```
19
16
  */
20
17
  export class VectorError extends Error {
21
- /**
22
- * Creates a new VectorError instance.
23
- *
24
- * @param message - Optional error message describing the validation failure
25
- */
26
- constructor(message) {
18
+ code = 'VECTOR_ERROR';
19
+ constructor(message, options) {
27
20
  super(message);
28
21
  this.name = 'VectorError';
29
- Object.setPrototypeOf(this, new.target.prototype);
22
+ if (options?.cause) {
23
+ this.cause = options.cause;
24
+ }
30
25
  }
31
26
  }
32
27
  /**
@@ -44,53 +39,30 @@ export class VectorError extends Error {
44
39
  * ```typescript
45
40
  * // Basic validation — passes silently for a valid vector
46
41
  * AssertVector([1, 2, 3]);
47
- *
48
42
  * // Validate with size constraint
49
43
  * AssertVector([1, 2], { size: 2 });
50
- *
51
44
  * // Throws VectorError for non-array input
52
45
  * AssertVector("not a vector"); // throws VectorError
53
46
  * ```
54
47
  */
55
- export function AssertVector(vector, args = {}, exception = {}) {
56
- // Initialize exception configuration with defaults
57
- const exc = exception ?? {};
58
- exc.class ??= VectorError;
59
- // First validate that it's an array
60
- if (!Array.isArray(vector)) {
61
- SetExceptionMessage(exc, 'Not a Valid Vector');
62
- ThrowException(exc);
63
- }
64
- // Type cast is safe after array validation
65
- const array = vector;
66
- // Validate array size constraints (inherited from AssertArrayArgs)
67
- if (args.size !== undefined && array.length !== args.size) {
68
- SetExceptionMessage(exc, `Vector does not match expected size. (size: ${args.size})`);
69
- ThrowException(exc);
48
+ export function AssertVector(vector) {
49
+ try {
50
+ VECTOR_SCHEMA.parse(vector);
70
51
  }
71
- if (args.minSize !== undefined && array.length < args.minSize) {
72
- SetExceptionMessage(exc, `Vector is less than minimum size. (min: ${args.minSize})`);
73
- ThrowException(exc);
52
+ catch (error) {
53
+ const message = error instanceof Error ? error.message : String(error);
54
+ throw new VectorError(`Invalid vector: ${message}`, {
55
+ cause: error instanceof Error ? error : undefined,
56
+ });
74
57
  }
75
- if (args.maxSize !== undefined && array.length > args.maxSize) {
76
- SetExceptionMessage(exc, `Vector exceeds maximum size. (max: ${args.maxSize})`);
77
- ThrowException(exc);
58
+ }
59
+ export function ValidateVector(vector) {
60
+ try {
61
+ AssertVector(vector);
62
+ return true;
78
63
  }
79
- // Validate each element is a valid number using AssertVectorValue
80
- for (let i = 0; i < array.length; i++) {
81
- try {
82
- AssertVectorValue(array[i], args, { ...exc, index: i });
83
- }
84
- catch (error) {
85
- // Re-throw with vector context if it's our error type
86
- if (error instanceof VectorError) {
87
- throw error;
88
- }
89
- // Wrap other errors in VectorError
90
- SetExceptionMessage(exc, `Invalid Vector Element${exc.index ? `[${exc.index}]` : ''}: ${error.message}`);
91
- exc.index = i;
92
- ThrowException(exc);
93
- }
64
+ catch {
65
+ return false;
94
66
  }
95
67
  }
96
68
  /**
@@ -107,8 +79,25 @@ export function AssertVector(vector, args = {}, exception = {}) {
107
79
  * AssertVector2("not a vec"); // throws
108
80
  * ```
109
81
  */
110
- export function AssertVector2(vector, exception = {}) {
111
- AssertVector(vector, { size: 2 }, exception);
82
+ export function AssertVector2(vector) {
83
+ try {
84
+ VECTOR2_SCHEMA.parse(vector);
85
+ }
86
+ catch (error) {
87
+ const message = error instanceof Error ? error.message : String(error);
88
+ throw new VectorError(`Invalid 2D vector: ${message}`, {
89
+ cause: error instanceof Error ? error : undefined,
90
+ });
91
+ }
92
+ }
93
+ export function ValidateVector2(vector) {
94
+ try {
95
+ AssertVector2(vector);
96
+ return true;
97
+ }
98
+ catch {
99
+ return false;
100
+ }
112
101
  }
113
102
  /**
114
103
  * Validates that an unknown value is a valid 3D vector (exactly 3 numeric components).
@@ -124,8 +113,25 @@ export function AssertVector2(vector, exception = {}) {
124
113
  * AssertVector3(null); // throws
125
114
  * ```
126
115
  */
127
- export function AssertVector3(vector, exception = {}) {
128
- AssertVector(vector, { size: 3 }, exception);
116
+ export function AssertVector3(vector) {
117
+ try {
118
+ VECTOR3_SCHEMA.parse(vector);
119
+ }
120
+ catch (error) {
121
+ const message = error instanceof Error ? error.message : String(error);
122
+ throw new VectorError(`Invalid 3D vector: ${message}`, {
123
+ cause: error instanceof Error ? error : undefined,
124
+ });
125
+ }
126
+ }
127
+ export function ValidateVector3(vector) {
128
+ try {
129
+ AssertVector3(vector);
130
+ return true;
131
+ }
132
+ catch {
133
+ return false;
134
+ }
129
135
  }
130
136
  /**
131
137
  * Validates that an unknown value is a valid 4D vector (exactly 4 numeric components).
@@ -141,145 +147,103 @@ export function AssertVector3(vector, exception = {}) {
141
147
  * AssertVector4(undefined); // throws
142
148
  * ```
143
149
  */
144
- export function AssertVector4(vector, exception = {}) {
145
- AssertVector(vector, { size: 4 }, exception);
146
- }
147
- /**
148
- * Validates that an unknown value is a valid vector element (a finite, non-NaN number).
149
- *
150
- * Supports optional numeric constraints such as range bounds, integer enforcement,
151
- * and finiteness checks. Throws `VectorError` with the component index when available.
152
- *
153
- * @param value - The value to validate as a vector element
154
- * @param args - Numeric constraints (finite, integer, gt, gte, lt, lte, eq)
155
- * @param exception - Custom exception details, optionally including a component `index`
156
- * @throws {VectorError} If the value is not a valid number or violates any constraint
157
- *
158
- * @example
159
- * ```typescript
160
- * AssertVectorValue(3.14); // passes
161
- * AssertVectorValue(3.14, { finite: true }); // passes
162
- * AssertVectorValue(Infinity, { finite: true }); // throws
163
- * AssertVectorValue(NaN); // throws
164
- * AssertVectorValue(5, { gte: 0, lte: 10 }); // passes
165
- * ```
166
- */
167
- export function AssertVectorValue(value, args = {}, exception = {}) {
168
- // Initialize exception configuration with defaults
169
- const exc = exception ?? {};
170
- exc.class ??= VectorError;
171
- // Validate that the value is a number (and not NaN)
172
- if (typeof value !== 'number' || Number.isNaN(value)) {
173
- if (exc.index !== undefined) {
174
- SetExceptionMessage(exc, `Vector[${exc.index}] Not a Number`);
175
- }
176
- else {
177
- SetExceptionMessage(exc, `Vector element must be a number, got ${typeof value}`);
178
- }
179
- ThrowException(exc);
150
+ export function AssertVector4(vector) {
151
+ try {
152
+ VECTOR4_SCHEMA.parse(vector);
180
153
  }
181
- // Type cast is safe after number validation
182
- const numValue = value;
183
- // Apply all number validation constraints using the same logic as AssertNumber
184
- // but with VectorError as the default error class instead of NumberError
185
- // Validate finite constraint (if specified, value must be finite)
186
- if (args.finite === true && !Number.isFinite(numValue)) {
187
- SetExceptionMessage(exc, `Vector${exc.index ? `[${exc.index}]` : ''} Must be Finite`);
188
- ThrowException(exc);
154
+ catch (error) {
155
+ const message = error instanceof Error ? error.message : String(error);
156
+ throw new VectorError(`Invalid 4D vector: ${message}`, {
157
+ cause: error instanceof Error ? error : undefined,
158
+ });
189
159
  }
190
- // Validate integer constraint (if specified, value must be an integer)
191
- if (args.integer === true && !Number.isInteger(numValue)) {
192
- SetExceptionMessage(exc, `Vector${exc.index ? `[${exc.index}]` : ''} Must be an Integer`);
193
- ThrowException(exc);
160
+ }
161
+ export function ValidateVector4(vector) {
162
+ try {
163
+ AssertVector4(vector);
164
+ return true;
194
165
  }
195
- // Validate equality constraint (if specified, value must exactly match)
196
- if (args.eq !== undefined && numValue !== args.eq) {
197
- SetExceptionMessage(exc, `Vector${exc.index ? `[${exc.index}]` : ''} Must be equal to ${args.eq}`);
198
- ThrowException(exc);
166
+ catch {
167
+ return false;
168
+ }
169
+ }
170
+ export const VECTOR_SAME_SIZE_SCHEMA = z.array(VECTOR_SCHEMA).superRefine((vectors, ctx) => {
171
+ if (!Array.isArray(vectors) || vectors.length === 0) {
172
+ ctx.addIssue({
173
+ code: 'custom',
174
+ message: 'Input must be a non-empty array of vectors',
175
+ });
176
+ return;
177
+ }
178
+ const [firstVector] = vectors;
179
+ if (!Array.isArray(firstVector)) {
180
+ ctx.addIssue({
181
+ code: 'custom',
182
+ message: 'Each item must be an array representing a vector',
183
+ });
184
+ return;
185
+ }
186
+ const size = firstVector.length;
187
+ for (const vector of vectors) {
188
+ if (!Array.isArray(vector)) {
189
+ ctx.addIssue({
190
+ code: 'custom',
191
+ message: 'Each item must be an array representing a vector',
192
+ });
193
+ return;
194
+ }
195
+ if (vector.length !== size) {
196
+ ctx.addIssue({
197
+ code: 'custom',
198
+ message: `All vectors must have the same size. Expected size: ${size}, but got: ${vector.length}`,
199
+ });
200
+ return;
201
+ }
199
202
  }
200
- // Validate greater than constraint (exclusive - value must be strictly greater)
201
- if (args.gt !== undefined && numValue <= args.gt) {
202
- SetExceptionMessage(exc, `Vector${exc.index ? `[${exc.index}]` : ''} Must be greater than ${args.gt}`);
203
- ThrowException(exc);
203
+ });
204
+ export function AssertVectorSameSize(vectors) {
205
+ try {
206
+ VECTOR_SAME_SIZE_SCHEMA.parse(vectors);
204
207
  }
205
- // Validate greater than or equal constraint (inclusive - value can equal the bound)
206
- if (args.gte !== undefined && numValue < args.gte) {
207
- SetExceptionMessage(exc, `Vector${exc.index ? `[${exc.index}]` : ''} Must be greater than or equal to ${args.gte}`);
208
- ThrowException(exc);
208
+ catch (error) {
209
+ const message = error instanceof Error ? error.message : String(error);
210
+ throw new VectorError(`Vectors must have same size: ${message}`, {
211
+ cause: error instanceof Error ? error : undefined,
212
+ });
209
213
  }
210
- // Validate less than constraint (exclusive - value must be strictly less)
211
- if (args.lt !== undefined && numValue >= args.lt) {
212
- SetExceptionMessage(exc, `Vector${exc.index ? `[${exc.index}]` : ''} Must be less than ${args.lt}`);
213
- ThrowException(exc);
214
+ }
215
+ export function ValidateVectorSameSize(vectors) {
216
+ try {
217
+ AssertVectorSameSize(vectors);
218
+ return true;
214
219
  }
215
- // Validate less than or equal constraint (inclusive - value can equal the bound)
216
- if (args.lte !== undefined && numValue > args.lte) {
217
- SetExceptionMessage(exc, `Vector${exc.index ? `[${exc.index}]` : ''} Must be less than or equal to ${args.lte}`);
218
- ThrowException(exc);
220
+ catch {
221
+ return false;
219
222
  }
220
223
  }
221
224
  /**
222
- * Validates an array of vectors, ensuring each vector is valid and optionally
223
- * enforcing that all vectors share the same size.
225
+ * Validates that the given vector is not a zero vector (all components are not zero).
226
+ * Throws a VectorError if the vector is zero.
224
227
  *
225
- * @param vectors - The array of vectors to validate (must be non-empty)
226
- * @param args - Validation constraints applied to each vector; set `sameSize: true`
227
- * to require all vectors to have identical lengths
228
- * @param exception - Custom exception details if validation fails
229
- * @throws {VectorError} If the array is empty, any vector is invalid, or sizes
230
- * differ when `sameSize` is `true`
228
+ * @param vector - The vector to validate
229
+ * @param label - The label for the vector used in the error message (default: 'Vector')
230
+ * @throws {VectorError} If the vector is a zero vector
231
231
  *
232
232
  * @example
233
233
  * ```typescript
234
- * // Validate an array of 3D vectors
235
- * AssertVectors([[1, 2, 3], [4, 5, 6]]);
236
- *
237
- * // Require all vectors to share the same length
238
- * AssertVectors([[1, 2], [3, 4]], { sameSize: true });
234
+ * const v = [1, 2, 3];
235
+ * AssertVectorNonZero(v); // Valid
239
236
  *
240
- * // Throws because vectors have different sizes
241
- * AssertVectors([[1, 2], [1, 2, 3]], { sameSize: true }); // throws
237
+ * const zero = [0, 0, 0];
238
+ * AssertVectorNonZero(zero, 'Direction'); // Throws VectorError: Direction must not be zero
242
239
  * ```
243
240
  */
244
- export function AssertVectors(vectors, args, exception) {
245
- const exc = exception ?? {};
246
- exc.class ??= VectorError;
247
- // Validate that vectors is an array of arrays
248
- if (!Array.isArray(vectors)) {
249
- SetExceptionMessage(exc, 'Vectors argument must be an array of vectors');
250
- ThrowException(exc);
251
- }
252
- if (vectors.length === 0) {
253
- SetExceptionMessage(exc, 'Vectors array is empty');
254
- ThrowException(exc);
255
- }
256
- // Validate each vector and collect their sizes
257
- const sizes = [];
258
- for (let i = 0; i < vectors.length; i++) {
259
- try {
260
- AssertVector(vectors[i], args, { ...exc, index: i });
261
- sizes.push(vectors[i].length);
262
- }
263
- catch (error) {
264
- if (error instanceof VectorError) {
265
- throw error;
266
- }
267
- SetExceptionMessage(exc, `Invalid vector at index ${i}: ${error.message}`);
268
- exc.index = i;
269
- ThrowException(exc);
270
- }
271
- }
272
- // Check if all vectors have the same size if required
273
- const requireSameSize = args?.sameSize ?? true;
274
- if (requireSameSize) {
275
- const [firstSize] = sizes;
276
- for (let i = 1; i < sizes.length; i++) {
277
- if (sizes[i] !== firstSize) {
278
- SetExceptionMessage(exc, `Vectors at index 0 and ${i} do not have the same size (${firstSize} vs ${sizes[i]})`);
279
- exc.index = i;
280
- ThrowException(exc);
281
- }
282
- }
241
+ export function AssertVectorNonZero(vector, label = 'Vector') {
242
+ AssertVector(vector);
243
+ // Check if vector is zero (all components are 0)
244
+ const isZero = vector.every((v) => v === 0);
245
+ if (isZero) {
246
+ throw new VectorError(`${label} must not be zero`);
283
247
  }
284
248
  }
285
249
  //# sourceMappingURL=asserts.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"asserts.js","sourceRoot":"","sources":["../../src/vectors/asserts.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAyD,mBAAmB,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AA2CxI;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,WAAY,SAAQ,KAAK;IACrC;;;;OAIG;IACH,YAAY,OAAgB;QAC3B,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;QAC1B,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACnD,CAAC;CACD;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM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