@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
@@ -2,7 +2,7 @@
2
2
  * Predefined vector factory functions for common mathematical operations.
3
3
  * Provides convenient constructors for standard vectors used in graphics, physics, and mathematics.
4
4
  */
5
- import { TVector, TVector2, TVector3, TVector4 } from './types.js';
5
+ import type { TVector, TVector2, TVector3, TVector4 } from './types.js';
6
6
  type TVectorSize3 = 3;
7
7
  type TVectorSize4 = 4;
8
8
  /**
@@ -14,9 +14,11 @@ type TVectorSize4 = 4;
14
14
  * @returns A vector with all components set to 0
15
15
  *
16
16
  * @example
17
- * const origin2D = VectorZero(2); // [0, 0]
18
- * const origin3D = VectorZero(3); // [0, 0, 0]
19
- * const origin4D = VectorZero(4); // [0, 0, 0, 0]
17
+ * ```typescript
18
+ * const origin2D = VectorZero(2); // [0, 0]
19
+ * const origin3D = VectorZero(3); // [0, 0, 0]
20
+ * const origin4D = VectorZero(4); // [0, 0, 0, 0]
21
+ * ```
20
22
  */
21
23
  export declare function VectorZero(size: 1): TVector;
22
24
  export declare function VectorZero(size: 2): TVector2;
@@ -31,9 +33,11 @@ export declare function VectorZero(size: TVectorSize4): TVector4;
31
33
  * @returns A vector with all components set to 1
32
34
  *
33
35
  * @example
34
- * const ones2D = VectorOne(2); // [1, 1]
35
- * const ones3D = VectorOne(3); // [1, 1, 1]
36
- * const ones4D = VectorOne(4); // [1, 1, 1, 1]
36
+ * ```typescript
37
+ * const ones2D = VectorOne(2); // [1, 1]
38
+ * const ones3D = VectorOne(3); // [1, 1, 1]
39
+ * const ones4D = VectorOne(4); // [1, 1, 1, 1]
40
+ * ```
37
41
  */
38
42
  export declare function VectorOne(size: 1): TVector;
39
43
  export declare function VectorOne(size: 2): TVector2;
@@ -47,8 +51,10 @@ export declare function VectorOne(size: TVectorSize4): TVector4;
47
51
  * @returns [0, 1] - Unit vector in positive Y direction
48
52
  *
49
53
  * @example
50
- * const upDirection = Vector2_Up(); // Character movement upward
51
- * const velocity = Vector2_Up().map(c => c * speed); // Moving up at given speed
54
+ * ```typescript
55
+ * const upDirection = Vector2Up(); // Character movement upward
56
+ * const velocity = Vector2Up().map(c => c * speed); // Moving up at given speed
57
+ * ```
52
58
  */
53
59
  export declare function Vector2Up(): TVector2;
54
60
  /**
@@ -58,8 +64,10 @@ export declare function Vector2Up(): TVector2;
58
64
  * @returns [0, 1, 0] - Unit vector in positive Y direction
59
65
  *
60
66
  * @example
61
- * const worldUp = Vector3_Up(); // World space up direction
62
- * const jumpForce = Vector3_Up().map(c => c * jumpStrength);
67
+ * ```typescript
68
+ * const worldUp = Vector3Up(); // World space up direction
69
+ * const jumpForce = Vector3Up().map(c => c * jumpStrength);
70
+ * ```
63
71
  */
64
72
  export declare function Vector3Up(): TVector3;
65
73
  /**
@@ -67,6 +75,10 @@ export declare function Vector3Up(): TVector3;
67
75
  * Useful in homogeneous coordinates and 4D transformations.
68
76
  *
69
77
  * @returns [0, 1, 0, 0] - Unit vector in positive Y direction
78
+ * @example
79
+ * ```typescript
80
+ * const up4 = Vector4Up(); // [0, 1, 0, 0]
81
+ * ```
70
82
  */
71
83
  export declare function Vector4Up(): TVector4;
