@pawells/math-extended 1.0.5 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/build/angles.d.ts +43 -3
- package/build/angles.d.ts.map +1 -1
- package/build/angles.js +61 -34
- package/build/angles.js.map +1 -1
- package/build/clamp.d.ts +5 -3
- package/build/clamp.d.ts.map +1 -1
- package/build/clamp.js +5 -3
- package/build/clamp.js.map +1 -1
- package/build/interpolation.d.ts +444 -67
- package/build/interpolation.d.ts.map +1 -1
- package/build/interpolation.js +444 -67
- package/build/interpolation.js.map +1 -1
- package/build/matrices/_exports.d.ts +13 -0
- package/build/matrices/_exports.d.ts.map +1 -0
- package/build/matrices/_exports.js +13 -0
- package/build/matrices/_exports.js.map +1 -0
- package/build/matrices/arithmetic.d.ts +170 -181
- package/build/matrices/arithmetic.d.ts.map +1 -1
- package/build/matrices/arithmetic.js +192 -202
- package/build/matrices/arithmetic.js.map +1 -1
- package/build/matrices/asserts.d.ts +244 -116
- package/build/matrices/asserts.d.ts.map +1 -1
- package/build/matrices/asserts.js +291 -94
- package/build/matrices/asserts.js.map +1 -1
- package/build/matrices/core.d.ts +40 -41
- package/build/matrices/core.d.ts.map +1 -1
- package/build/matrices/core.js +12 -13
- package/build/matrices/core.js.map +1 -1
- package/build/matrices/decompositions.d.ts +121 -124
- package/build/matrices/decompositions.d.ts.map +1 -1
- package/build/matrices/decompositions.js +168 -226
- package/build/matrices/decompositions.js.map +1 -1
- package/build/matrices/index.d.ts +3 -2
- package/build/matrices/index.d.ts.map +1 -1
- package/build/matrices/index.js +5 -2
- package/build/matrices/index.js.map +1 -1
- package/build/matrices/linear-algebra.d.ts +18 -13
- package/build/matrices/linear-algebra.d.ts.map +1 -1
- package/build/matrices/linear-algebra.js +58 -23
- package/build/matrices/linear-algebra.js.map +1 -1
- package/build/matrices/normalization.d.ts +8 -8
- package/build/matrices/transformations.d.ts +184 -168
- package/build/matrices/transformations.d.ts.map +1 -1
- package/build/matrices/transformations.js +99 -83
- package/build/matrices/transformations.js.map +1 -1
- package/build/matrices/types.d.ts +12 -12
- package/build/matrices/types.d.ts.map +1 -1
- package/build/quaternions/_exports.d.ts +11 -0
- package/build/quaternions/_exports.d.ts.map +1 -0
- package/build/quaternions/_exports.js +11 -0
- package/build/quaternions/_exports.js.map +1 -0
- package/build/quaternions/asserts.d.ts +115 -7
- package/build/quaternions/asserts.d.ts.map +1 -1
- package/build/quaternions/asserts.js +162 -8
- package/build/quaternions/asserts.js.map +1 -1
- package/build/quaternions/conversions.d.ts +31 -21
- package/build/quaternions/conversions.d.ts.map +1 -1
- package/build/quaternions/conversions.js +28 -18
- package/build/quaternions/conversions.js.map +1 -1
- package/build/quaternions/core.d.ts +73 -41
- package/build/quaternions/core.d.ts.map +1 -1
- package/build/quaternions/core.js +84 -49
- package/build/quaternions/core.js.map +1 -1
- package/build/quaternions/index.d.ts +3 -2
- package/build/quaternions/index.d.ts.map +1 -1
- package/build/quaternions/index.js +5 -2
- package/build/quaternions/index.js.map +1 -1
- package/build/quaternions/interpolation.d.ts +15 -9
- package/build/quaternions/interpolation.d.ts.map +1 -1
- package/build/quaternions/interpolation.js +15 -9
- package/build/quaternions/interpolation.js.map +1 -1
- package/build/quaternions/predefined.d.ts +9 -3
- package/build/quaternions/predefined.d.ts.map +1 -1
- package/build/quaternions/predefined.js +9 -3
- package/build/quaternions/predefined.js.map +1 -1
- package/build/quaternions/types.d.ts +3 -3
- package/build/random.d.ts +5 -2
- package/build/random.d.ts.map +1 -1
- package/build/random.js +20 -17
- package/build/random.js.map +1 -1
- package/build/vectors/_exports.d.ts +10 -0
- package/build/vectors/_exports.d.ts.map +1 -0
- package/build/vectors/_exports.js +10 -0
- package/build/vectors/_exports.js.map +1 -0
- package/build/vectors/asserts.d.ts +153 -49
- package/build/vectors/asserts.d.ts.map +1 -1
- package/build/vectors/asserts.js +202 -52
- package/build/vectors/asserts.js.map +1 -1
- package/build/vectors/core.d.ts +216 -137
- package/build/vectors/core.d.ts.map +1 -1
- package/build/vectors/core.js +217 -158
- package/build/vectors/core.js.map +1 -1
- package/build/vectors/index.d.ts +1 -0
- package/build/vectors/index.d.ts.map +1 -1
- package/build/vectors/index.js +3 -0
- package/build/vectors/index.js.map +1 -1
- package/build/vectors/interpolation.d.ts +39 -27
- package/build/vectors/interpolation.d.ts.map +1 -1
- package/build/vectors/interpolation.js +39 -27
- package/build/vectors/interpolation.js.map +1 -1
- package/build/vectors/predefined.d.ts +48 -24
- package/build/vectors/predefined.d.ts.map +1 -1
- package/build/vectors/predefined.js +38 -18
- package/build/vectors/predefined.js.map +1 -1
- package/package.json +12 -15
|
@@ -12,11 +12,8 @@
|
|
|
12
12
|
*
|
|
13
13
|
* All matrices use homogeneous coordinates for consistent transformation composition.
|
|
14
14
|
* 2D transformations use 3x3 matrices, 3D transformations use 4x4 matrices.
|
|
15
|
-
*
|
|
16
|
-
* @author JTV Development Team
|
|
17
|
-
* @since 1.0.0
|
|
18
15
|
*/
|
|
19
|
-
import {
|
|
16
|
+
import { TMatrix3, TMatrix4 } from './types.js';
|
|
20
17
|
import { TVector2, TVector3 } from '../vectors/types.js';
|
|
21
18
|
/**
|
|
22
19
|
* Creates a 2D rotation matrix for rotating points around the origin.
|
|
@@ -33,20 +30,21 @@ import { TVector2, TVector3 } from '../vectors/types.js';
|
|
|
33
30
|
* ```
|
|
34
31
|
*
|
|
35
32
|
* @param radians - Rotation angle in radians (positive = counterclockwise)
|
|
36
|
-
* @returns {
|
|
33
|
+
* @returns {TMatrix3} A 3x3 rotation matrix for 2D transformations
|
|
37
34
|
*
|
|
38
35
|
* @throws {Error} If radians is not a finite number
|
|
39
36
|
*
|
|
40
37
|
* @example
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
38
|
+
* ```typescript
|
|
39
|
+
* ```typescript
|
|
40
|
+
* // 90-degree counterclockwise rotation
|
|
41
|
+
* const matrix = MatrixRotation2D(Math.PI / 2);
|
|
42
|
+
* // 45-degree clockwise rotation
|
|
43
|
+
* const clockwise = MatrixRotation2D(-Math.PI / 4);
|
|
44
|
+
* ```
|
|
45
|
+
* ```
|
|
48
46
|
*/
|
|
49
|
-
export declare function MatrixRotation2D(radians: number):
|
|
47
|
+
export declare function MatrixRotation2D(radians: number): TMatrix3;
|
|
50
48
|
/**
|
|
51
49
|
* Creates a 3D roll rotation matrix (rotation around the X-axis).
|
|
52
50
|
*
|
|
@@ -63,17 +61,19 @@ export declare function MatrixRotation2D(radians: number): IMatrix3;
|
|
|
63
61
|
* ```
|
|
64
62
|
*
|
|
65
63
|
* @param radians - Roll angle in radians (positive = right-hand rule around X-axis)
|
|
66
|
-
* @returns {
|
|
64
|
+
* @returns {TMatrix4} A 4x4 roll rotation matrix
|
|
67
65
|
*
|
|
68
66
|
* @throws {Error} If radians is not a finite number
|
|
69
67
|
*
|
|
70
68
|
* @example
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
69
|
+
* ```typescript
|
|
70
|
+
* ```typescript
|
|
71
|
+
* // 45-degree roll (banking left in aviation)
|
|
72
|
+
* const rollMatrix = MatrixRotation3DRoll(Math.PI / 4);
|
|
73
|
+
* ```
|
|
74
|
+
* ```
|
|
75
75
|
*/
|
|
76
|
-
export declare function MatrixRotation3DRoll(radians: number):
|
|
76
|
+
export declare function MatrixRotation3DRoll(radians: number): TMatrix4;
|
|
77
77
|
/**
|
|
78
78
|
* Creates a 3D pitch rotation matrix (rotation around the Y-axis).
|
|
79
79
|
*
|
|
@@ -90,17 +90,19 @@ export declare function MatrixRotation3DRoll(radians: number): IMatrix4;
|
|
|
90
90
|
* ```
|
|
91
91
|
*
|
|
92
92
|
* @param radians - Pitch angle in radians (positive = nose up in aviation)
|
|
93
|
-
* @returns {
|
|
93
|
+
* @returns {TMatrix4} A 4x4 pitch rotation matrix
|
|
94
94
|
*
|
|
95
95
|
* @throws {Error} If radians is not a finite number
|
|
96
96
|
*
|
|
97
97
|
* @example
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
98
|
+
* ```typescript
|
|
99
|
+
* ```typescript
|
|
100
|
+
* // 30-degree pitch up
|
|
101
|
+
* const pitchMatrix = MatrixRotation3DPitch(Math.PI / 6);
|
|
102
|
+
* ```
|
|
103
|
+
* ```
|
|
102
104
|
*/
|
|
103
|
-
export declare function MatrixRotation3DPitch(radians: number):
|
|
105
|
+
export declare function MatrixRotation3DPitch(radians: number): TMatrix4;
|
|
104
106
|
/**
|
|
105
107
|
* Creates a 3D yaw rotation matrix (rotation around the Z-axis).
|
|
106
108
|
*
|
|
@@ -117,17 +119,19 @@ export declare function MatrixRotation3DPitch(radians: number): IMatrix4;
|
|
|
117
119
|
* ```
|
|
118
120
|
*
|
|
119
121
|
* @param radians - Yaw angle in radians (positive = turn left in aviation)
|
|
120
|
-
* @returns {
|
|
122
|
+
* @returns {TMatrix4} A 4x4 yaw rotation matrix
|
|
121
123
|
*
|
|
122
124
|
* @throws {Error} If radians is not a finite number
|
|
123
125
|
*
|
|
124
126
|
* @example
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
127
|
+
* ```typescript
|
|
128
|
+
* ```typescript
|
|
129
|
+
* // 60-degree yaw left
|
|
130
|
+
* const yawMatrix = MatrixRotation3DYaw(Math.PI / 3);
|
|
131
|
+
* ```
|
|
132
|
+
* ```
|
|
129
133
|
*/
|
|
130
|
-
export declare function MatrixRotation3DYaw(radians: number):
|
|
134
|
+
export declare function MatrixRotation3DYaw(radians: number): TMatrix4;
|
|
131
135
|
/**
|
|
132
136
|
* Creates a composite 3D rotation matrix from yaw, pitch, and roll components.
|
|
133
137
|
*
|
|
@@ -142,22 +146,23 @@ export declare function MatrixRotation3DYaw(radians: number): IMatrix4;
|
|
|
142
146
|
* @param roll - Roll angle in radians (X-axis rotation) or vector [roll, pitch, yaw]
|
|
143
147
|
* @param pitch - Pitch angle in radians (Y-axis rotation, required if roll is number)
|
|
144
148
|
* @param yaw - Yaw angle in radians (Z-axis rotation, required if roll is number)
|
|
145
|
-
* @returns {
|
|
149
|
+
* @returns {TMatrix4} A 4x4 composite rotation matrix
|
|
146
150
|
*
|
|
147
151
|
* @throws {Error} If any angle is not a finite number
|
|
148
152
|
*
|
|
149
153
|
* @example
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
154
|
+
* ```typescript
|
|
155
|
+
* ```typescript
|
|
156
|
+
* // Using individual angles (banking, elevation, heading)
|
|
157
|
+
* const rotationMatrix = MatrixRotation3D(0.1, 0.2, 0.3);
|
|
158
|
+
* // Using vector input
|
|
159
|
+
* const eulerAngles: TVector3 = [0.1, 0.2, 0.3];
|
|
160
|
+
* const rotationMatrix2 = MatrixRotation3D(eulerAngles);
|
|
161
|
+
* ```
|
|
162
|
+
* ```
|
|
158
163
|
*/
|
|
159
|
-
export declare function MatrixRotation3D(roll: number, pitch: number, yaw: number):
|
|
160
|
-
export declare function MatrixRotation3D(v: TVector3):
|
|
164
|
+
export declare function MatrixRotation3D(roll: number, pitch: number, yaw: number): TMatrix4;
|
|
165
|
+
export declare function MatrixRotation3D(v: TVector3): TMatrix4;
|
|
161
166
|
/**
|
|
162
167
|
* Creates a composite 3D rotation matrix from Euler angles specified in degrees.
|
|
163
168
|
*
|
|
@@ -170,22 +175,23 @@ export declare function MatrixRotation3D(v: TVector3): IMatrix4;
|
|
|
170
175
|
* @param roll - Roll angle in degrees (X-axis rotation) or vector [roll, pitch, yaw]
|
|
171
176
|
* @param pitch - Pitch angle in degrees (Y-axis rotation, required if roll is number)
|
|
172
177
|
* @param yaw - Yaw angle in degrees (Z-axis rotation, required if roll is number)
|
|
173
|
-
* @returns {
|
|
178
|
+
* @returns {TMatrix4} A 4x4 composite rotation matrix
|
|
174
179
|
*
|
|
175
180
|
* @throws {Error} If any angle is not a finite number
|
|
176
181
|
*
|
|
177
182
|
* @example
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
183
|
+
* ```typescript
|
|
184
|
+
* ```typescript
|
|
185
|
+
* // Using individual angles in degrees
|
|
186
|
+
* const rotation = MatrixRotation3DEulerAngles(45, 30, 60);
|
|
187
|
+
* // Using vector input in degrees
|
|
188
|
+
* const angles: TVector3 = [45, 30, 60];
|
|
189
|
+
* const rotation2 = MatrixRotation3DEulerAngles(angles);
|
|
190
|
+
* ```
|
|
191
|
+
* ```
|
|
186
192
|
*/
|
|
187
|
-
export declare function MatrixRotation3DEulerAngles(roll: number, pitch: number, yaw: number):
|
|
188
|
-
export declare function MatrixRotation3DEulerAngles(v: TVector3):
|
|
193
|
+
export declare function MatrixRotation3DEulerAngles(roll: number, pitch: number, yaw: number): TMatrix4;
|
|
194
|
+
export declare function MatrixRotation3DEulerAngles(v: TVector3): TMatrix4;
|
|
189
195
|
/**
|
|
190
196
|
* Creates a 2D scale transformation matrix with flexible input options.
|
|
191
197
|
*
|
|
@@ -207,29 +213,28 @@ export declare function MatrixRotation3DEulerAngles(v: TVector3): IMatrix4;
|
|
|
207
213
|
*
|
|
208
214
|
* @param scale - Uniform scale factor for both axes, OR X-axis scale factor
|
|
209
215
|
* @param y - Y-axis scale factor (only for independent scaling)
|
|
210
|
-
* @returns {
|
|
216
|
+
* @returns {TMatrix3} A 3x3 scale transformation matrix
|
|
211
217
|
*
|
|
212
218
|
* @throws {Error} If any scale factor is not a finite number
|
|
213
219
|
*
|
|
214
220
|
* @example
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
* ```
|
|
221
|
+
* ```typescript
|
|
222
|
+
* ```typescript
|
|
223
|
+
* // Uniform scaling (double size)
|
|
224
|
+
* const uniform = MatrixScale2D(2.0);
|
|
225
|
+
* // Independent scaling (stretch horizontally, compress vertically)
|
|
226
|
+
* const stretch = MatrixScale2D(2.0, 0.5);
|
|
227
|
+
* // Vector input
|
|
228
|
+
* const scaleVector: TVector2 = [1.5, 0.8];
|
|
229
|
+
* const vectorScale = MatrixScale2D(scaleVector);
|
|
230
|
+
* // Flip horizontally
|
|
231
|
+
* const flip = MatrixScale2D(-1, 1);
|
|
232
|
+
* ```
|
|
233
|
+
* ```
|
|
229
234
|
*/
|
|
230
|
-
export declare function MatrixScale2D(scale: number):
|
|
231
|
-
export declare function MatrixScale2D(x: number, y: number):
|
|
232
|
-
export declare function MatrixScale2D(v: TVector2):
|
|
235
|
+
export declare function MatrixScale2D(scale: number): TMatrix3;
|
|
236
|
+
export declare function MatrixScale2D(x: number, y: number): TMatrix3;
|
|
237
|
+
export declare function MatrixScale2D(v: TVector2): TMatrix3;
|
|
233
238
|
/**
|
|
234
239
|
* Creates a 3D scale transformation matrix with flexible input options.
|
|
235
240
|
*
|
|
@@ -253,29 +258,28 @@ export declare function MatrixScale2D(v: TVector2): IMatrix3;
|
|
|
253
258
|
* @param scale - Uniform scale factor for all axes, OR X-axis scale factor
|
|
254
259
|
* @param y - Y-axis scale factor (only for independent scaling)
|
|
255
260
|
* @param z - Z-axis scale factor (only for independent scaling)
|
|
256
|
-
* @returns {
|
|
261
|
+
* @returns {TMatrix4} A 4x4 scale transformation matrix
|
|
257
262
|
*
|
|
258
263
|
* @throws {Error} If any scale factor is not a finite number
|
|
259
264
|
*
|
|
260
265
|
* @example
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
* ```
|
|
266
|
+
* ```typescript
|
|
267
|
+
* ```typescript
|
|
268
|
+
* // Uniform scaling (triple size)
|
|
269
|
+
* const uniform = MatrixScale3D(3.0);
|
|
270
|
+
* // Independent scaling (stretch, compress, normal)
|
|
271
|
+
* const stretch = MatrixScale3D(2.0, 0.5, 1.0);
|
|
272
|
+
* // Vector input
|
|
273
|
+
* const scaleVector: TVector3 = [1.5, 0.8, 2.0];
|
|
274
|
+
* const vectorScale = MatrixScale3D(scaleVector);
|
|
275
|
+
* // Mirror across XY plane
|
|
276
|
+
* const mirror = MatrixScale3D(1, 1, -1);
|
|
277
|
+
* ```
|
|
278
|
+
* ```
|
|
275
279
|
*/
|
|
276
|
-
export declare function MatrixScale3D(scale: number):
|
|
277
|
-
export declare function MatrixScale3D(x: number, y: number, z: number):
|
|
278
|
-
export declare function MatrixScale3D(v: TVector3):
|
|
280
|
+
export declare function MatrixScale3D(scale: number): TMatrix4;
|
|
281
|
+
export declare function MatrixScale3D(x: number, y: number, z: number): TMatrix4;
|
|
282
|
+
export declare function MatrixScale3D(v: TVector3): TMatrix4;
|
|
279
283
|
/**
|
|
280
284
|
* Creates a 2D translation transformation matrix.
|
|
281
285
|
*
|
|
@@ -290,21 +294,22 @@ export declare function MatrixScale3D(v: TVector3): IMatrix4;
|
|
|
290
294
|
* ```
|
|
291
295
|
*
|
|
292
296
|
* @param v - Translation vector [x, y] containing offset distances
|
|
293
|
-
* @returns {
|
|
297
|
+
* @returns {TMatrix3} A 3x3 translation transformation matrix
|
|
294
298
|
*
|
|
295
299
|
* @throws {Error} If the input is not a valid 2D vector
|
|
296
300
|
*
|
|
297
301
|
* @example
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
302
|
+
* ```typescript
|
|
303
|
+
* ```typescript
|
|
304
|
+
* // Move 10 units right, 5 units up
|
|
305
|
+
* const translation = MatrixTranslation2D(10, 5);
|
|
306
|
+
* // Using vector input
|
|
307
|
+
* const offset: TVector2 = [10, 5];
|
|
308
|
+
* const translation2 = MatrixTranslation2D(...offset);
|
|
309
|
+
* ```
|
|
310
|
+
* ```
|
|
306
311
|
*/
|
|
307
|
-
export declare function MatrixTranslation2D(...v: TVector2):
|
|
312
|
+
export declare function MatrixTranslation2D(...v: TVector2): TMatrix3;
|
|
308
313
|
/**
|
|
309
314
|
* Creates a 3D translation transformation matrix with flexible input options.
|
|
310
315
|
*
|
|
@@ -327,26 +332,26 @@ export declare function MatrixTranslation2D(...v: TVector2): IMatrix3;
|
|
|
327
332
|
* @param translationOrX - Uniform translation distance for all axes, OR X-axis distance
|
|
328
333
|
* @param y - Y-axis translation distance (only for independent translation)
|
|
329
334
|
* @param z - Z-axis translation distance (only for independent translation)
|
|
330
|
-
* @returns {
|
|
335
|
+
* @returns {TMatrix4} A 4x4 translation transformation matrix
|
|
331
336
|
*
|
|
332
337
|
* @throws {Error} If any translation distance is not a finite number
|
|
333
338
|
*
|
|
334
339
|
* @example
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
340
|
+
* ```typescript
|
|
341
|
+
* ```typescript
|
|
342
|
+
* // Uniform translation (move 5 units in all directions)
|
|
343
|
+
* const uniform = MatrixTranslation3D(5.0);
|
|
344
|
+
* // Independent translation
|
|
345
|
+
* const independent = MatrixTranslation3D(10, -5, 3);
|
|
346
|
+
* // Vector input
|
|
347
|
+
* const offset: TVector3 = [10, -5, 3];
|
|
348
|
+
* const vectorTranslation = MatrixTranslation3D(...offset);
|
|
349
|
+
* ```
|
|
350
|
+
* ```
|
|
346
351
|
*/
|
|
347
|
-
export declare function MatrixTranslation3D(translation: number):
|
|
348
|
-
export declare function MatrixTranslation3D(x: number, y: number, z: number):
|
|
349
|
-
export declare function MatrixTranslation3D(v: TVector3):
|
|
352
|
+
export declare function MatrixTranslation3D(translation: number): TMatrix4;
|
|
353
|
+
export declare function MatrixTranslation3D(x: number, y: number, z: number): TMatrix4;
|
|
354
|
+
export declare function MatrixTranslation3D(v: TVector3): TMatrix4;
|
|
350
355
|
/**
|
|
351
356
|
* Transforms a 2D vector using a 3x3 transformation matrix with homogeneous coordinates.
|
|
352
357
|
*
|
|
@@ -366,21 +371,22 @@ export declare function MatrixTranslation3D(v: TVector3): IMatrix4;
|
|
|
366
371
|
* @throws {Error} If inputs are not valid vector/matrix types
|
|
367
372
|
*
|
|
368
373
|
* @example
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
374
|
+
* ```typescript
|
|
375
|
+
* ```typescript
|
|
376
|
+
* // Rotate a point 90 degrees counterclockwise
|
|
377
|
+
* const rotationMatrix = MatrixRotation2D(Math.PI / 2);
|
|
378
|
+
* const point: TVector2 = [1, 0];
|
|
379
|
+
* const rotatedPoint = MatrixTransform2D(point, rotationMatrix);
|
|
380
|
+
* // Result: approximately [0, 1]
|
|
381
|
+
* // Chain multiple transformations
|
|
382
|
+
* const scale = MatrixScale2D(2, 2);
|
|
383
|
+
* const translate = MatrixTranslation2D(5, 3);
|
|
384
|
+
* const combined = MatrixMultiply(translate, scale);
|
|
385
|
+
* const transformedPoint = MatrixTransform2D(point, combined);
|
|
386
|
+
* ```
|
|
387
|
+
* ```
|
|
382
388
|
*/
|
|
383
|
-
export declare function MatrixTransform2D(vector: TVector2, matrix:
|
|
389
|
+
export declare function MatrixTransform2D(vector: TVector2, matrix: TMatrix3): TVector2;
|
|
384
390
|
/**
|
|
385
391
|
* Transforms a 3D vector using a 4x4 transformation matrix with homogeneous coordinates.
|
|
386
392
|
* Converts to homogeneous coordinates, applies transformation, then converts back to 3D.
|
|
@@ -392,13 +398,15 @@ export declare function MatrixTransform2D(vector: TVector2, matrix: IMatrix3): T
|
|
|
392
398
|
* @throws {Error} If the w component is near zero (degenerate transformation).
|
|
393
399
|
*
|
|
394
400
|
* @example
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
401
|
+
* ```typescript
|
|
402
|
+
* ```typescript
|
|
403
|
+
* const rotationMatrix = MatrixRotation3DYaw(Math.PI / 4);
|
|
404
|
+
* const point: TVector3 = [1, 0, 0];
|
|
405
|
+
* const rotatedPoint = MatrixTransform3D(point, rotationMatrix);
|
|
406
|
+
* ```
|
|
407
|
+
* ```
|
|
400
408
|
*/
|
|
401
|
-
export declare function MatrixTransform3D(vector: TVector3, transform:
|
|
409
|
+
export declare function MatrixTransform3D(vector: TVector3, transform: TMatrix4): TVector3;
|
|
402
410
|
/**
|
|
403
411
|
* Transforms a 3D direction vector using a 3x3 matrix, ignoring translation components.
|
|
404
412
|
* Designed for direction vectors (normals, velocities) where translation should not apply.
|
|
@@ -408,13 +416,15 @@ export declare function MatrixTransform3D(vector: TVector3, transform: IMatrix4)
|
|
|
408
416
|
* @returns {TVector3} The transformed direction vector.
|
|
409
417
|
*
|
|
410
418
|
* @example
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
419
|
+
* ```typescript
|
|
420
|
+
* ```typescript
|
|
421
|
+
* const rotationMatrix = MatrixRotation3DYaw(Math.PI / 4);
|
|
422
|
+
* const normal: TVector3 = [0, 0, 1];
|
|
423
|
+
* const rotatedNormal = MatrixDirection3D(normal, rotationMatrix);
|
|
424
|
+
* ```
|
|
425
|
+
* ```
|
|
416
426
|
*/
|
|
417
|
-
export declare function MatrixDirection3D(direction: TVector3, matrix:
|
|
427
|
+
export declare function MatrixDirection3D(direction: TVector3, matrix: TMatrix3): TVector3;
|
|
418
428
|
/**
|
|
419
429
|
* Creates a view matrix for positioning and orienting a 3D camera.
|
|
420
430
|
* Transforms world coordinates to camera coordinates using the "look-at" approach.
|
|
@@ -422,18 +432,20 @@ export declare function MatrixDirection3D(direction: TVector3, matrix: IMatrix3)
|
|
|
422
432
|
* @param eye - Camera position in world coordinates.
|
|
423
433
|
* @param target - Point the camera is looking at.
|
|
424
434
|
* @param up - Up direction vector (usually [0, 1, 0]).
|
|
425
|
-
* @returns {
|
|
435
|
+
* @returns {TMatrix4} A 4x4 view transformation matrix.
|
|
426
436
|
*
|
|
427
437
|
* @example
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
438
|
+
* ```typescript
|
|
439
|
+
* ```typescript
|
|
440
|
+
* const viewMatrix = MatrixView(
|
|
441
|
+
* [10, 5, 10], // Camera position
|
|
442
|
+
* [0, 0, 0], // Looking at origin
|
|
443
|
+
* [0, 1, 0] // Y-axis is up
|
|
444
|
+
* );
|
|
445
|
+
* ```
|
|
446
|
+
* ```
|
|
435
447
|
*/
|
|
436
|
-
export declare function MatrixView(eye: TVector3, target: TVector3, up: TVector3):
|
|
448
|
+
export declare function MatrixView(eye: TVector3, target: TVector3, up: TVector3): TMatrix4;
|
|
437
449
|
/**
|
|
438
450
|
* Creates a perspective projection matrix for 3D rendering.
|
|
439
451
|
* Transforms 3D view coordinates to normalized device coordinates with perspective effect.
|
|
@@ -442,21 +454,23 @@ export declare function MatrixView(eye: TVector3, target: TVector3, up: TVector3
|
|
|
442
454
|
* @param aspect - Aspect ratio of the viewport (width/height).
|
|
443
455
|
* @param near - Distance to near clipping plane (must be positive).
|
|
444
456
|
* @param far - Distance to far clipping plane (must be > near).
|
|
445
|
-
* @returns {
|
|
457
|
+
* @returns {TMatrix4} A 4x4 perspective projection matrix.
|
|
446
458
|
*
|
|
447
459
|
* @throws {Error} If parameters are invalid.
|
|
448
460
|
*
|
|
449
461
|
* @example
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
462
|
+
* ```typescript
|
|
463
|
+
* ```typescript
|
|
464
|
+
* const perspectiveMatrix = MatrixPerspective(
|
|
465
|
+
* Math.PI / 4, // 45-degree field of view
|
|
466
|
+
* 16 / 9, // Widescreen aspect ratio
|
|
467
|
+
* 0.1, // Near plane
|
|
468
|
+
* 1000 // Far plane
|
|
469
|
+
* );
|
|
470
|
+
* ```
|
|
471
|
+
* ```
|
|
458
472
|
*/
|
|
459
|
-
export declare function MatrixPerspective(fovY: number, aspect: number, near: number, far: number):
|
|
473
|
+
export declare function MatrixPerspective(fovY: number, aspect: number, near: number, far: number): TMatrix4;
|
|
460
474
|
/**
|
|
461
475
|
* Creates an orthographic projection matrix for 3D rendering.
|
|
462
476
|
* Maps a rectangular box to the unit cube [-1, 1]³ without perspective distortion.
|
|
@@ -467,18 +481,20 @@ export declare function MatrixPerspective(fovY: number, aspect: number, near: nu
|
|
|
467
481
|
* @param top - Top boundary of the orthographic volume.
|
|
468
482
|
* @param near - Near clipping plane distance.
|
|
469
483
|
* @param far - Far clipping plane distance.
|
|
470
|
-
* @returns {
|
|
484
|
+
* @returns {TMatrix4} A 4x4 orthographic projection matrix.
|
|
471
485
|
*
|
|
472
486
|
* @throws {Error} If any opposing boundaries are equal.
|
|
473
487
|
*
|
|
474
488
|
* @example
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
489
|
+
* ```typescript
|
|
490
|
+
* ```typescript
|
|
491
|
+
* const orthoMatrix = MatrixOrthographic(
|
|
492
|
+
* -10, 10, // Left/Right: 20 units wide
|
|
493
|
+
* -7.5, 7.5, // Bottom/Top: 15 units tall
|
|
494
|
+
* -100, 100 // Near/Far: 200 units deep
|
|
495
|
+
* );
|
|
496
|
+
* ```
|
|
497
|
+
* ```
|
|
482
498
|
*/
|
|
483
|
-
export declare function MatrixOrthographic(left: number, right: number, bottom: number, top: number, near: number, far: number):
|
|
499
|
+
export declare function MatrixOrthographic(left: number, right: number, bottom: number, top: number, near: number, far: number): TMatrix4;
|
|
484
500
|
//# sourceMappingURL=transformations.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transformations.d.ts","sourceRoot":"","sources":["../../src/matrices/transformations.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"transformations.d.ts","sourceRoot":"","sources":["../../src/matrices/transformations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAMH,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAY,MAAM,qBAAqB,CAAC;AAUnE;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,QAAQ,CAU1D;AAMD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,QAAQ,CAW9D;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,QAAQ,CAW/D;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,QAAQ,CAW7D;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,QAAQ,CAAC;AAErF,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;AAwBxD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,G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