math 0.0.0 → 0.1.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/API.md +1605 -0
- package/LICENSE +21 -0
- package/README.md +197 -0
- package/dist/color/color.js +136 -0
- package/dist/color/color.js.map +1 -0
- package/dist/color/colorspace.js +43 -0
- package/dist/color/colorspace.js.map +1 -0
- package/dist/color/hsl.js +123 -0
- package/dist/color/hsl.js.map +1 -0
- package/dist/color/index.js +7 -0
- package/dist/color/index.js.map +1 -0
- package/dist/color/parse.js +276 -0
- package/dist/color/parse.js.map +1 -0
- package/dist/core/angle.js +43 -0
- package/dist/core/angle.js.map +1 -0
- package/dist/core/euler.js +212 -0
- package/dist/core/euler.js.map +1 -0
- package/dist/core/mat2.js +385 -0
- package/dist/core/mat2.js.map +1 -0
- package/dist/core/mat2d.js +422 -0
- package/dist/core/mat2d.js.map +1 -0
- package/dist/core/mat3.js +749 -0
- package/dist/core/mat3.js.map +1 -0
- package/dist/core/mat4.js +2197 -0
- package/dist/core/mat4.js.map +1 -0
- package/dist/core/polar.js +200 -0
- package/dist/core/polar.js.map +1 -0
- package/dist/core/quat.js +730 -0
- package/dist/core/quat.js.map +1 -0
- package/dist/core/quat2.js +883 -0
- package/dist/core/quat2.js.map +1 -0
- package/dist/core/scalar.js +112 -0
- package/dist/core/scalar.js.map +1 -0
- package/dist/core/spherical.js +248 -0
- package/dist/core/spherical.js.map +1 -0
- package/dist/core/vec2.js +597 -0
- package/dist/core/vec2.js.map +1 -0
- package/dist/core/vec3.js +916 -0
- package/dist/core/vec3.js.map +1 -0
- package/dist/core/vec4.js +573 -0
- package/dist/core/vec4.js.map +1 -0
- package/dist/geometry/circumcircle.js +39 -0
- package/dist/geometry/circumcircle.js.map +1 -0
- package/dist/geometry/index.js +6 -0
- package/dist/geometry/index.js.map +1 -0
- package/dist/geometry/polygon2-decompose.js +411 -0
- package/dist/geometry/polygon2-decompose.js.map +1 -0
- package/dist/geometry/polygon2-triangulate.js +222 -0
- package/dist/geometry/polygon2-triangulate.js.map +1 -0
- package/dist/geometry/quickhull2.js +123 -0
- package/dist/geometry/quickhull2.js.map +1 -0
- package/dist/geometry/quickhull3.js +605 -0
- package/dist/geometry/quickhull3.js.map +1 -0
- package/dist/ik/fabrik2.js +675 -0
- package/dist/ik/fabrik2.js.map +1 -0
- package/dist/ik/fabrik3.js +912 -0
- package/dist/ik/fabrik3.js.map +1 -0
- package/dist/ik/index.js +5 -0
- package/dist/ik/index.js.map +1 -0
- package/dist/index.js +27 -0
- package/dist/index.js.map +1 -0
- package/dist/noise/fractal.js +185 -0
- package/dist/noise/fractal.js.map +1 -0
- package/dist/noise/index.js +16 -0
- package/dist/noise/index.js.map +1 -0
- package/dist/noise/perlin2d.js +50 -0
- package/dist/noise/perlin2d.js.map +1 -0
- package/dist/noise/perlin3d.js +72 -0
- package/dist/noise/perlin3d.js.map +1 -0
- package/dist/noise/permutation.js +120 -0
- package/dist/noise/permutation.js.map +1 -0
- package/dist/noise/simplex2d.js +84 -0
- package/dist/noise/simplex2d.js.map +1 -0
- package/dist/noise/simplex3d.js +147 -0
- package/dist/noise/simplex3d.js.map +1 -0
- package/dist/noise/simplex4d.js +149 -0
- package/dist/noise/simplex4d.js.map +1 -0
- package/dist/noise/worley2d.js +50 -0
- package/dist/noise/worley2d.js.map +1 -0
- package/dist/noise/worley3d.js +61 -0
- package/dist/noise/worley3d.js.map +1 -0
- package/dist/random/index.js +9 -0
- package/dist/random/index.js.map +1 -0
- package/dist/random/isaac32.js +164 -0
- package/dist/random/isaac32.js.map +1 -0
- package/dist/random/isaac64.js +215 -0
- package/dist/random/isaac64.js.map +1 -0
- package/dist/random/mulberry32.js +48 -0
- package/dist/random/mulberry32.js.map +1 -0
- package/dist/random/random.js +120 -0
- package/dist/random/random.js.map +1 -0
- package/dist/shapes/box2.js +300 -0
- package/dist/shapes/box2.js.map +1 -0
- package/dist/shapes/box3.js +550 -0
- package/dist/shapes/box3.js.map +1 -0
- package/dist/shapes/circle.js +6 -0
- package/dist/shapes/circle.js.map +1 -0
- package/dist/shapes/frustum.js +662 -0
- package/dist/shapes/frustum.js.map +1 -0
- package/dist/shapes/index.js +25 -0
- package/dist/shapes/index.js.map +1 -0
- package/dist/shapes/obb3.js +557 -0
- package/dist/shapes/obb3.js.map +1 -0
- package/dist/shapes/plane3.js +267 -0
- package/dist/shapes/plane3.js.map +1 -0
- package/dist/shapes/polygon2.js +451 -0
- package/dist/shapes/polygon2.js.map +1 -0
- package/dist/shapes/raycast3.js +164 -0
- package/dist/shapes/raycast3.js.map +1 -0
- package/dist/shapes/segment2.js +82 -0
- package/dist/shapes/segment2.js.map +1 -0
- package/dist/shapes/sphere.js +23 -0
- package/dist/shapes/sphere.js.map +1 -0
- package/dist/shapes/triangle2.js +79 -0
- package/dist/shapes/triangle2.js.map +1 -0
- package/dist/shapes/triangle3.js +60 -0
- package/dist/shapes/triangle3.js.map +1 -0
- package/dist/src/color/color.d.ts +50 -0
- package/dist/src/color/colorspace.d.ts +15 -0
- package/dist/src/color/hsl.d.ts +28 -0
- package/dist/src/color/index.d.ts +5 -0
- package/dist/src/color/parse.d.ts +15 -0
- package/dist/src/core/angle.d.ts +29 -0
- package/dist/src/core/arrays.d.ts +4 -0
- package/dist/src/core/euler.d.ts +78 -0
- package/dist/src/core/index.d.ts +27 -0
- package/dist/src/core/mat2.d.ts +217 -0
- package/dist/src/core/mat2d.d.ts +218 -0
- package/dist/src/core/mat3.d.ts +295 -0
- package/dist/src/core/mat4.d.ts +667 -0
- package/dist/src/core/polar.d.ts +151 -0
- package/dist/src/core/quat.d.ts +370 -0
- package/dist/src/core/quat2.d.ts +344 -0
- package/dist/src/core/scalar.d.ts +75 -0
- package/dist/src/core/spherical.d.ts +165 -0
- package/dist/src/core/vec2.d.ts +403 -0
- package/dist/src/core/vec3.d.ts +493 -0
- package/dist/src/core/vec4.d.ts +336 -0
- package/dist/src/geometry/circumcircle.d.ts +9 -0
- package/dist/src/geometry/index.d.ts +5 -0
- package/dist/src/geometry/polygon2-decompose.d.ts +25 -0
- package/dist/src/geometry/polygon2-triangulate.d.ts +15 -0
- package/dist/src/geometry/quickhull2.d.ts +10 -0
- package/dist/src/geometry/quickhull3.d.ts +27 -0
- package/dist/src/ik/fabrik2.d.ts +314 -0
- package/dist/src/ik/fabrik3.d.ts +371 -0
- package/dist/src/ik/index.d.ts +2 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/noise/fractal.d.ts +95 -0
- package/dist/src/noise/index.d.ts +9 -0
- package/dist/src/noise/perlin2d.d.ts +19 -0
- package/dist/src/noise/perlin3d.d.ts +20 -0
- package/dist/src/noise/permutation.d.ts +22 -0
- package/dist/src/noise/simplex2d.d.ts +19 -0
- package/dist/src/noise/simplex3d.d.ts +20 -0
- package/dist/src/noise/simplex4d.d.ts +24 -0
- package/dist/src/noise/worley2d.d.ts +22 -0
- package/dist/src/noise/worley3d.d.ts +23 -0
- package/dist/src/random/index.d.ts +8 -0
- package/dist/src/random/isaac32.d.ts +62 -0
- package/dist/src/random/isaac64.d.ts +75 -0
- package/dist/src/random/mulberry32.d.ts +43 -0
- package/dist/src/random/random.d.ts +67 -0
- package/dist/src/shapes/box2.d.ts +174 -0
- package/dist/src/shapes/box3.d.ts +213 -0
- package/dist/src/shapes/circle.d.ts +7 -0
- package/dist/src/shapes/frustum.d.ts +147 -0
- package/dist/src/shapes/index.d.ts +20 -0
- package/dist/src/shapes/obb3.d.ts +105 -0
- package/dist/src/shapes/plane3.d.ts +130 -0
- package/dist/src/shapes/polygon2.d.ts +155 -0
- package/dist/src/shapes/raycast3.d.ts +42 -0
- package/dist/src/shapes/segment2.d.ts +34 -0
- package/dist/src/shapes/sphere.d.ts +19 -0
- package/dist/src/shapes/triangle2.d.ts +53 -0
- package/dist/src/shapes/triangle3.d.ts +29 -0
- package/dist/src/time/easing.d.ts +21 -0
- package/dist/src/time/index.d.ts +6 -0
- package/dist/src/time/spring-core.d.ts +15 -0
- package/dist/src/time/spring.d.ts +36 -0
- package/dist/src/time/spring2.d.ts +11 -0
- package/dist/src/time/spring3.d.ts +11 -0
- package/dist/src/time/spring4.d.ts +11 -0
- package/dist/time/easing.js +24 -0
- package/dist/time/easing.js.map +1 -0
- package/dist/time/index.js +11 -0
- package/dist/time/index.js.map +1 -0
- package/dist/time/spring-core.js +48 -0
- package/dist/time/spring-core.js.map +1 -0
- package/dist/time/spring.js +62 -0
- package/dist/time/spring.js.map +1 -0
- package/dist/time/spring2.js +31 -0
- package/dist/time/spring2.js.map +1 -0
- package/dist/time/spring3.js +32 -0
- package/dist/time/spring3.js.map +1 -0
- package/dist/time/spring4.js +32 -0
- package/dist/time/spring4.js.map +1 -0
- package/package.json +90 -12
- package/skills/math/SKILL.md +140 -0
- package/math.coffee +0 -36
- package/math.js +0 -67
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import type { Vec2 } from './vec2.js';
|
|
2
|
+
/** A 2x2 matrix */
|
|
3
|
+
export type Mat2 = [e1: number, e2: number, e3: number, e4: number];
|
|
4
|
+
/**
|
|
5
|
+
* Creates a new identity mat2
|
|
6
|
+
*
|
|
7
|
+
* @returns a new 2x2 matrix
|
|
8
|
+
*/
|
|
9
|
+
export declare function create(): Mat2;
|
|
10
|
+
/**
|
|
11
|
+
* Creates a new mat2 initialized with values from an existing matrix
|
|
12
|
+
*
|
|
13
|
+
* @param a matrix to clone
|
|
14
|
+
* @returns a new 2x2 matrix
|
|
15
|
+
*/
|
|
16
|
+
export declare function clone(a: Mat2): Mat2;
|
|
17
|
+
/**
|
|
18
|
+
* Copy the values from one mat2 to another
|
|
19
|
+
*
|
|
20
|
+
* @param out the receiving matrix
|
|
21
|
+
* @param a the source matrix
|
|
22
|
+
* @returns out
|
|
23
|
+
*/
|
|
24
|
+
export declare function copy(out: Mat2, a: Mat2): Mat2;
|
|
25
|
+
/**
|
|
26
|
+
* Set a mat2 to the identity matrix
|
|
27
|
+
*
|
|
28
|
+
* @param out the receiving matrix
|
|
29
|
+
* @returns out
|
|
30
|
+
*/
|
|
31
|
+
export declare function identity(out: Mat2): Mat2;
|
|
32
|
+
/**
|
|
33
|
+
* Create a new mat2 with the given values
|
|
34
|
+
*
|
|
35
|
+
* @param m00 Component in column 0, row 0 position (index 0)
|
|
36
|
+
* @param m01 Component in column 0, row 1 position (index 1)
|
|
37
|
+
* @param m10 Component in column 1, row 0 position (index 2)
|
|
38
|
+
* @param m11 Component in column 1, row 1 position (index 3)
|
|
39
|
+
* @returns out A new 2x2 matrix
|
|
40
|
+
*/
|
|
41
|
+
export declare function fromValues(m00: number, m01: number, m10: number, m11: number): Mat2;
|
|
42
|
+
/**
|
|
43
|
+
* Set the components of a mat2 to the given values
|
|
44
|
+
*
|
|
45
|
+
* @param out the receiving matrix
|
|
46
|
+
* @param m00 Component in column 0, row 0 position (index 0)
|
|
47
|
+
* @param m01 Component in column 0, row 1 position (index 1)
|
|
48
|
+
* @param m10 Component in column 1, row 0 position (index 2)
|
|
49
|
+
* @param m11 Component in column 1, row 1 position (index 3)
|
|
50
|
+
* @returns out
|
|
51
|
+
*/
|
|
52
|
+
export declare function set(out: Mat2, m00: number, m01: number, m10: number, m11: number): Mat2;
|
|
53
|
+
/**
|
|
54
|
+
* Transpose the values of a mat2
|
|
55
|
+
*
|
|
56
|
+
* @param out the receiving matrix
|
|
57
|
+
* @param a the source matrix
|
|
58
|
+
* @returns out
|
|
59
|
+
*/
|
|
60
|
+
export declare function transpose(out: Mat2, a: Mat2): Mat2;
|
|
61
|
+
/**
|
|
62
|
+
* Inverts a mat2
|
|
63
|
+
*
|
|
64
|
+
* @param out the receiving matrix
|
|
65
|
+
* @param a the source matrix
|
|
66
|
+
* @returns out, or null if source matrix is not invertible
|
|
67
|
+
*/
|
|
68
|
+
export declare function invert(out: Mat2, a: Mat2): Mat2 | null;
|
|
69
|
+
/**
|
|
70
|
+
* Calculates the adjugate of a mat2
|
|
71
|
+
*
|
|
72
|
+
* @param out the receiving matrix
|
|
73
|
+
* @param a the source matrix
|
|
74
|
+
* @returns out
|
|
75
|
+
*/
|
|
76
|
+
export declare function adjoint(out: Mat2, a: Mat2): Mat2;
|
|
77
|
+
/**
|
|
78
|
+
* Calculates the determinant of a mat2
|
|
79
|
+
*
|
|
80
|
+
* @param a the source matrix
|
|
81
|
+
* @returns determinant of a
|
|
82
|
+
*/
|
|
83
|
+
export declare function determinant(a: Mat2): number;
|
|
84
|
+
/**
|
|
85
|
+
* Multiplies two mat2's
|
|
86
|
+
*
|
|
87
|
+
* @param out the receiving matrix
|
|
88
|
+
* @param a the first operand
|
|
89
|
+
* @param b the second operand
|
|
90
|
+
* @returns out
|
|
91
|
+
*/
|
|
92
|
+
export declare function multiply(out: Mat2, a: Mat2, b: Mat2): Mat2;
|
|
93
|
+
/**
|
|
94
|
+
* Rotates a mat2 by the given angle
|
|
95
|
+
*
|
|
96
|
+
* @param out the receiving matrix
|
|
97
|
+
* @param a the matrix to rotate
|
|
98
|
+
* @param rad the angle to rotate the matrix by
|
|
99
|
+
* @returns out
|
|
100
|
+
*/
|
|
101
|
+
export declare function rotate(out: Mat2, a: Mat2, rad: number): Mat2;
|
|
102
|
+
/**
|
|
103
|
+
* Scales the mat2 by the dimensions in the given vec2
|
|
104
|
+
*
|
|
105
|
+
* @param out the receiving matrix
|
|
106
|
+
* @param a the matrix to rotate
|
|
107
|
+
* @param v the vec2 to scale the matrix by
|
|
108
|
+
* @returns out
|
|
109
|
+
**/
|
|
110
|
+
export declare function scale(out: Mat2, a: Mat2, v: Vec2): Mat2;
|
|
111
|
+
/**
|
|
112
|
+
* Creates a matrix from a given angle
|
|
113
|
+
* This is equivalent to (but much faster than):
|
|
114
|
+
*
|
|
115
|
+
* mat2.identity(dest);
|
|
116
|
+
* mat2.rotate(dest, dest, rad);
|
|
117
|
+
*
|
|
118
|
+
* @param out mat2 receiving operation result
|
|
119
|
+
* @param rad the angle to rotate the matrix by
|
|
120
|
+
* @returns out
|
|
121
|
+
*/
|
|
122
|
+
export declare function fromRotation(out: Mat2, rad: number): Mat2;
|
|
123
|
+
/**
|
|
124
|
+
* Creates a matrix from a vector scaling
|
|
125
|
+
* This is equivalent to (but much faster than):
|
|
126
|
+
*
|
|
127
|
+
* mat2.identity(dest);
|
|
128
|
+
* mat2.scale(dest, dest, vec);
|
|
129
|
+
*
|
|
130
|
+
* @param out mat2 receiving operation result
|
|
131
|
+
* @param v Scaling vector
|
|
132
|
+
* @returns out
|
|
133
|
+
*/
|
|
134
|
+
export declare function fromScaling(out: Mat2, v: Vec2): Mat2;
|
|
135
|
+
/**
|
|
136
|
+
* Returns a string representation of a mat2
|
|
137
|
+
*
|
|
138
|
+
* @param a matrix to represent as a string
|
|
139
|
+
* @returns string representation of the matrix
|
|
140
|
+
*/
|
|
141
|
+
export declare function str(a: Mat2): string;
|
|
142
|
+
/**
|
|
143
|
+
* Returns Frobenius norm of a mat2
|
|
144
|
+
*
|
|
145
|
+
* @param a the matrix to calculate Frobenius norm of
|
|
146
|
+
* @returns Frobenius norm
|
|
147
|
+
*/
|
|
148
|
+
export declare function frob(a: Mat2): number;
|
|
149
|
+
/**
|
|
150
|
+
* Returns L, D and U matrices (Lower triangular, Diagonal and Upper triangular) by factorizing the input matrix
|
|
151
|
+
* @param L the lower triangular matrix
|
|
152
|
+
* @param D the diagonal matrix
|
|
153
|
+
* @param U the upper triangular matrix
|
|
154
|
+
* @param a the input matrix to factorize
|
|
155
|
+
*/
|
|
156
|
+
export declare function LDU(L: Mat2, D: Mat2, U: Mat2, a: Mat2): [Mat2, Mat2, Mat2];
|
|
157
|
+
/**
|
|
158
|
+
* Adds two mat2's
|
|
159
|
+
*
|
|
160
|
+
* @param out the receiving matrix
|
|
161
|
+
* @param a the first operand
|
|
162
|
+
* @param b the second operand
|
|
163
|
+
* @returns out
|
|
164
|
+
*/
|
|
165
|
+
export declare function add(out: Mat2, a: Mat2, b: Mat2): Mat2;
|
|
166
|
+
/**
|
|
167
|
+
* Subtracts matrix b from matrix a
|
|
168
|
+
*
|
|
169
|
+
* @param out the receiving matrix
|
|
170
|
+
* @param a the first operand
|
|
171
|
+
* @param b the second operand
|
|
172
|
+
* @returns out
|
|
173
|
+
*/
|
|
174
|
+
export declare function subtract(out: Mat2, a: Mat2, b: Mat2): Mat2;
|
|
175
|
+
/**
|
|
176
|
+
* Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===)
|
|
177
|
+
*
|
|
178
|
+
* @param a The first matrix.
|
|
179
|
+
* @param b The second matrix.
|
|
180
|
+
* @returns True if the matrices are equal, false otherwise.
|
|
181
|
+
*/
|
|
182
|
+
export declare function exactEquals(a: Mat2, b: Mat2): boolean;
|
|
183
|
+
/**
|
|
184
|
+
* Returns whether or not the matrices have approximately the same elements in the same position.
|
|
185
|
+
*
|
|
186
|
+
* @param a The first matrix.
|
|
187
|
+
* @param b The second matrix.
|
|
188
|
+
* @returns True if the matrices are equal, false otherwise.
|
|
189
|
+
*/
|
|
190
|
+
export declare function equals(a: Mat2, b: Mat2): boolean;
|
|
191
|
+
/**
|
|
192
|
+
* Multiply each element of the matrix by a scalar.
|
|
193
|
+
*
|
|
194
|
+
* @param out the receiving matrix
|
|
195
|
+
* @param a the matrix to scale
|
|
196
|
+
* @param b amount to scale the matrix's elements by
|
|
197
|
+
* @returns out
|
|
198
|
+
*/
|
|
199
|
+
export declare function multiplyScalar(out: Mat2, a: Mat2, b: number): Mat2;
|
|
200
|
+
/**
|
|
201
|
+
* Adds two mat2's after multiplying each element of the second operand by a scalar value.
|
|
202
|
+
*
|
|
203
|
+
* @param out the receiving vector
|
|
204
|
+
* @param a the first operand
|
|
205
|
+
* @param b the second operand
|
|
206
|
+
* @param scale the amount to scale b's elements by before adding
|
|
207
|
+
* @returns out
|
|
208
|
+
*/
|
|
209
|
+
export declare function multiplyScalarAndAdd(out: Mat2, a: Mat2, b: Mat2, scale: number): Mat2;
|
|
210
|
+
/**
|
|
211
|
+
* Alias for {@link mat2.multiply}
|
|
212
|
+
*/
|
|
213
|
+
export declare const mul: typeof multiply;
|
|
214
|
+
/**
|
|
215
|
+
* Alias for {@link mat2.subtract}
|
|
216
|
+
*/
|
|
217
|
+
export declare const sub: typeof subtract;
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import type { Vec2 } from './vec2.js';
|
|
2
|
+
/** A 2D affine transform matrix */
|
|
3
|
+
export type Mat2d = [e1: number, e2: number, e3: number, e4: number, e5: number, e6: number];
|
|
4
|
+
/**
|
|
5
|
+
* Creates a new identity mat2d
|
|
6
|
+
*
|
|
7
|
+
* @returns a new 2x3 matrix
|
|
8
|
+
*/
|
|
9
|
+
export declare function create(): Mat2d;
|
|
10
|
+
/**
|
|
11
|
+
* Creates a new mat2d initialized with values from an existing matrix
|
|
12
|
+
*
|
|
13
|
+
* @param a matrix to clone
|
|
14
|
+
* @returns a new 2x3 matrix
|
|
15
|
+
*/
|
|
16
|
+
export declare function clone(a: Mat2d): Mat2d;
|
|
17
|
+
/**
|
|
18
|
+
* Copy the values from one mat2d to another
|
|
19
|
+
*
|
|
20
|
+
* @param out the receiving matrix
|
|
21
|
+
* @param a the source matrix
|
|
22
|
+
* @returns out
|
|
23
|
+
*/
|
|
24
|
+
export declare function copy(out: Mat2d, a: Mat2d): Mat2d;
|
|
25
|
+
/**
|
|
26
|
+
* Set a mat2d to the identity matrix
|
|
27
|
+
*
|
|
28
|
+
* @param out the receiving matrix
|
|
29
|
+
* @returns out
|
|
30
|
+
*/
|
|
31
|
+
export declare function identity(out: Mat2d): Mat2d;
|
|
32
|
+
/**
|
|
33
|
+
* Create a new mat2d with the given values
|
|
34
|
+
*
|
|
35
|
+
* @param a Component A (index 0)
|
|
36
|
+
* @param b Component B (index 1)
|
|
37
|
+
* @param c Component C (index 2)
|
|
38
|
+
* @param d Component D (index 3)
|
|
39
|
+
* @param tx Component TX (index 4)
|
|
40
|
+
* @param ty Component TY (index 5)
|
|
41
|
+
* @returns A new mat2d
|
|
42
|
+
*/
|
|
43
|
+
export declare function fromValues(a: number, b: number, c: number, d: number, tx: number, ty: number): Mat2d;
|
|
44
|
+
/**
|
|
45
|
+
* Set the components of a mat2d to the given values
|
|
46
|
+
*
|
|
47
|
+
* @param out the receiving matrix
|
|
48
|
+
* @param a Component A (index 0)
|
|
49
|
+
* @param b Component B (index 1)
|
|
50
|
+
* @param c Component C (index 2)
|
|
51
|
+
* @param d Component D (index 3)
|
|
52
|
+
* @param tx Component TX (index 4)
|
|
53
|
+
* @param ty Component TY (index 5)
|
|
54
|
+
* @returns out
|
|
55
|
+
*/
|
|
56
|
+
export declare function set(out: Mat2d, a: number, b: number, c: number, d: number, tx: number, ty: number): Mat2d;
|
|
57
|
+
/**
|
|
58
|
+
* Inverts a mat2d
|
|
59
|
+
*
|
|
60
|
+
* @param out the receiving matrix
|
|
61
|
+
* @param a the source matrix
|
|
62
|
+
* @returns out, or null if source matrix is not invertible
|
|
63
|
+
*/
|
|
64
|
+
export declare function invert(out: Mat2d, a: Mat2d): Mat2d | null;
|
|
65
|
+
/**
|
|
66
|
+
* Calculates the determinant of a mat2d
|
|
67
|
+
*
|
|
68
|
+
* @param a the source matrix
|
|
69
|
+
* @returns determinant of a
|
|
70
|
+
*/
|
|
71
|
+
export declare function determinant(a: Mat2d): number;
|
|
72
|
+
/**
|
|
73
|
+
* Multiplies two mat2d's
|
|
74
|
+
*
|
|
75
|
+
* @param out the receiving matrix
|
|
76
|
+
* @param a the first operand
|
|
77
|
+
* @param b the second operand
|
|
78
|
+
* @returns out
|
|
79
|
+
*/
|
|
80
|
+
export declare function multiply(out: Mat2d, a: Mat2d, b: Mat2d): Mat2d;
|
|
81
|
+
/**
|
|
82
|
+
* Rotates a mat2d by the given angle
|
|
83
|
+
*
|
|
84
|
+
* @param out the receiving matrix
|
|
85
|
+
* @param a the matrix to rotate
|
|
86
|
+
* @param rad the angle to rotate the matrix by
|
|
87
|
+
* @returns out
|
|
88
|
+
*/
|
|
89
|
+
export declare function rotate(out: Mat2d, a: Mat2d, rad: number): Mat2d;
|
|
90
|
+
/**
|
|
91
|
+
* Scales the mat2d by the dimensions in the given vec2
|
|
92
|
+
*
|
|
93
|
+
* @param out the receiving matrix
|
|
94
|
+
* @param a the matrix to translate
|
|
95
|
+
* @param v the vec2 to scale the matrix by
|
|
96
|
+
* @returns out
|
|
97
|
+
**/
|
|
98
|
+
export declare function scale(out: Mat2d, a: Mat2d, v: Vec2): Mat2d;
|
|
99
|
+
/**
|
|
100
|
+
* Translates the mat2d by the dimensions in the given vec2
|
|
101
|
+
*
|
|
102
|
+
* @param out the receiving matrix
|
|
103
|
+
* @param a the matrix to translate
|
|
104
|
+
* @param v the vec2 to translate the matrix by
|
|
105
|
+
* @returns out
|
|
106
|
+
**/
|
|
107
|
+
export declare function translate(out: Mat2d, a: Mat2d, v: Vec2): Mat2d;
|
|
108
|
+
/**
|
|
109
|
+
* Creates a matrix from a given angle
|
|
110
|
+
* This is equivalent to (but much faster than):
|
|
111
|
+
*
|
|
112
|
+
* mat2d.identity(dest);
|
|
113
|
+
* mat2d.rotate(dest, dest, rad);
|
|
114
|
+
*
|
|
115
|
+
* @param out mat2d receiving operation result
|
|
116
|
+
* @param rad the angle to rotate the matrix by
|
|
117
|
+
* @returns out
|
|
118
|
+
*/
|
|
119
|
+
export declare function fromRotation(out: Mat2d, rad: number): Mat2d;
|
|
120
|
+
/**
|
|
121
|
+
* Creates a matrix from a vector scaling
|
|
122
|
+
* This is equivalent to (but much faster than):
|
|
123
|
+
*
|
|
124
|
+
* mat2d.identity(dest);
|
|
125
|
+
* mat2d.scale(dest, dest, vec);
|
|
126
|
+
*
|
|
127
|
+
* @param out mat2d receiving operation result
|
|
128
|
+
* @param v Scaling vector
|
|
129
|
+
* @returns out
|
|
130
|
+
*/
|
|
131
|
+
export declare function fromScaling(out: Mat2d, v: Vec2): Mat2d;
|
|
132
|
+
/**
|
|
133
|
+
* Creates a matrix from a vector translation
|
|
134
|
+
* This is equivalent to (but much faster than):
|
|
135
|
+
*
|
|
136
|
+
* mat2d.identity(dest);
|
|
137
|
+
* mat2d.translate(dest, dest, vec);
|
|
138
|
+
*
|
|
139
|
+
* @param out mat2d receiving operation result
|
|
140
|
+
* @param v Translation vector
|
|
141
|
+
* @returns out
|
|
142
|
+
*/
|
|
143
|
+
export declare function fromTranslation(out: Mat2d, v: Vec2): Mat2d;
|
|
144
|
+
/**
|
|
145
|
+
* Returns a string representation of a mat2d
|
|
146
|
+
*
|
|
147
|
+
* @param a matrix to represent as a string
|
|
148
|
+
* @returns string representation of the matrix
|
|
149
|
+
*/
|
|
150
|
+
export declare function str(a: Mat2d): string;
|
|
151
|
+
/**
|
|
152
|
+
* Returns Frobenius norm of a mat2d
|
|
153
|
+
*
|
|
154
|
+
* @param a the matrix to calculate Frobenius norm of
|
|
155
|
+
* @returns Frobenius norm
|
|
156
|
+
*/
|
|
157
|
+
export declare function frob(a: Mat2d): number;
|
|
158
|
+
/**
|
|
159
|
+
* Adds two mat2d's
|
|
160
|
+
*
|
|
161
|
+
* @param out the receiving matrix
|
|
162
|
+
* @param a the first operand
|
|
163
|
+
* @param b the second operand
|
|
164
|
+
* @returns out
|
|
165
|
+
*/
|
|
166
|
+
export declare function add(out: Mat2d, a: Mat2d, b: Mat2d): Mat2d;
|
|
167
|
+
/**
|
|
168
|
+
* Subtracts matrix b from matrix a
|
|
169
|
+
*
|
|
170
|
+
* @param out the receiving matrix
|
|
171
|
+
* @param a the first operand
|
|
172
|
+
* @param b the second operand
|
|
173
|
+
* @returns out
|
|
174
|
+
*/
|
|
175
|
+
export declare function subtract(out: Mat2d, a: Mat2d, b: Mat2d): Mat2d;
|
|
176
|
+
/**
|
|
177
|
+
* Multiply each element of the matrix by a scalar.
|
|
178
|
+
*
|
|
179
|
+
* @param out the receiving matrix
|
|
180
|
+
* @param a the matrix to scale
|
|
181
|
+
* @param b amount to scale the matrix's elements by
|
|
182
|
+
* @returns out
|
|
183
|
+
*/
|
|
184
|
+
export declare function multiplyScalar(out: Mat2d, a: Mat2d, b: number): Mat2d;
|
|
185
|
+
/**
|
|
186
|
+
* Adds two mat2d's after multiplying each element of the second operand by a scalar value.
|
|
187
|
+
*
|
|
188
|
+
* @param out the receiving vector
|
|
189
|
+
* @param a the first operand
|
|
190
|
+
* @param b the second operand
|
|
191
|
+
* @param scale the amount to scale b's elements by before adding
|
|
192
|
+
* @returns out
|
|
193
|
+
*/
|
|
194
|
+
export declare function multiplyScalarAndAdd(out: Mat2d, a: Mat2d, b: Mat2d, scale: number): Mat2d;
|
|
195
|
+
/**
|
|
196
|
+
* Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===)
|
|
197
|
+
*
|
|
198
|
+
* @param a The first matrix.
|
|
199
|
+
* @param b The second matrix.
|
|
200
|
+
* @returns True if the matrices are equal, false otherwise.
|
|
201
|
+
*/
|
|
202
|
+
export declare function exactEquals(a: Mat2d, b: Mat2d): boolean;
|
|
203
|
+
/**
|
|
204
|
+
* Returns whether or not the matrices have approximately the same elements in the same position.
|
|
205
|
+
*
|
|
206
|
+
* @param a The first matrix.
|
|
207
|
+
* @param b The second matrix.
|
|
208
|
+
* @returns True if the matrices are equal, false otherwise.
|
|
209
|
+
*/
|
|
210
|
+
export declare function equals(a: Mat2d, b: Mat2d): boolean;
|
|
211
|
+
/**
|
|
212
|
+
* Alias for {@link mat2d.multiply}
|
|
213
|
+
*/
|
|
214
|
+
export declare const mul: typeof multiply;
|
|
215
|
+
/**
|
|
216
|
+
* Alias for {@link mat2d.subtract}
|
|
217
|
+
*/
|
|
218
|
+
export declare const sub: typeof subtract;
|