72
84
  /**
@@ -76,8 +88,10 @@ export declare function Vector4Up(): TVector4;
76
88
  * @returns [0, -1] - Unit vector in negative Y direction
77
89
  *
78
90
  * @example
79
- * const gravity = Vector2_Down().map(c => c * 9.81); // Gravity force
80
- * const dropDirection = Vector2_Down(); // Object falling down
91
+ * ```typescript
92
+ * const gravity = Vector2Down().map(c => c * 9.81); // Gravity force
93
+ * const dropDirection = Vector2Down(); // Object falling down
94
+ * ```
81
95
  */
82
96
  export declare function Vector2Down(): TVector2;
83
97
  /**
@@ -87,14 +101,20 @@ export declare function Vector2Down(): TVector2;
87
101
  * @returns [0, -1, 0] - Unit vector in negative Y direction
88
102
  *
89
103
  * @example
90
- * const gravityForce = Vector3Down().map(c => c * 9.81);
91
- * const downwardRay = Vector3Down(); // Raycast downward
104
+ * ```typescript
105
+ * const gravityForce = Vector3Down().map(c => c * 9.81);
106
+ * const downwardRay = Vector3Down(); // Raycast downward
107
+ * ```
92
108
  */
93
109
  export declare function Vector3Down(): TVector3;
94
110
  /**
95
111
  * Creates a 4D unit vector pointing downward (negative Y direction).
96
112
  *
97
113
  * @returns [0, -1, 0, 0] - Unit vector in negative Y direction
114
+ * @example
115
+ * ```typescript
116
+ * const down4 = Vector4Down(); // [0, -1, 0, 0]
117
+ * ```
98
118
  */
99
119
  export declare function Vector4Down(): TVector4;
100
120
  /**
@@ -104,8 +124,10 @@ export declare function Vector4Down(): TVector4;
104
124
  * @returns [-1, 0] - Unit vector in negative X direction
105
125
  *
106
126
  * @example
107
- * const leftMovement = Vector2Left().map(c => c * speed);
108
- * const leftDirection = Vector2Left(); // Character facing left
127
+ * ```typescript
128
+ * const leftMovement = Vector2Left().map(c => c * speed);
129
+ * const leftDirection = Vector2Left(); // Character facing left
130
+ * ```
109
131
  */
110
132
  export declare function Vector2Left(): TVector2;
111
133
  /**
@@ -115,13 +137,19 @@ export declare function Vector2Left(): TVector2;
115
137
  * @returns [-1, 0, 0] - Unit vector in negative X direction
116
138
  *
117
139
  * @example
118
- * const strafeLeft = Vector3Left().map(c => c * strafeSpeed);
140
+ * ```typescript
141
+ * const strafeLeft = Vector3Left().map(c => c * strafeSpeed);
142
+ * ```
119
143
  */
120
144
  export declare function Vector3Left(): TVector3;
121
145
  /**
122
146
  * Creates a 4D unit vector pointing left (negative X direction).
123
147
  *
124
148
  * @returns [-1, 0, 0, 0] - Unit vector in negative X direction
149
+ * @example
150
+ * ```typescript
151
+ * const left4 = Vector4Left(); // [-1, 0, 0, 0]
152
+ * ```
125
153
  */
126
154
  export declare function Vector4Left(): TVector4;
127
155
  /**
@@ -131,8 +159,10 @@ export declare function Vector4Left(): TVector4;
131
159
  * @returns [1, 0] - Unit vector in positive X direction
132
160
  *
133
161
  * @example
134
- * const rightMovement = Vector2Right().map(c => c * speed);
135
- * const rightDirection = Vector2Right(); // Character facing right
162
+ * ```typescript
163
+ * const rightMovement = Vector2Right().map(c => c * speed);
164
+ * const rightDirection = Vector2Right(); // Character facing right
165
+ * ```
136
166
  */
137
167
  export declare function Vector2Right(): TVector2;
