@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.
- package/README.md +15 -21
- package/build/angles.d.ts +28 -18
- package/build/angles.d.ts.map +1 -1
- package/build/angles.js +28 -18
- package/build/angles.js.map +1 -1
- package/build/clamp.d.ts +2 -0
- package/build/clamp.d.ts.map +1 -1
- package/build/clamp.js +2 -0
- package/build/clamp.js.map +1 -1
- package/build/core.d.ts +23 -0
- package/build/core.d.ts.map +1 -0
- package/build/core.js +25 -0
- package/build/core.js.map +1 -0
- package/build/index.d.ts +1 -4
- package/build/index.d.ts.map +1 -1
- package/build/index.js +1 -6
- package/build/index.js.map +1 -1
- package/build/interpolation.d.ts +62 -13
- package/build/interpolation.d.ts.map +1 -1
- package/build/interpolation.js +66 -23
- package/build/interpolation.js.map +1 -1
- package/build/matrices/arithmetic.d.ts +65 -76
- package/build/matrices/arithmetic.d.ts.map +1 -1
- package/build/matrices/arithmetic.js +65 -107
- package/build/matrices/arithmetic.js.map +1 -1
- package/build/matrices/asserts.d.ts +26 -273
- package/build/matrices/asserts.d.ts.map +1 -1
- package/build/matrices/asserts.js +106 -350
- package/build/matrices/asserts.js.map +1 -1
- package/build/matrices/core.d.ts +150 -79
- package/build/matrices/core.d.ts.map +1 -1
- package/build/matrices/core.js +128 -104
- package/build/matrices/core.js.map +1 -1
- package/build/matrices/decompositions.d.ts +41 -44
- package/build/matrices/decompositions.d.ts.map +1 -1
- package/build/matrices/decompositions.js +51 -94
- package/build/matrices/decompositions.js.map +1 -1
- package/build/matrices/index.d.ts +2 -2
- package/build/matrices/index.d.ts.map +1 -1
- package/build/matrices/index.js +2 -2
- package/build/matrices/index.js.map +1 -1
- package/build/matrices/linear-algebra.d.ts +56 -19
- package/build/matrices/linear-algebra.d.ts.map +1 -1
- package/build/matrices/linear-algebra.js +80 -36
- package/build/matrices/linear-algebra.js.map +1 -1
- package/build/matrices/normalization.d.ts +36 -15
- package/build/matrices/normalization.d.ts.map +1 -1
- package/build/matrices/normalization.js +32 -23
- package/build/matrices/normalization.js.map +1 -1
- package/build/matrices/transformations.d.ts +39 -52
- package/build/matrices/transformations.d.ts.map +1 -1
- package/build/matrices/transformations.js +8 -11
- package/build/matrices/transformations.js.map +1 -1
- package/build/matrices/types.d.ts +39 -67
- package/build/matrices/types.d.ts.map +1 -1
- package/build/matrices/types.js +63 -1
- package/build/matrices/types.js.map +1 -1
- package/build/quaternions/asserts.d.ts +114 -15
- package/build/quaternions/asserts.d.ts.map +1 -1
- package/build/quaternions/asserts.js +189 -51
- package/build/quaternions/asserts.js.map +1 -1
- package/build/quaternions/conversions.d.ts +18 -8
- package/build/quaternions/conversions.d.ts.map +1 -1
- package/build/quaternions/conversions.js +14 -4
- package/build/quaternions/conversions.js.map +1 -1
- package/build/quaternions/core.d.ts +31 -2
- package/build/quaternions/core.d.ts.map +1 -1
- package/build/quaternions/core.js +32 -4
- package/build/quaternions/core.js.map +1 -1
- package/build/quaternions/index.d.ts +2 -2
- package/build/quaternions/index.d.ts.map +1 -1
- package/build/quaternions/index.js +3 -2
- package/build/quaternions/index.js.map +1 -1
- package/build/quaternions/interpolation.d.ts +7 -1
- package/build/quaternions/interpolation.d.ts.map +1 -1
- package/build/quaternions/interpolation.js +12 -6
- package/build/quaternions/interpolation.js.map +1 -1
- package/build/quaternions/predefined.d.ts +7 -1
- package/build/quaternions/predefined.d.ts.map +1 -1
- package/build/quaternions/predefined.js +6 -0
- package/build/quaternions/predefined.js.map +1 -1
- package/build/quaternions/types.d.ts +24 -13
- package/build/quaternions/types.d.ts.map +1 -1
- package/build/quaternions/types.js +51 -1
- package/build/quaternions/types.js.map +1 -1
- package/build/random.d.ts +66 -20
- package/build/random.d.ts.map +1 -1
- package/build/random.js +73 -20
- package/build/random.js.map +1 -1
- package/build/vectors/asserts.d.ts +33 -99
- package/build/vectors/asserts.d.ts.map +1 -1
- package/build/vectors/asserts.js +145 -181
- package/build/vectors/asserts.js.map +1 -1
- package/build/vectors/core.d.ts +76 -44
- package/build/vectors/core.d.ts.map +1 -1
- package/build/vectors/core.js +128 -119
- package/build/vectors/core.js.map +1 -1
- package/build/vectors/index.d.ts.map +1 -1
- package/build/vectors/index.js +1 -0
- package/build/vectors/index.js.map +1 -1
- package/build/vectors/interpolation.d.ts +13 -1
- package/build/vectors/interpolation.d.ts.map +1 -1
- package/build/vectors/interpolation.js +48 -47
- package/build/vectors/interpolation.js.map +1 -1
- package/build/vectors/predefined.d.ts +73 -25
- package/build/vectors/predefined.d.ts.map +1 -1
- package/build/vectors/predefined.js +62 -18
- package/build/vectors/predefined.js.map +1 -1
- package/build/vectors/types.d.ts +26 -4
- package/build/vectors/types.d.ts.map +1 -1
- package/build/vectors/types.js +50 -1
- package/build/vectors/types.js.map +1 -1
- package/package.json +4 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AssertMatrix,
|
|
1
|
+
import { AssertMatrix, MatrixError } from './asserts.js';
|
|
2
2
|
import { MatrixSize } from './core.js';
|
|
3
3
|
import { MatrixSVD } from './decompositions.js';
|
|
4
4
|
/**
|
|
@@ -6,7 +6,10 @@ import { MatrixSVD } from './decompositions.js';
|
|
|
6
6
|
* @param matrix - The input matrix (any dimensions)
|
|
7
7
|
* @returns {number} The Frobenius norm (always non-negative)
|
|
8
8
|
* @throws {Error} If the matrix contains invalid values
|
|
9
|
-
* @example
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* MatrixFrobeniusNorm([[3, 4], [0, 0]]) // 5 (sqrt(3² + 4²))
|
|
12
|
+
* ```
|
|
10
13
|
*/
|
|
11
14
|
export function MatrixFrobeniusNorm(matrix) {
|
|
12
15
|
AssertMatrix(matrix);
|
|
@@ -14,10 +17,8 @@ export function MatrixFrobeniusNorm(matrix) {
|
|
|
14
17
|
let sum = 0;
|
|
15
18
|
for (let row = 0; row < rows; row++) {
|
|
16
19
|
const matrixRow = matrix[row];
|
|
17
|
-
AssertMatrixRow(matrixRow, { rowIndex: row });
|
|
18
20
|
for (let col = 0; col < cols; col++) {
|
|
19
21
|
const val = matrixRow[col];
|
|
20
|
-
AssertMatrixValue(val, { rowIndex: row, columnIndex: col });
|
|
21
22
|
// Add square of each element to the sum
|
|
22
23
|
sum += val * val;
|
|
23
24
|
}
|
|
@@ -30,7 +31,10 @@ export function MatrixFrobeniusNorm(matrix) {
|
|
|
30
31
|
* @param matrix - The input matrix
|
|
31
32
|
* @returns {number} The spectral norm (always non-negative)
|
|
32
33
|
* @throws {Error} If the matrix contains invalid values
|
|
33
|
-
* @example
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
* MatrixSpectralNorm([[3, 0], [0, 4]]) // 4 (largest singular value)
|
|
37
|
+
* ```
|
|
34
38
|
*/
|
|
35
39
|
export function MatrixSpectralNorm(matrix) {
|
|
36
40
|
AssertMatrix(matrix);
|
|
@@ -47,7 +51,10 @@ export function MatrixSpectralNorm(matrix) {
|
|
|
47
51
|
* @param matrix - The input matrix
|
|
48
52
|
* @returns {number} The 1-norm (always non-negative)
|
|
49
53
|
* @throws {Error} If the matrix contains invalid values
|
|
50
|
-
* @example
|
|
54
|
+
* @example
|
|
55
|
+
* ```typescript
|
|
56
|
+
* Matrix1Norm([[1, 2], [3, 4]]) // 6 (max of column sums: 4, 6)
|
|
57
|
+
* ```
|
|
51
58
|
*/
|
|
52
59
|
export function Matrix1Norm(matrix) {
|
|
53
60
|
AssertMatrix(matrix);
|
|
@@ -59,9 +66,7 @@ export function Matrix1Norm(matrix) {
|
|
|
59
66
|
// Sum absolute values in this column
|
|
60
67
|
for (let row = 0; row < rows; row++) {
|
|
61
68
|
const matrixRow = matrix[row];
|
|
62
|
-
AssertMatrixRow(matrixRow, { rowIndex: row });
|
|
63
69
|
const val = matrixRow[col];
|
|
64
|
-
AssertMatrixValue(val, { rowIndex: row, columnIndex: col });
|
|
65
70
|
columnSum += Math.abs(val);
|
|
66
71
|
}
|
|
67
72
|
maxColumnSum = Math.max(maxColumnSum, columnSum);
|
|
@@ -73,7 +78,10 @@ export function Matrix1Norm(matrix) {
|
|
|
73
78
|
* @param matrix - The input matrix
|
|
74
79
|
* @returns {number} The infinity norm (always non-negative)
|
|
75
80
|
* @throws {Error} If the matrix contains invalid values
|
|
76
|
-
* @example
|
|
81
|
+
* @example
|
|
82
|
+
* ```typescript
|
|
83
|
+
* MatrixInfinityNorm([[1, 2], [3, 4]]) // 7 (max of row sums: 3, 7)
|
|
84
|
+
* ```
|
|
77
85
|
*/
|
|
78
86
|
export function MatrixInfinityNorm(matrix) {
|
|
79
87
|
AssertMatrix(matrix);
|
|
@@ -82,12 +90,10 @@ export function MatrixInfinityNorm(matrix) {
|
|
|
82
90
|
// Iterate through each row
|
|
83
91
|
for (let row = 0; row < rows; row++) {
|
|
84
92
|
const matrixRow = matrix[row];
|
|
85
|
-
AssertMatrixRow(matrixRow, { rowIndex: row });
|
|
86
93
|
let rowSum = 0;
|
|
87
94
|
// Sum absolute values in this row
|
|
88
95
|
for (let col = 0; col < cols; col++) {
|
|
89
96
|
const val = matrixRow[col];
|
|
90
|
-
AssertMatrixValue(val, { rowIndex: row, columnIndex: col });
|
|
91
97
|
rowSum += Math.abs(val);
|
|
92
98
|
}
|
|
93
99
|
maxRowSum = Math.max(maxRowSum, rowSum);
|
|
@@ -100,7 +106,10 @@ export function MatrixInfinityNorm(matrix) {
|
|
|
100
106
|
* @param matrix - The input matrix
|
|
101
107
|
* @returns {number} The nuclear norm (always non-negative)
|
|
102
108
|
* @throws {Error} If the matrix contains invalid values
|
|
103
|
-
* @example
|
|
109
|
+
* @example
|
|
110
|
+
* ```typescript
|
|
111
|
+
* MatrixNuclearNorm([[3, 0], [0, 4]]) // 7 (sum of singular values: 3 + 4)
|
|
112
|
+
* ```
|
|
104
113
|
*/
|
|
105
114
|
export function MatrixNuclearNorm(matrix) {
|
|
106
115
|
AssertMatrix(matrix);
|
|
@@ -118,7 +127,10 @@ export function MatrixNuclearNorm(matrix) {
|
|
|
118
127
|
* @param matrix - The input matrix
|
|
119
128
|
* @returns {number} The max norm (always non-negative)
|
|
120
129
|
* @throws {Error} If the matrix contains invalid values
|
|
121
|
-
* @example
|
|
130
|
+
* @example
|
|
131
|
+
* ```typescript
|
|
132
|
+
* MatrixMaxNorm([[1, -5], [3, 2]]) // 5 (max absolute value)
|
|
133
|
+
* ```
|
|
122
134
|
*/
|
|
123
135
|
export function MatrixMaxNorm(matrix) {
|
|
124
136
|
AssertMatrix(matrix);
|
|
@@ -126,10 +138,8 @@ export function MatrixMaxNorm(matrix) {
|
|
|
126
138
|
let maxValue = 0;
|
|
127
139
|
for (let row = 0; row < rows; row++) {
|
|
128
140
|
const matrixRow = matrix[row];
|
|
129
|
-
AssertMatrixRow(matrixRow, { rowIndex: row });
|
|
130
141
|
for (let col = 0; col < cols; col++) {
|
|
131
142
|
const val = matrixRow[col];
|
|
132
|
-
AssertMatrixValue(val, { rowIndex: row, columnIndex: col });
|
|
133
143
|
maxValue = Math.max(maxValue, Math.abs(val));
|
|
134
144
|
}
|
|
135
145
|
}
|
|
@@ -141,24 +151,23 @@ export function MatrixMaxNorm(matrix) {
|
|
|
141
151
|
* @param p - The norm parameter (must be >= 1)
|
|
142
152
|
* @returns {number} The p-norm (always non-negative)
|
|
143
153
|
* @throws {Error} If the matrix contains invalid values or p < 1
|
|
144
|
-
* @example
|
|
154
|
+
* @example
|
|
155
|
+
* ```typescript
|
|
156
|
+
* MatrixPNorm([[1, 2], [3, 4]], 1) // 10 (sum of absolute values)
|
|
157
|
+
* ```
|
|
145
158
|
*/
|
|
146
159
|
export function MatrixPNorm(matrix, p) {
|
|
147
160
|
AssertMatrix(matrix);
|
|
148
|
-
if (p < 1)
|
|
149
|
-
throw new
|
|
150
|
-
|
|
151
|
-
if (p === Infinity) {
|
|
161
|
+
if (p < 1)
|
|
162
|
+
throw new MatrixError('p-norm parameter must be >= 1');
|
|
163
|
+
if (p === Infinity)
|
|
152
164
|
return MatrixMaxNorm(matrix);
|
|
153
|
-
}
|
|
154
165
|
const [rows, cols] = MatrixSize(matrix);
|
|
155
166
|
let sum = 0;
|
|
156
167
|
for (let row = 0; row < rows; row++) {
|
|
157
168
|
const matrixRow = matrix[row];
|
|
158
|
-
AssertMatrixRow(matrixRow, { rowIndex: row });
|
|
159
169
|
for (let col = 0; col < cols; col++) {
|
|
160
170
|
const val = matrixRow[col];
|
|
161
|
-
AssertMatrixValue(val, { rowIndex: row, columnIndex: col });
|
|
162
171
|
sum += Math.pow(Math.abs(val), p);
|
|
163
172
|
}
|
|
164
173
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normalization.js","sourceRoot":"","sources":["../../src/matrices/normalization.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"normalization.js","sourceRoot":"","sources":["../../src/matrices/normalization.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAGhD;;;;;;;;;GASG;AACH,MAAM,UAAU,mBAAmB,CAAC,MAAe;IAClD,YAAY,CAAC,MAAM,CAAC,CAAC;IAErB,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC;IACxC,IAAI,GAAG,GAAG,CAAC,CAAC;IAEZ,KAAK,IAAI,GAAG,GAAG,CAAC,EAAE,GAAG,GAAG,IAAI,EAAE,GAAG,EAAE,EAAE,CAAC;QACrC,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;QAE9B,KAAK,IAAI,GAAG,GAAG,CAAC,EAAE,GAAG,GAAG,IAAI,EAAE,GAAG,EAAE,EAAE,CAAC;YACrC,MAAM,GAAG,GAAG,SAAS,CAAC,GAAG,CAAC,C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E,EAAE,CAAC;QACrC,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;QAE9B,KAAK,IAAI,GAAG,GAAG,CAAC,EAAE,GAAG,GAAG,IAAI,EAAE,GAAG,EAAE,EAAE,CAAC;YACrC,MAAM,GAAG,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC;YAC3B,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;QACnC,CAAC;IACF,CAAC;IAED,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;AAC7B,CAAC"}
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
* All matrices use homogeneous coordinates for consistent transformation composition.
|
|
14
14
|
* 2D transformations use 3x3 matrices, 3D transformations use 4x4 matrices.
|
|
15
15
|
*/
|
|
16
|
-
import {
|
|
17
|
-
import { TVector2, TVector3 } from '../vectors/types.js';
|
|
16
|
+
import type { TMatrix3, TMatrix4 } from './types.js';
|
|
17
|
+
import type { TVector2, TVector3 } from '../vectors/types.js';
|
|
18
18
|
/**
|
|
19
19
|
* Creates a 2D rotation matrix for rotating points around the origin.
|
|
20
20
|
*
|
|
@@ -30,7 +30,7 @@ import { TVector2, TVector3 } from '../vectors/types.js';
|
|
|
30
30
|
* ```
|
|
31
31
|
*
|
|
32
32
|
* @param radians - Rotation angle in radians (positive = counterclockwise)
|
|
33
|
-
* @returns {
|
|
33
|
+
* @returns {TMatrix3} A 3x3 rotation matrix for 2D transformations
|
|
34
34
|
*
|
|
35
35
|
* @throws {Error} If radians is not a finite number
|
|
36
36
|
*
|
|
@@ -38,12 +38,11 @@ import { TVector2, TVector3 } from '../vectors/types.js';
|
|
|
38
38
|
* ```typescript
|
|
39
39
|
* // 90-degree counterclockwise rotation
|
|
40
40
|
* const matrix = MatrixRotation2D(Math.PI / 2);
|
|
41
|
-
*
|
|
42
41
|
* // 45-degree clockwise rotation
|
|
43
42
|
* const clockwise = MatrixRotation2D(-Math.PI / 4);
|
|
44
43
|
* ```
|
|
45
44
|
*/
|
|
46
|
-
export declare function MatrixRotation2D(radians: number):
|
|
45
|
+
export declare function MatrixRotation2D(radians: number): TMatrix3;
|
|
47
46
|
/**
|
|
48
47
|
* Creates a 3D roll rotation matrix (rotation around the X-axis).
|
|
49
48
|
*
|
|
@@ -60,7 +59,7 @@ export declare function MatrixRotation2D(radians: number): IMatrix3;
|
|
|
60
59
|
* ```
|
|
61
60
|
*
|
|
62
61
|
* @param radians - Roll angle in radians (positive = right-hand rule around X-axis)
|
|
63
|
-
* @returns {
|
|
62
|
+
* @returns {TMatrix4} A 4x4 roll rotation matrix
|
|
64
63
|
*
|
|
65
64
|
* @throws {Error} If radians is not a finite number
|
|
66
65
|
*
|
|
@@ -70,7 +69,7 @@ export declare function MatrixRotation2D(radians: number): IMatrix3;
|
|
|
70
69
|
* const rollMatrix = MatrixRotation3DRoll(Math.PI / 4);
|
|
71
70
|
* ```
|
|
72
71
|
*/
|
|
73
|
-
export declare function MatrixRotation3DRoll(radians: number):
|
|
72
|
+
export declare function MatrixRotation3DRoll(radians: number): TMatrix4;
|
|
74
73
|
/**
|
|
75
74
|
* Creates a 3D pitch rotation matrix (rotation around the Y-axis).
|
|
76
75
|
*
|
|
@@ -87,7 +86,7 @@ export declare function MatrixRotation3DRoll(radians: number): IMatrix4;
|
|
|
87
86
|
* ```
|
|
88
87
|
*
|
|
89
88
|
* @param radians - Pitch angle in radians (positive = nose up in aviation)
|
|
90
|
-
* @returns {
|
|
89
|
+
* @returns {TMatrix4} A 4x4 pitch rotation matrix
|
|
91
90
|
*
|
|
92
91
|
* @throws {Error} If radians is not a finite number
|
|
93
92
|
*
|
|
@@ -97,7 +96,7 @@ export declare function MatrixRotation3DRoll(radians: number): IMatrix4;
|
|
|
97
96
|
* const pitchMatrix = MatrixRotation3DPitch(Math.PI / 6);
|
|
98
97
|
* ```
|
|
99
98
|
*/
|
|
100
|
-
export declare function MatrixRotation3DPitch(radians: number):
|
|
99
|
+
export declare function MatrixRotation3DPitch(radians: number): TMatrix4;
|
|
101
100
|
/**
|
|
102
101
|
* Creates a 3D yaw rotation matrix (rotation around the Z-axis).
|
|
103
102
|
*
|
|
@@ -114,7 +113,7 @@ export declare function MatrixRotation3DPitch(radians: number): IMatrix4;
|
|
|
114
113
|
* ```
|
|
115
114
|
*
|
|
116
115
|
* @param radians - Yaw angle in radians (positive = turn left in aviation)
|
|
117
|
-
* @returns {
|
|
116
|
+
* @returns {TMatrix4} A 4x4 yaw rotation matrix
|
|
118
117
|
*
|
|
119
118
|
* @throws {Error} If radians is not a finite number
|
|
120
119
|
*
|
|
@@ -124,7 +123,7 @@ export declare function MatrixRotation3DPitch(radians: number): IMatrix4;
|
|
|
124
123
|
* const yawMatrix = MatrixRotation3DYaw(Math.PI / 3);
|
|
125
124
|
* ```
|
|
126
125
|
*/
|
|
127
|
-
export declare function MatrixRotation3DYaw(radians: number):
|
|
126
|
+
export declare function MatrixRotation3DYaw(radians: number): TMatrix4;
|
|
128
127
|
/**
|
|
129
128
|
* Creates a composite 3D rotation matrix from yaw, pitch, and roll components.
|
|
130
129
|
*
|
|
@@ -139,7 +138,7 @@ export declare function MatrixRotation3DYaw(radians: number): IMatrix4;
|
|
|
139
138
|
* @param roll - Roll angle in radians (X-axis rotation) or vector [roll, pitch, yaw]
|
|
140
139
|
* @param pitch - Pitch angle in radians (Y-axis rotation, required if roll is number)
|
|
141
140
|
* @param yaw - Yaw angle in radians (Z-axis rotation, required if roll is number)
|
|
142
|
-
* @returns {
|
|
141
|
+
* @returns {TMatrix4} A 4x4 composite rotation matrix
|
|
143
142
|
*
|
|
144
143
|
* @throws {Error} If any angle is not a finite number
|
|
145
144
|
*
|
|
@@ -147,14 +146,13 @@ export declare function MatrixRotation3DYaw(radians: number): IMatrix4;
|
|
|
147
146
|
* ```typescript
|
|
148
147
|
* // Using individual angles (banking, elevation, heading)
|
|
149
148
|
* const rotationMatrix = MatrixRotation3D(0.1, 0.2, 0.3);
|
|
150
|
-
*
|
|
151
149
|
* // Using vector input
|
|
152
150
|
* const eulerAngles: TVector3 = [0.1, 0.2, 0.3];
|
|
153
151
|
* const rotationMatrix2 = MatrixRotation3D(eulerAngles);
|
|
154
152
|
* ```
|
|
155
153
|
*/
|
|
156
|
-
export declare function MatrixRotation3D(roll: number, pitch: number, yaw: number):
|
|
157
|
-
export declare function MatrixRotation3D(v: TVector3):
|
|
154
|
+
export declare function MatrixRotation3D(roll: number, pitch: number, yaw: number): TMatrix4;
|
|
155
|
+
export declare function MatrixRotation3D(v: TVector3): TMatrix4;
|
|
158
156
|
/**
|
|
159
157
|
* Creates a composite 3D rotation matrix from Euler angles specified in degrees.
|
|
160
158
|
*
|
|
@@ -167,7 +165,7 @@ export declare function MatrixRotation3D(v: TVector3): IMatrix4;
|
|
|
167
165
|
* @param roll - Roll angle in degrees (X-axis rotation) or vector [roll, pitch, yaw]
|
|
168
166
|
* @param pitch - Pitch angle in degrees (Y-axis rotation, required if roll is number)
|
|
169
167
|
* @param yaw - Yaw angle in degrees (Z-axis rotation, required if roll is number)
|
|
170
|
-
* @returns {
|
|
168
|
+
* @returns {TMatrix4} A 4x4 composite rotation matrix
|
|
171
169
|
*
|
|
172
170
|
* @throws {Error} If any angle is not a finite number
|
|
173
171
|
*
|
|
@@ -175,14 +173,13 @@ export declare function MatrixRotation3D(v: TVector3): IMatrix4;
|
|
|
175
173
|
* ```typescript
|
|
176
174
|
* // Using individual angles in degrees
|
|
177
175
|
* const rotation = MatrixRotation3DEulerAngles(45, 30, 60);
|
|
178
|
-
*
|
|
179
176
|
* // Using vector input in degrees
|
|
180
177
|
* const angles: TVector3 = [45, 30, 60];
|
|
181
178
|
* const rotation2 = MatrixRotation3DEulerAngles(angles);
|
|
182
179
|
* ```
|
|
183
180
|
*/
|
|
184
|
-
export declare function MatrixRotation3DEulerAngles(roll: number, pitch: number, yaw: number):
|
|
185
|
-
export declare function MatrixRotation3DEulerAngles(v: TVector3):
|
|
181
|
+
export declare function MatrixRotation3DEulerAngles(roll: number, pitch: number, yaw: number): TMatrix4;
|
|
182
|
+
export declare function MatrixRotation3DEulerAngles(v: TVector3): TMatrix4;
|
|
186
183
|
/**
|
|
187
184
|
* Creates a 2D scale transformation matrix with flexible input options.
|
|
188
185
|
*
|
|
@@ -204,7 +201,7 @@ export declare function MatrixRotation3DEulerAngles(v: TVector3): IMatrix4;
|
|
|
204
201
|
*
|
|
205
202
|
* @param scale - Uniform scale factor for both axes, OR X-axis scale factor
|
|
206
203
|
* @param y - Y-axis scale factor (only for independent scaling)
|
|
207
|
-
* @returns {
|
|
204
|
+
* @returns {TMatrix3} A 3x3 scale transformation matrix
|
|
208
205
|
*
|
|
209
206
|
* @throws {Error} If any scale factor is not a finite number
|
|
210
207
|
*
|
|
@@ -212,21 +209,18 @@ export declare function MatrixRotation3DEulerAngles(v: TVector3): IMatrix4;
|
|
|
212
209
|
* ```typescript
|
|
213
210
|
* // Uniform scaling (double size)
|
|
214
211
|
* const uniform = MatrixScale2D(2.0);
|
|
215
|
-
*
|
|
216
212
|
* // Independent scaling (stretch horizontally, compress vertically)
|
|
217
213
|
* const stretch = MatrixScale2D(2.0, 0.5);
|
|
218
|
-
*
|
|
219
214
|
* // Vector input
|
|
220
215
|
* const scaleVector: TVector2 = [1.5, 0.8];
|
|
221
216
|
* const vectorScale = MatrixScale2D(scaleVector);
|
|
222
|
-
*
|
|
223
217
|
* // Flip horizontally
|
|
224
218
|
* const flip = MatrixScale2D(-1, 1);
|
|
225
219
|
* ```
|
|
226
220
|
*/
|
|
227
|
-
export declare function MatrixScale2D(scale: number):
|
|
228
|
-
export declare function MatrixScale2D(x: number, y: number):
|
|
229
|
-
export declare function MatrixScale2D(v: TVector2):
|
|
221
|
+
export declare function MatrixScale2D(scale: number): TMatrix3;
|
|
222
|
+
export declare function MatrixScale2D(x: number, y: number): TMatrix3;
|
|
223
|
+
export declare function MatrixScale2D(v: TVector2): TMatrix3;
|
|
230
224
|
/**
|
|
231
225
|
* Creates a 3D scale transformation matrix with flexible input options.
|
|
232
226
|
*
|
|
@@ -250,7 +244,7 @@ export declare function MatrixScale2D(v: TVector2): IMatrix3;
|
|
|
250
244
|
* @param scale - Uniform scale factor for all axes, OR X-axis scale factor
|
|
251
245
|
* @param y - Y-axis scale factor (only for independent scaling)
|
|
252
246
|
* @param z - Z-axis scale factor (only for independent scaling)
|
|
253
|
-
* @returns {
|
|
247
|
+
* @returns {TMatrix4} A 4x4 scale transformation matrix
|
|
254
248
|
*
|
|
255
249
|
* @throws {Error} If any scale factor is not a finite number
|
|
256
250
|
*
|
|
@@ -258,21 +252,18 @@ export declare function MatrixScale2D(v: TVector2): IMatrix3;
|
|
|
258
252
|
* ```typescript
|
|
259
253
|
* // Uniform scaling (triple size)
|
|
260
254
|
* const uniform = MatrixScale3D(3.0);
|
|
261
|
-
*
|
|
262
255
|
* // Independent scaling (stretch, compress, normal)
|
|
263
256
|
* const stretch = MatrixScale3D(2.0, 0.5, 1.0);
|
|
264
|
-
*
|
|
265
257
|
* // Vector input
|
|
266
258
|
* const scaleVector: TVector3 = [1.5, 0.8, 2.0];
|
|
267
259
|
* const vectorScale = MatrixScale3D(scaleVector);
|
|
268
|
-
*
|
|
269
260
|
* // Mirror across XY plane
|
|
270
261
|
* const mirror = MatrixScale3D(1, 1, -1);
|
|
271
262
|
* ```
|
|
272
263
|
*/
|
|
273
|
-
export declare function MatrixScale3D(scale: number):
|
|
274
|
-
export declare function MatrixScale3D(x: number, y: number, z: number):
|
|
275
|
-
export declare function MatrixScale3D(v: TVector3):
|
|
264
|
+
export declare function MatrixScale3D(scale: number): TMatrix4;
|
|
265
|
+
export declare function MatrixScale3D(x: number, y: number, z: number): TMatrix4;
|
|
266
|
+
export declare function MatrixScale3D(v: TVector3): TMatrix4;
|
|
276
267
|
/**
|
|
277
268
|
* Creates a 2D translation transformation matrix.
|
|
278
269
|
*
|
|
@@ -287,7 +278,7 @@ export declare function MatrixScale3D(v: TVector3): IMatrix4;
|
|
|
287
278
|
* ```
|
|
288
279
|
*
|
|
289
280
|
* @param v - Translation vector [x, y] containing offset distances
|
|
290
|
-
* @returns {
|
|
281
|
+
* @returns {TMatrix3} A 3x3 translation transformation matrix
|
|
291
282
|
*
|
|
292
283
|
* @throws {Error} If the input is not a valid 2D vector
|
|
293
284
|
*
|
|
@@ -295,13 +286,12 @@ export declare function MatrixScale3D(v: TVector3): IMatrix4;
|
|
|
295
286
|
* ```typescript
|
|
296
287
|
* // Move 10 units right, 5 units up
|
|
297
288
|
* const translation = MatrixTranslation2D(10, 5);
|
|
298
|
-
*
|
|
299
289
|
* // Using vector input
|
|
300
290
|
* const offset: TVector2 = [10, 5];
|
|
301
291
|
* const translation2 = MatrixTranslation2D(...offset);
|
|
302
292
|
* ```
|
|
303
293
|
*/
|
|
304
|
-
export declare function MatrixTranslation2D(...v: TVector2):
|
|
294
|
+
export declare function MatrixTranslation2D(...v: TVector2): TMatrix3;
|
|
305
295
|
/**
|
|
306
296
|
* Creates a 3D translation transformation matrix with flexible input options.
|
|
307
297
|
*
|
|
@@ -324,7 +314,7 @@ export declare function MatrixTranslation2D(...v: TVector2): IMatrix3;
|
|
|
324
314
|
* @param translationOrX - Uniform translation distance for all axes, OR X-axis distance
|
|
325
315
|
* @param y - Y-axis translation distance (only for independent translation)
|
|
326
316
|
* @param z - Z-axis translation distance (only for independent translation)
|
|
327
|
-
* @returns {
|
|
317
|
+
* @returns {TMatrix4} A 4x4 translation transformation matrix
|
|
328
318
|
*
|
|
329
319
|
* @throws {Error} If any translation distance is not a finite number
|
|
330
320
|
*
|
|
@@ -332,18 +322,16 @@ export declare function MatrixTranslation2D(...v: TVector2): IMatrix3;
|
|
|
332
322
|
* ```typescript
|
|
333
323
|
* // Uniform translation (move 5 units in all directions)
|
|
334
324
|
* const uniform = MatrixTranslation3D(5.0);
|
|
335
|
-
*
|
|
336
325
|
* // Independent translation
|
|
337
326
|
* const independent = MatrixTranslation3D(10, -5, 3);
|
|
338
|
-
*
|
|
339
327
|
* // Vector input
|
|
340
328
|
* const offset: TVector3 = [10, -5, 3];
|
|
341
329
|
* const vectorTranslation = MatrixTranslation3D(...offset);
|
|
342
330
|
* ```
|
|
343
331
|
*/
|
|
344
|
-
export declare function MatrixTranslation3D(translation: number):
|
|
345
|
-
export declare function MatrixTranslation3D(x: number, y: number, z: number):
|
|
346
|
-
export declare function MatrixTranslation3D(v: TVector3):
|
|
332
|
+
export declare function MatrixTranslation3D(translation: number): TMatrix4;
|
|
333
|
+
export declare function MatrixTranslation3D(x: number, y: number, z: number): TMatrix4;
|
|
334
|
+
export declare function MatrixTranslation3D(v: TVector3): TMatrix4;
|
|
347
335
|
/**
|
|
348
336
|
* Transforms a 2D vector using a 3x3 transformation matrix with homogeneous coordinates.
|
|
349
337
|
*
|
|
@@ -369,7 +357,6 @@ export declare function MatrixTranslation3D(v: TVector3): IMatrix4;
|
|
|
369
357
|
* const point: TVector2 = [1, 0];
|
|
370
358
|
* const rotatedPoint = MatrixTransform2D(point, rotationMatrix);
|
|
371
359
|
* // Result: approximately [0, 1]
|
|
372
|
-
*
|
|
373
360
|
* // Chain multiple transformations
|
|
374
361
|
* const scale = MatrixScale2D(2, 2);
|
|
375
362
|
* const translate = MatrixTranslation2D(5, 3);
|
|
@@ -377,7 +364,7 @@ export declare function MatrixTranslation3D(v: TVector3): IMatrix4;
|
|
|
377
364
|
* const transformedPoint = MatrixTransform2D(point, combined);
|
|
378
365
|
* ```
|
|
379
366
|
*/
|
|
380
|
-
export declare function MatrixTransform2D(vector: TVector2, matrix:
|
|
367
|
+
export declare function MatrixTransform2D(vector: TVector2, matrix: TMatrix3): TVector2;
|
|
381
368
|
/**
|
|
382
369
|
* Transforms a 3D vector using a 4x4 transformation matrix with homogeneous coordinates.
|
|
383
370
|
* Converts to homogeneous coordinates, applies transformation, then converts back to 3D.
|
|
@@ -395,7 +382,7 @@ export declare function MatrixTransform2D(vector: TVector2, matrix: IMatrix3): T
|
|
|
395
382
|
* const rotatedPoint = MatrixTransform3D(point, rotationMatrix);
|
|
396
383
|
* ```
|
|
397
384
|
*/
|
|
398
|
-
export declare function MatrixTransform3D(vector: TVector3, transform:
|
|
385
|
+
export declare function MatrixTransform3D(vector: TVector3, transform: TMatrix4): TVector3;
|
|
399
386
|
/**
|
|
400
387
|
* Transforms a 3D direction vector using a 3x3 matrix, ignoring translation components.
|
|
401
388
|
* Designed for direction vectors (normals, velocities) where translation should not apply.
|
|
@@ -411,7 +398,7 @@ export declare function MatrixTransform3D(vector: TVector3, transform: IMatrix4)
|
|
|
411
398
|
* const rotatedNormal = MatrixDirection3D(normal, rotationMatrix);
|
|
412
399
|
* ```
|
|
413
400
|
*/
|
|
414
|
-
export declare function MatrixDirection3D(direction: TVector3, matrix:
|
|
401
|
+
export declare function MatrixDirection3D(direction: TVector3, matrix: TMatrix3): TVector3;
|
|
415
402
|
/**
|
|
416
403
|
* Creates a view matrix for positioning and orienting a 3D camera.
|
|
417
404
|
* Transforms world coordinates to camera coordinates using the "look-at" approach.
|
|
@@ -419,7 +406,7 @@ export declare function MatrixDirection3D(direction: TVector3, matrix: IMatrix3)
|
|
|
419
406
|
* @param eye - Camera position in world coordinates.
|
|
420
407
|
* @param target - Point the camera is looking at.
|
|
421
408
|
* @param up - Up direction vector (usually [0, 1, 0]).
|
|
422
|
-
* @returns {
|
|
409
|
+
* @returns {TMatrix4} A 4x4 view transformation matrix.
|
|
423
410
|
*
|
|
424
411
|
* @example
|
|
425
412
|
* ```typescript
|
|
@@ -430,7 +417,7 @@ export declare function MatrixDirection3D(direction: TVector3, matrix: IMatrix3)
|
|
|
430
417
|
* );
|
|
431
418
|
* ```
|
|
432
419
|
*/
|
|
433
|
-
export declare function MatrixView(eye: TVector3, target: TVector3, up: TVector3):
|
|
420
|
+
export declare function MatrixView(eye: TVector3, target: TVector3, up: TVector3): TMatrix4;
|
|
434
421
|
/**
|
|
435
422
|
* Creates a perspective projection matrix for 3D rendering.
|
|
436
423
|
* Transforms 3D view coordinates to normalized device coordinates with perspective effect.
|
|
@@ -439,7 +426,7 @@ export declare function MatrixView(eye: TVector3, target: TVector3, up: TVector3
|
|
|
439
426
|
* @param aspect - Aspect ratio of the viewport (width/height).
|
|
440
427
|
* @param near - Distance to near clipping plane (must be positive).
|
|
441
428
|
* @param far - Distance to far clipping plane (must be > near).
|
|
442
|
-
* @returns {
|
|
429
|
+
* @returns {TMatrix4} A 4x4 perspective projection matrix.
|
|
443
430
|
*
|
|
444
431
|
* @throws {Error} If parameters are invalid.
|
|
445
432
|
*
|
|
@@ -453,7 +440,7 @@ export declare function MatrixView(eye: TVector3, target: TVector3, up: TVector3
|
|
|
453
440
|
* );
|
|
454
441
|
* ```
|
|
455
442
|
*/
|
|
456
|
-
export declare function MatrixPerspective(fovY: number, aspect: number, near: number, far: number):
|
|
443
|
+
export declare function MatrixPerspective(fovY: number, aspect: number, near: number, far: number): TMatrix4;
|
|
457
444
|
/**
|
|
458
445
|
* Creates an orthographic projection matrix for 3D rendering.
|
|
459
446
|
* Maps a rectangular box to the unit cube [-1, 1]³ without perspective distortion.
|
|
@@ -464,7 +451,7 @@ export declare function MatrixPerspective(fovY: number, aspect: number, near: nu
|
|
|
464
451
|
* @param top - Top boundary of the orthographic volume.
|
|
465
452
|
* @param near - Near clipping plane distance.
|
|
466
453
|
* @param far - Far clipping plane distance.
|
|
467
|
-
* @returns {
|
|
454
|
+
* @returns {TMatrix4} A 4x4 orthographic projection matrix.
|
|
468
455
|
*
|
|
469
456
|
* @throws {Error} If any opposing boundaries are equal.
|
|
470
457
|
*
|
|
@@ -477,5 +464,5 @@ export declare function MatrixPerspective(fovY: number, aspect: number, near: nu
|
|
|
477
464
|
* );
|
|
478
465
|
* ```
|
|
479
466
|
*/
|
|
480
|
-
export declare function MatrixOrthographic(left: number, right: number, bottom: number, top: number, near: number, far: number):
|
|
467
|
+
export declare function MatrixOrthographic(left: number, right: number, bottom: number, top: number, near: number, far: number): TMatrix4;
|
|
481
468
|
//# sourceMappingURL=transformations.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
1
|
+
{"version":3,"file":"transformations.d.ts","sourceRoot":"","sources":["../../src/matrices/transformations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAMH,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAY,MAAM,qBAAqB,CAAC;AAUxE;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,QAAQ,CAU1D;AAMD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,QAAQ,CAW9D;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,QAAQ,CAW/D;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,QAAQ,CAW7D;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;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;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,M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EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,GAAG,QAAQ,CAkB9E;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,GAAG,QAAQ,CAoBjF;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,GAAG,QAAQ,CAUjF;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE,QAAQ,GAAG,QAAQ,CAiClF;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,QAAQ,CAuBnG;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,QAAQ,CA0BhI"}
|
|
@@ -38,7 +38,7 @@ const DEGREES_PER_HALF_REVOLUTION = 180;
|
|
|
38
38
|
* ```
|
|
39
39
|
*
|
|
40
40
|
* @param radians - Rotation angle in radians (positive = counterclockwise)
|
|
41
|
-
* @returns {
|
|
41
|
+
* @returns {TMatrix3} A 3x3 rotation matrix for 2D transformations
|
|
42
42
|
*
|
|
43
43
|
* @throws {Error} If radians is not a finite number
|
|
44
44
|
*
|
|
@@ -46,7 +46,6 @@ const DEGREES_PER_HALF_REVOLUTION = 180;
|
|
|
46
46
|
* ```typescript
|
|
47
47
|
* // 90-degree counterclockwise rotation
|
|
48
48
|
* const matrix = MatrixRotation2D(Math.PI / 2);
|
|
49
|
-
*
|
|
50
49
|
* // 45-degree clockwise rotation
|
|
51
50
|
* const clockwise = MatrixRotation2D(-Math.PI / 4);
|
|
52
51
|
* ```
|
|
@@ -80,7 +79,7 @@ export function MatrixRotation2D(radians) {
|
|
|
80
79
|
* ```
|
|
81
80
|
*
|
|
82
81
|
* @param radians - Roll angle in radians (positive = right-hand rule around X-axis)
|
|
83
|
-
* @returns {
|
|
82
|
+
* @returns {TMatrix4} A 4x4 roll rotation matrix
|
|
84
83
|
*
|
|
85
84
|
* @throws {Error} If radians is not a finite number
|
|
86
85
|
*
|
|
@@ -117,7 +116,7 @@ export function MatrixRotation3DRoll(radians) {
|
|
|
117
116
|
* ```
|
|
118
117
|
*
|
|
119
118
|
* @param radians - Pitch angle in radians (positive = nose up in aviation)
|
|
120
|
-
* @returns {
|
|
119
|
+
* @returns {TMatrix4} A 4x4 pitch rotation matrix
|
|
121
120
|
*
|
|
122
121
|
* @throws {Error} If radians is not a finite number
|
|
123
122
|
*
|
|
@@ -154,7 +153,7 @@ export function MatrixRotation3DPitch(radians) {
|
|
|
154
153
|
* ```
|
|
155
154
|
*
|
|
156
155
|
* @param radians - Yaw angle in radians (positive = turn left in aviation)
|
|
157
|
-
* @returns {
|
|
156
|
+
* @returns {TMatrix4} A 4x4 yaw rotation matrix
|
|
158
157
|
*
|
|
159
158
|
* @throws {Error} If radians is not a finite number
|
|
160
159
|
*
|
|
@@ -286,7 +285,7 @@ export function MatrixScale3D(scaleOrX, y, z) {
|
|
|
286
285
|
* ```
|
|
287
286
|
*
|
|
288
287
|
* @param v - Translation vector [x, y] containing offset distances
|
|
289
|
-
* @returns {
|
|
288
|
+
* @returns {TMatrix3} A 3x3 translation transformation matrix
|
|
290
289
|
*
|
|
291
290
|
* @throws {Error} If the input is not a valid 2D vector
|
|
292
291
|
*
|
|
@@ -294,7 +293,6 @@ export function MatrixScale3D(scaleOrX, y, z) {
|
|
|
294
293
|
* ```typescript
|
|
295
294
|
* // Move 10 units right, 5 units up
|
|
296
295
|
* const translation = MatrixTranslation2D(10, 5);
|
|
297
|
-
*
|
|
298
296
|
* // Using vector input
|
|
299
297
|
* const offset: TVector2 = [10, 5];
|
|
300
298
|
* const translation2 = MatrixTranslation2D(...offset);
|
|
@@ -369,7 +367,6 @@ export function MatrixTranslation3D(translationOrX, y, z) {
|
|
|
369
367
|
* const point: TVector2 = [1, 0];
|
|
370
368
|
* const rotatedPoint = MatrixTransform2D(point, rotationMatrix);
|
|
371
369
|
* // Result: approximately [0, 1]
|
|
372
|
-
*
|
|
373
370
|
* // Chain multiple transformations
|
|
374
371
|
* const scale = MatrixScale2D(2, 2);
|
|
375
372
|
* const translate = MatrixTranslation2D(5, 3);
|
|
@@ -460,7 +457,7 @@ export function MatrixDirection3D(direction, matrix) {
|
|
|
460
457
|
* @param eye - Camera position in world coordinates.
|
|
461
458
|
* @param target - Point the camera is looking at.
|
|
462
459
|
* @param up - Up direction vector (usually [0, 1, 0]).
|
|
463
|
-
* @returns {
|
|
460
|
+
* @returns {TMatrix4} A 4x4 view transformation matrix.
|
|
464
461
|
*
|
|
465
462
|
* @example
|
|
466
463
|
* ```typescript
|
|
@@ -507,7 +504,7 @@ export function MatrixView(eye, target, up) {
|
|
|
507
504
|
* @param aspect - Aspect ratio of the viewport (width/height).
|
|
508
505
|
* @param near - Distance to near clipping plane (must be positive).
|
|
509
506
|
* @param far - Distance to far clipping plane (must be > near).
|
|
510
|
-
* @returns {
|
|
507
|
+
* @returns {TMatrix4} A 4x4 perspective projection matrix.
|
|
511
508
|
*
|
|
512
509
|
* @throws {Error} If parameters are invalid.
|
|
513
510
|
*
|
|
@@ -551,7 +548,7 @@ export function MatrixPerspective(fovY, aspect, near, far) {
|
|
|
551
548
|
* @param top - Top boundary of the orthographic volume.
|
|
552
549
|
* @param near - Near clipping plane distance.
|
|
553
550
|
* @param far - Far clipping plane distance.
|
|
554
|
-
* @returns {
|
|
551
|
+
* @returns {TMatrix4} A 4x4 orthographic projection matrix.
|
|
555
552
|
*
|
|
556
553
|
* @throws {Error} If any opposing boundaries are equal.
|
|
557
554
|
*
|