138
168
  /**
@@ -142,13 +172,19 @@ export declare function Vector2Right(): TVector2;
142
172
  * @returns [1, 0, 0] - Unit vector in positive X direction
143
173
  *
144
174
  * @example
145
- * const strafeRight = Vector3Right().map(c => c * strafeSpeed);
175
+ * ```typescript
176
+ * const strafeRight = Vector3Right().map(c => c * strafeSpeed);
177
+ * ```
146
178
  */
147
179
  export declare function Vector3Right(): TVector3;
148
180
  /**
149
181
  * Creates a 4D unit vector pointing right (positive X direction).
150
182
  *
151
183
  * @returns [1, 0, 0, 0] - Unit vector in positive X direction
184
+ * @example
185
+ * ```typescript
186
+ * const right4 = Vector4Right(); // [1, 0, 0, 0]
187
+ * ```
152
188
  */
153
189
  export declare function Vector4Right(): TVector4;
154
190
  /**
@@ -159,14 +195,20 @@ export declare function Vector4Right(): TVector4;
159
195
  * @returns [0, 0, 1] - Unit vector in positive Z direction
160
196
  *
161
197
  * @example
162
- * const forwardMovement = Vector3Forward().map(c => c * speed);
163
- * const cameraForward = Vector3Forward(); // Camera looking direction
198
+ * ```typescript
199
+ * const forwardMovement = Vector3Forward().map(c => c * speed);
200
+ * const cameraForward = Vector3Forward(); // Camera looking direction
201
+ * ```
164
202
  */
165
203
  export declare function Vector3Forward(): TVector3;
166
204
  /**
167
205
  * Creates a 4D unit vector pointing forward (positive Z direction).
168
206
  *
169
207
  * @returns [0, 0, 1, 0] - Unit vector in positive Z direction
208
+ * @example
209
+ * ```typescript
210
+ * const forward4 = Vector4Forward(); // [0, 0, 1, 0]
211
+ * ```
170
212
  */
171
213
  export declare function Vector4Forward(): TVector4;
172
214
  /**
@@ -177,14 +219,20 @@ export declare function Vector4Forward(): TVector4;
177
219
  * @returns [0, 0, -1] - Unit vector in negative Z direction
178
220
  *
179
221
  * @example
180
- * const backwardMovement = Vector3Backward().map(c => c * speed);
181
- * const reverseDirection = Vector3Backward(); // Moving away from target
222
+ * ```typescript
223
+ * const backwardMovement = Vector3Backward().map(c => c * speed);
224
+ * const reverseDirection = Vector3Backward(); // Moving away from target
225
+ * ```
182
226
  */
183
227
  export declare function Vector3Backward(): TVector3;
184
228
  /**
185
229
  * Creates a 4D unit vector pointing backward (negative Z direction).
186
230
  *
187
231
  * @returns [0, 0, -1, 0] - Unit vector in negative Z direction
232
+ * @example
233
+ * ```typescript
234
+ * const backward4 = Vector4Backward(); // [0, 0, -1, 0]
235
+ * ```
188
236
  */
189
237
  export declare function Vector4Backward(): TVector4;
190
238
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"predefined.d.ts","sourceRoot":"","sources":["../../src/vectors/predefined.ts"],"names":[],"mappings":"AA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AAY,GAAG,QAAQ,CAAC;AAKxD;;;;;;;;;;;;GAYG;AACH,wBAAgB,SAAS,IAAI,QAAQ,CAEpC;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,SAAS,IAAI,QAAQ,CAEpC;AAED;;;;;;;;;GASG;AACH,wBAAgB,SAAS,IAAI,QAAQ,CAEpC;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,IAAI,QAAQ,CAEtC;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,IAAI,QAAQ,CAEtC;AAED;;;;;;;;GAQG;AACH,wBAAgB,WAAW,IAAI,QAAQ,CAEtC;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,IAAI,QAAQ,CAEtC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,IAAI,QAAQ,CAEtC;AAED;;;;;;;;GAQG;AACH,wBAAgB,WAAW,IAAI,QAAQ,CAEtC;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,IAAI,QAAQ,CAEvC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,IAAI,QAAQ,CAEvC;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,IAAI,QAAQ,CAEvC;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,IAAI,QAAQ,CAEzC;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,IAAI,QAAQ,CAEzC;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,IAAI,QAAQ,CAE1C;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,IAAI,QAAQ,CAE1C"}
@@ -16,8 +16,10 @@ export function VectorOne(size) {
16
16
  * @returns [0, 1] - Unit vector in positive Y direction
17
17
  *
18
18
  * @example
19
- * const upDirection = Vector2_Up(); // Character movement upward
20
- * const velocity = Vector2_Up().map(c => c * speed); // Moving up at given speed
19
+ * ```typescript
20
+ * const upDirection = Vector2Up(); // Character movement upward
21
+ * const velocity = Vector2Up().map(c => c * speed); // Moving up at given speed
22
+ * ```
21
23
  */
22
24
  export function Vector2Up() {
23
25
  return [0, 1];
@@ -29,8 +31,10 @@ export function Vector2Up() {
29
31
  * @returns [0, 1, 0] - Unit vector in positive Y direction
30
32
  *
31
33
  * @example
32
- * const worldUp = Vector3_Up(); // World space up direction
33
- * const jumpForce = Vector3_Up().map(c => c * jumpStrength);
34
+ * ```typescript
35
+ * const worldUp = Vector3Up(); // World space up direction
36
+ * const jumpForce = Vector3Up().map(c => c * jumpStrength);
37
+ * ```
34
38
  */
35
39
  export function Vector3Up() {
36
40
  return [0, 1, 0];
@@ -40,6 +44,10 @@ export function Vector3Up() {
40
44
  * Useful in homogeneous coordinates and 4D transformations.
41
45
  *
42
46
  * @returns [0, 1, 0, 0] - Unit vector in positive Y direction
47
+ * @example
48
+ * ```typescript
49
+ * const up4 = Vector4Up(); // [0, 1, 0, 0]
50
+ * ```
43
51
  */
44
52
  export function Vector4Up() {
45
53
  return [0, 1, 0, 0];
@@ -51,8 +59,10 @@ export function Vector4Up() {
51
59
  * @returns [0, -1] - Unit vector in negative Y direction
52
60
  *
53
61
  * @example
54
- * const gravity = Vector2_Down().map(c => c * 9.81); // Gravity force
55
- * const dropDirection = Vector2_Down(); // Object falling down
62
+ * ```typescript
63
+ * const gravity = Vector2Down().map(c => c * 9.81); // Gravity force
64
+ * const dropDirection = Vector2Down(); // Object falling down
65
+ * ```
56
66
  */
57
67
  export function Vector2Down() {
58
68
  return [0, -1];
@@ -64,8 +74,10 @@ export function Vector2Down() {
64
74
  * @returns [0, -1, 0] - Unit vector in negative Y direction
65
75
  *
66
76
  * @example
67
- * const gravityForce = Vector3Down().map(c => c * 9.81);
68
- * const downwardRay = Vector3Down(); // Raycast downward
77
+ * ```typescript
78
+ * const gravityForce = Vector3Down().map(c => c * 9.81);
79
+ * const downwardRay = Vector3Down(); // Raycast downward
80
+ * ```
69
81
  */
70
82
  export function Vector3Down() {
71
83
  return [0, -1, 0];
@@ -74,6 +86,10 @@ export function Vector3Down() {
74
86
  * Creates a 4D unit vector pointing downward (negative Y direction).
75
87
  *
76
88
  * @returns [0, -1, 0, 0] - Unit vector in negative Y direction
89
+ * @example
90
+ * ```typescript
91
+ * const down4 = Vector4Down(); // [0, -1, 0, 0]
92
+ * ```
77
93
  */
78
94
  export function Vector4Down() {
79
95
  return [0, -1, 0, 0];
@@ -85,8 +101,10 @@ export function Vector4Down() {
85
101
  * @returns [-1, 0] - Unit vector in negative X direction
86
102
  *
87
103
  * @example
88
- * const leftMovement = Vector2Left().map(c => c * speed);
89
- * const leftDirection = Vector2Left(); // Character facing left
104
+ * ```typescript
105
+ * const leftMovement = Vector2Left().map(c => c * speed);
106
+ * const leftDirection = Vector2Left(); // Character facing left
107
+ * ```
90
108
  */
91
109
  export function Vector2Left() {
92
110
  return [-1, 0];
@@ -98,7 +116,9 @@ export function Vector2Left() {
98
116
  * @returns [-1, 0, 0] - Unit vector in negative X direction
99
117
  *
100
118
  * @example
101
- * const strafeLeft = Vector3Left().map(c => c * strafeSpeed);
119
+ * ```typescript
120
+ * const strafeLeft = Vector3Left().map(c => c * strafeSpeed);
121
+ * ```
102
122
  */
103
123
  export function Vector3Left() {
104
124
  return [-1, 0, 0];
@@ -107,6 +127,10 @@ export function Vector3Left() {
107
127
  * Creates a 4D unit vector pointing left (negative X direction).
108
128
  *
109
129
  * @returns [-1, 0, 0, 0] - Unit vector in negative X direction
130
+ * @example
131
+ * ```typescript
132
+ * const left4 = Vector4Left(); // [-1, 0, 0, 0]
133
+ * ```
110
134
  */
111
135
  export function Vector4Left() {
112
136
  return [-1, 0, 0, 0];
@@ -118,8 +142,10 @@ export function Vector4Left() {
118
142
  * @returns [1, 0] - Unit vector in positive X direction
119
143
  *
120
144
  * @example
121
- * const rightMovement = Vector2Right().map(c => c * speed);
122
- * const rightDirection = Vector2Right(); // Character facing right
145
+ * ```typescript
146
+ * const rightMovement = Vector2Right().map(c => c * speed);
147
+ * const rightDirection = Vector2Right(); // Character facing right
148
+ * ```
123
149
  */
124
150
  export function Vector2Right() {
125
151
  return [1, 0];
@@ -131,7 +157,9 @@ export function Vector2Right() {
131
157
  * @returns [1, 0, 0] - Unit vector in positive X direction
132
158
  *
133
159
  * @example
134
- * const strafeRight = Vector3Right().map(c => c * strafeSpeed);
160
+ * ```typescript
161
+ * const strafeRight = Vector3Right().map(c => c * strafeSpeed);
162
+ * ```
135
163
  */
136
164
  export function Vector3Right() {
137
165
  return [1, 0, 0];
@@ -140,6 +168,10 @@ export function Vector3Right() {
140
168
  * Creates a 4D unit vector pointing right (positive X direction).
141
169
  *
142
170
  * @returns [1, 0, 0, 0] - Unit vector in positive X direction
171
+ * @example
172
+ * ```typescript
173
+ * const right4 = Vector4Right(); // [1, 0, 0, 0]
174
+ * ```
143
175
  */
144
176
  export function Vector4Right() {
145
177
  return [1, 0, 0, 0];
@@ -152,8 +184,10 @@ export function Vector4Right() {
152
184
  * @returns [0, 0, 1] - Unit vector in positive Z direction
153
185
  *
154
186
  * @example
155
- * const forwardMovement = Vector3Forward().map(c => c * speed);
156
- * const cameraForward = Vector3Forward(); // Camera looking direction
187
+ * ```typescript
188
+ * const forwardMovement = Vector3Forward().map(c => c * speed);
189
+ * const cameraForward = Vector3Forward(); // Camera looking direction
190
+ * ```
157
191
  */
158
192
  export function Vector3Forward() {
159
193
  return [0, 0, 1];
@@ -162,6 +196,10 @@ export function Vector3Forward() {
162
196
  * Creates a 4D unit vector pointing forward (positive Z direction).
163
197
  *
164
198
  * @returns [0, 0, 1, 0] - Unit vector in positive Z direction
199
+ * @example
200
+ * ```typescript
201
+ * const forward4 = Vector4Forward(); // [0, 0, 1, 0]
202
+ * ```
165
203
  */
166
204
  export function Vector4Forward() {
167
205
  return [0, 0, 1, 0];
@@ -174,8 +212,10 @@ export function Vector4Forward() {
174
212
  * @returns [0, 0, -1] - Unit vector in negative Z direction
175
213
  *
176
214
  * @example
177
- * const backwardMovement = Vector3Backward().map(c => c * speed);
178
- * const reverseDirection = Vector3Backward(); // Moving away from target
215
+ * ```typescript
216
+ * const backwardMovement = Vector3Backward().map(c => c * speed);
217
+ * const reverseDirection = Vector3Backward(); // Moving away from target
218
+ * ```
179
219
  */
180
220
  export function Vector3Backward() {
181
221
  return [0, 0, -1];
@@ -184,6 +224,10 @@ export function Vector3Backward() {
184
224
  * Creates a 4D unit vector pointing backward (negative Z direction).
185
225
  *
186
226
  * @returns [0, 0, -1, 0] - Unit vector in negative Z direction
227
+ * @example
228
+ * ```typescript
229
+ * const backward4 = Vector4Backward(); // [0, 0, -1, 0]
230
+ * ```
187
231
  */
188
232
  export function Vector4Backward() {
189
233
  return [0, 0, -1, 0];
@@ -1 +1 @@
1
- {"version":3,"file":"predefined.js","sourceRoot":"","sources":["../../src/vectors/predefined.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAwBH,MAAM,UAAU,UAAU,CAAC,IAAY;IACtC,OAAO,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAChC,CAAC;AAmBD,MAAM,UAAU,SAAS,CAAC,IAAY;IACrC,OAAO,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAChC,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,SAAS;IACxB,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACf,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,SAAS;IACxB,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAClB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,SAAS;IACxB,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AACrB,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,WAAW;IAC1B,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAChB,CAAC;AAED;;;;;;;;;GAS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C,CAAC,CAAC;AACtB,CAAC"}
@@ -2,50 +2,70 @@
2
2
  * Vector type definitions for mathematical operations and geometric calculations.
3
3
  * These types provide a flexible foundation for vector operations while maintaining type safety.
4
4
  */
5
+ import z from 'zod';
5
6
  /**
6
7
  * Generic vector type representing an array of numbers with arbitrary dimensions.
7
8
  * Useful for mathematical operations on vectors of any size.
8
9
  *
9
10
  * @example
11
+ * ```typescript
10
12
  * const vector: TVector = [1, 2, 3, 4, 5]; // 5D vector
13
+ * ```
11
14
  */
12
- export type TVector = number[];
15
+ export declare const VECTOR_SCHEMA: z.ZodArray<z.ZodNumber>;
16
+ export type TVector = z.infer<typeof VECTOR_SCHEMA>;
17
+ /**
18
+ * Non-empty vector schema ensuring at least one element.
19
+ * Used for operations that require non-empty vectors.
20
+ */
21
+ export declare const VECTOR_NONEMPTY_SCHEMA: z.ZodArray<z.ZodNumber>;
13
22
  /**
14
23
  * 2D vector type supporting both tuple and array representations.
15
24
  * Commonly used for 2D graphics, physics simulations, and coordinate systems.
16
25
  *
17
26
  * @example
27
+ * ```typescript
18
28
  * const position: TVector2 = [10, 20]; // Tuple representation (preferred)
19
29
  * const velocity: TVector2 = [5.5, -3.2]; // Array representation
30
+ * ```
20
31
  */
21
- export type TVector2 = [number, number];
32
+ export declare const VECTOR2_SCHEMA: z.ZodArray<z.ZodNumber>;
33
+ export type TVector2 = z.infer<typeof VECTOR2_SCHEMA>;
22
34
  /**
23
35
  * 3D vector type supporting both tuple and array representations.
24
36
  * Essential for 3D graphics, spatial calculations, and physics simulations.
25
37
  *
26
38
  * @example
39
+ * ```typescript
27
40
  * const position: TVector3 = [10, 20, 30]; // 3D position
28
41
  * const direction: TVector3 = [0, 1, 0]; // Unit vector (up)
29
42
  * const velocity: TVector3 = [2.5, -1.8, 3.2]; // 3D velocity
43
+ * ```
30
44
  */
31
- export type TVector3 = [number, number, number];
45
+ export declare const VECTOR3_SCHEMA: z.ZodArray<z.ZodNumber>;
46
+ export type TVector3 = z.infer<typeof VECTOR3_SCHEMA>;
32
47
  /**
33
48
  * 4D vector type supporting both tuple and array representations.
34
49
  * Used for homogeneous coordinates in 3D transformations and projections.
35
50
  *
36
51
  * @example
52
+ * ```typescript
37
53
  * const homogeneous: TVector4 = [10, 20, 30, 1]; // 3D point in homogeneous coordinates
38
54
  * const direction: TVector4 = [0, 1, 0, 0]; // 3D direction vector
55
+ * ```
39
56
  */
40
- export type TVector4 = [number, number, number, number];
57
+ export declare const VECTOR4_SCHEMA: z.ZodArray<z.ZodNumber>;
58
+ export type TVector4 = z.infer<typeof VECTOR4_SCHEMA>;
41
59
  /**
42
60
  * Union type representing any vector type.
43
61
  * Useful for functions that can accept vectors of any dimension.
44
62
  *
45
63
  * @example
64
+ * ```typescript
46
65
  * function processVector(vector: TAnyVector): void {
47
66
  * // Can handle any vector dimension
48
67
  * }
68
+ * ```
49
69
  */
50
70
  export type TAnyVector = TVector | TVector2 | TVector3 | TVector4;
51
71
  /**
@@ -54,9 +74,11 @@ export type TAnyVector = TVector | TVector2 | TVector3 | TVector4;
54
74
  *
55
75
  * @template T - The input vector type extending TAnyVector
56
76
  * @example
77
+ * ```typescript
57
78
  * function operation<T extends TAnyVector>(vector: T): TVectorResult<T> {
58
79
  * // Returns same specific type as input
59
80
  * }
81
+ * ```
60
82
  */
61
83
  export type TVectorResult<T extends TAnyVector> = T extends TVector2 ? TVector2 : T extends TVector3 ? TVector3 : T extends TVector4 ? TVector4 : TVector;
62
84
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/vectors/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;GAMG;AACH,MAAM,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC;AAE/B;;;;;;;GAOG;AACH,MAAM,MAAM,QAAQ,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAExC;;;;;;;;GAQG;AACH,MAAM,MAAM,QAAQ,GAAG,CAAC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M,UAAU,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAElE;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,UAAU,IAAI,CAAC,SAAS,QAAQ,GAAG,QAAQ,GAAG,CAAC,SAAS,QAAQ,GAAG,QAAQ,GAAG,CAAC,SAAS,QAAQ,GAAG,QAAQ,GAAG,OAAO,CAAC"}
@@ -2,5 +2,54 @@
2
2
  * Vector type definitions for mathematical operations and geometric calculations.
3
3
  * These types provide a flexible foundation for vector operations while maintaining type safety.
4
4
  */
5
- export {};
5
+ import z from 'zod';
6
+ /**
7
+ * Generic vector type representing an array of numbers with arbitrary dimensions.
8
+ * Useful for mathematical operations on vectors of any size.
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * const vector: TVector = [1, 2, 3, 4, 5]; // 5D vector
13
+ * ```
14
+ */
15
+ export const VECTOR_SCHEMA = z.array(z.number());
16
+ /**
17
+ * Non-empty vector schema ensuring at least one element.
18
+ * Used for operations that require non-empty vectors.
19
+ */
20
+ export const VECTOR_NONEMPTY_SCHEMA = VECTOR_SCHEMA.min(1);
21
+ /**
22
+ * 2D vector type supporting both tuple and array representations.
23
+ * Commonly used for 2D graphics, physics simulations, and coordinate systems.
24
+ *
25
+ * @example
26
+ * ```typescript
27
+ * const position: TVector2 = [10, 20]; // Tuple representation (preferred)
28
+ * const velocity: TVector2 = [5.5, -3.2]; // Array representation
29
+ * ```
30
+ */
31
+ export const VECTOR2_SCHEMA = z.array(z.number()).refine(arr => arr.length === 2, { message: 'Vector2 must be an array of 2 numbers [x, y]' });
32
+ /**
33
+ * 3D vector type supporting both tuple and array representations.
34
+ * Essential for 3D graphics, spatial calculations, and physics simulations.
35
+ *
36
+ * @example
37
+ * ```typescript
38
+ * const position: TVector3 = [10, 20, 30]; // 3D position
39
+ * const direction: TVector3 = [0, 1, 0]; // Unit vector (up)
40
+ * const velocity: TVector3 = [2.5, -1.8, 3.2]; // 3D velocity
41
+ * ```
42
+ */
43
+ export const VECTOR3_SCHEMA = z.array(z.number()).refine(arr => arr.length === 3, { message: 'Vector3 must be an array of 3 numbers [x, y, z]' });
44
+ /**
45
+ * 4D vector type supporting both tuple and array representations.
46
+ * Used for homogeneous coordinates in 3D transformations and projections.
47
+ *
48
+ * @example
49
+ * ```typescript
50
+ * const homogeneous: TVector4 = [10, 20, 30, 1]; // 3D point in homogeneous coordinates
51
+ * const direction: TVector4 = [0, 1, 0, 0]; // 3D direction vector
52
+ * ```
53
+ */
54
+ export const VECTOR4_SCHEMA = z.array(z.number()).refine(arr => arr.length === 4, { message: 'Vector4 must be an array of 4 numbers [x, y, z, w]' });
6
55
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/vectors/types.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/vectors/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,CAAC,MAAM,KAAK,CAAC;AAEpB;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;AAGjD;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AAE3D;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE,EAAE,OAAO,EAAE,8CAA8C,EAAE,CAAC,CAAC;AAG/I;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE,EAAE,OAAO,EAAE,iDAAiD,EAAE,CAAC,CAAC;AAGlJ;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE,EAAE,OAAO,EAAE,oDAAoD,EAAE,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pawells/math-extended",
3
3
  "displayName": "Math Extended",
4
- "version": "1.1.1",
4
+ "version": "3.0.0",
5
5
  "description": "Shared TypeScript math library — vectors, matrices, quaternions, interpolation, angles, and random utilities. ESM-only.",
6
6
  "type": "module",
7
7
  "main": "./build/index.js",
@@ -28,7 +28,8 @@
28
28
  "prepare": "husky"
29
29
  },
30
30
  "dependencies": {
31
- "@pawells/typescript-common": "1.3.1"
31
+ "@pawells/typescript-common": "2.0.0",
32
+ "zod": "^4.4.3"
32
33
  },
33
34
  "devDependencies": {
34
35
  "@eslint/js": "^10.0.1",
@@ -44,7 +45,7 @@
44
45
  "eslint-plugin-unused-imports": "^4.0.0",
45
46
  "globals": "^17.4.0",
46
47
  "husky": "^9.1.7",
47
- "typescript": "^5.3.3",
48
+ "typescript": "^6.0.2",
48
49
  "vitest": "^4.0.18"
49
50
  },
50
51
  "keywords": [