math 0.0.3 → 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 -16
- package/skills/math/SKILL.md +140 -0
- package/AUTHORS +0 -1
- package/Cakefile +0 -28
- package/math.coffee +0 -112
- package/math.js +0 -141
|
@@ -0,0 +1,403 @@
|
|
|
1
|
+
import type { MutableArrayLike } from './arrays.js';
|
|
2
|
+
import type { Mat2 } from './mat2.js';
|
|
3
|
+
import type { Mat2d } from './mat2d.js';
|
|
4
|
+
import type { Mat3 } from './mat3.js';
|
|
5
|
+
import type { Mat4 } from './mat4.js';
|
|
6
|
+
import type { Vec3 } from './vec3.js';
|
|
7
|
+
/** A 2D vector */
|
|
8
|
+
export type Vec2 = [x: number, y: number];
|
|
9
|
+
/**
|
|
10
|
+
* Creates a new, empty vec2
|
|
11
|
+
*
|
|
12
|
+
* @returns a new 2D vector
|
|
13
|
+
*/
|
|
14
|
+
export declare function create(): Vec2;
|
|
15
|
+
/**
|
|
16
|
+
* Creates a new vec2 initialized with values from an existing vector
|
|
17
|
+
*
|
|
18
|
+
* @param a vector to clone
|
|
19
|
+
* @returns a new 2D vector
|
|
20
|
+
*/
|
|
21
|
+
export declare function clone(a: Vec2): Vec2;
|
|
22
|
+
/**
|
|
23
|
+
* Creates a new vec2 initialized with the given values
|
|
24
|
+
*
|
|
25
|
+
* @param x X component
|
|
26
|
+
* @param y Y component
|
|
27
|
+
* @returns a new 2D vector
|
|
28
|
+
*/
|
|
29
|
+
export declare function fromValues(x: number, y: number): Vec2;
|
|
30
|
+
/**
|
|
31
|
+
* Copy the values from one vec2 to another
|
|
32
|
+
*
|
|
33
|
+
* @param out the receiving vector
|
|
34
|
+
* @param a the source vector
|
|
35
|
+
* @returns out
|
|
36
|
+
*/
|
|
37
|
+
export declare function copy(out: Vec2, a: Vec2): Vec2;
|
|
38
|
+
/**
|
|
39
|
+
* Set the components of a vec2 to the given values
|
|
40
|
+
*
|
|
41
|
+
* @param out the receiving vector
|
|
42
|
+
* @param x X component
|
|
43
|
+
* @param y Y component
|
|
44
|
+
* @returns out
|
|
45
|
+
*/
|
|
46
|
+
export declare function set(out: Vec2, x: number, y: number): Vec2;
|
|
47
|
+
/**
|
|
48
|
+
* Sets the components of a vec2 from a buffer
|
|
49
|
+
* @param out the receiving vector
|
|
50
|
+
* @param buffer the source buffer
|
|
51
|
+
* @param startIndex the starting index in the buffer
|
|
52
|
+
* @returns out
|
|
53
|
+
*/
|
|
54
|
+
export declare function fromBuffer(out: Vec2, buffer: ArrayLike<number>, startIndex: number): Vec2;
|
|
55
|
+
/**
|
|
56
|
+
* Writes the components of a vec2 to a buffer
|
|
57
|
+
* @param outBuffer The output buffer
|
|
58
|
+
* @param vec The source vector
|
|
59
|
+
* @param startIndex The starting index in the buffer
|
|
60
|
+
* @returns The output buffer
|
|
61
|
+
*/
|
|
62
|
+
export declare function toBuffer(outBuffer: MutableArrayLike<number>, vec: Vec2, startIndex: number): MutableArrayLike<number>;
|
|
63
|
+
/**
|
|
64
|
+
* Adds two vec2's
|
|
65
|
+
*
|
|
66
|
+
* @param out the receiving vector
|
|
67
|
+
* @param a the first operand
|
|
68
|
+
* @param b the second operand
|
|
69
|
+
* @returns out
|
|
70
|
+
*/
|
|
71
|
+
export declare function add(out: Vec2, a: Vec2, b: Vec2): Vec2;
|
|
72
|
+
/**
|
|
73
|
+
* Adds a scalar value to all components of a vec2
|
|
74
|
+
*
|
|
75
|
+
* @param out the receiving vector
|
|
76
|
+
* @param a the source vector
|
|
77
|
+
* @param b the scalar value to add
|
|
78
|
+
* @returns out
|
|
79
|
+
*/
|
|
80
|
+
export declare function addScalar(out: Vec2, a: Vec2, b: number): Vec2;
|
|
81
|
+
/**
|
|
82
|
+
* Subtracts vector b from vector a
|
|
83
|
+
*
|
|
84
|
+
* @param out the receiving vector
|
|
85
|
+
* @param a the first operand
|
|
86
|
+
* @param b the second operand
|
|
87
|
+
* @returns out
|
|
88
|
+
*/
|
|
89
|
+
export declare function subtract(out: Vec2, a: Vec2, b: Vec2): Vec2;
|
|
90
|
+
/**
|
|
91
|
+
* Subtracts a scalar value from all components of a vec2
|
|
92
|
+
*
|
|
93
|
+
* @param out the receiving vector
|
|
94
|
+
* @param a the source vector
|
|
95
|
+
* @param b the scalar value to subtract
|
|
96
|
+
* @returns out
|
|
97
|
+
*/
|
|
98
|
+
export declare function subtractScalar(out: Vec2, a: Vec2, b: number): Vec2;
|
|
99
|
+
/**
|
|
100
|
+
* Multiplies two vec2's
|
|
101
|
+
*
|
|
102
|
+
* @param out the receiving vector
|
|
103
|
+
* @param a the first operand
|
|
104
|
+
* @param b the second operand
|
|
105
|
+
* @returns out
|
|
106
|
+
*/
|
|
107
|
+
export declare function multiply(out: Vec2, a: Vec2, b: Vec2): Vec2;
|
|
108
|
+
/**
|
|
109
|
+
* Divides two vec2's
|
|
110
|
+
*
|
|
111
|
+
* @param out the receiving vector
|
|
112
|
+
* @param a the first operand
|
|
113
|
+
* @param b the second operand
|
|
114
|
+
* @returns out
|
|
115
|
+
*/
|
|
116
|
+
export declare function divide(out: Vec2, a: Vec2, b: Vec2): Vec2;
|
|
117
|
+
/**
|
|
118
|
+
* Math.ceil the components of a vec2
|
|
119
|
+
*
|
|
120
|
+
* @param out the receiving vector
|
|
121
|
+
* @param a vector to ceil
|
|
122
|
+
* @returns out
|
|
123
|
+
*/
|
|
124
|
+
export declare function ceil(out: Vec2, a: Vec2): Vec2;
|
|
125
|
+
/**
|
|
126
|
+
* Math.floor the components of a vec2
|
|
127
|
+
*
|
|
128
|
+
* @param out the receiving vector
|
|
129
|
+
* @param a vector to floor
|
|
130
|
+
* @returns out
|
|
131
|
+
*/
|
|
132
|
+
export declare function floor(out: Vec2, a: Vec2): Vec2;
|
|
133
|
+
/**
|
|
134
|
+
* Returns the minimum of two vec2's
|
|
135
|
+
*
|
|
136
|
+
* @param out the receiving vector
|
|
137
|
+
* @param a the first operand
|
|
138
|
+
* @param b the second operand
|
|
139
|
+
* @returns out
|
|
140
|
+
*/
|
|
141
|
+
export declare function min(out: Vec2, a: Vec2, b: Vec2): Vec2;
|
|
142
|
+
/**
|
|
143
|
+
* Returns the maximum of two vec2's
|
|
144
|
+
*
|
|
145
|
+
* @param out the receiving vector
|
|
146
|
+
* @param a the first operand
|
|
147
|
+
* @param b the second operand
|
|
148
|
+
* @returns out
|
|
149
|
+
*/
|
|
150
|
+
export declare function max(out: Vec2, a: Vec2, b: Vec2): Vec2;
|
|
151
|
+
/**
|
|
152
|
+
* symmetric round the components of a vec2
|
|
153
|
+
*
|
|
154
|
+
* @param out the receiving vector
|
|
155
|
+
* @param a vector to round
|
|
156
|
+
* @returns out
|
|
157
|
+
*/
|
|
158
|
+
export declare function round(out: Vec2, a: Vec2): Vec2;
|
|
159
|
+
/**
|
|
160
|
+
* Scales a vec2 by a scalar number
|
|
161
|
+
*
|
|
162
|
+
* @param out the receiving vector
|
|
163
|
+
* @param a the vector to scale
|
|
164
|
+
* @param b amount to scale the vector by
|
|
165
|
+
* @returns out
|
|
166
|
+
*/
|
|
167
|
+
export declare function scale(out: Vec2, a: Vec2, b: number): Vec2;
|
|
168
|
+
/**
|
|
169
|
+
* Adds two vec2's after scaling the second operand by a scalar value
|
|
170
|
+
*
|
|
171
|
+
* @param out the receiving vector
|
|
172
|
+
* @param a the first operand
|
|
173
|
+
* @param b the second operand
|
|
174
|
+
* @param scale the amount to scale b by before adding
|
|
175
|
+
* @returns out
|
|
176
|
+
*/
|
|
177
|
+
export declare function scaleAndAdd(out: Vec2, a: Vec2, b: Vec2, scale: number): Vec2;
|
|
178
|
+
/**
|
|
179
|
+
* Calculates the euclidian distance between two vec2's
|
|
180
|
+
*
|
|
181
|
+
* @param a the first operand
|
|
182
|
+
* @param b the second operand
|
|
183
|
+
* @returns distance between a and b
|
|
184
|
+
*/
|
|
185
|
+
export declare function distance(a: Vec2, b: Vec2): number;
|
|
186
|
+
/**
|
|
187
|
+
* Calculates the squared euclidian distance between two vec2's
|
|
188
|
+
*
|
|
189
|
+
* @param a the first operand
|
|
190
|
+
* @param b the second operand
|
|
191
|
+
* @returns squared distance between a and b
|
|
192
|
+
*/
|
|
193
|
+
export declare function squaredDistance(a: Vec2, b: Vec2): number;
|
|
194
|
+
/**
|
|
195
|
+
* Calculates the length of a vec2
|
|
196
|
+
*
|
|
197
|
+
* @param a vector to calculate length of
|
|
198
|
+
* @returns length of a
|
|
199
|
+
*/
|
|
200
|
+
export declare function length(a: Vec2): number;
|
|
201
|
+
/**
|
|
202
|
+
* Calculates the squared length of a vec2
|
|
203
|
+
*
|
|
204
|
+
* @param a vector to calculate squared length of
|
|
205
|
+
* @returns squared length of a
|
|
206
|
+
*/
|
|
207
|
+
export declare function squaredLength(a: Vec2): number;
|
|
208
|
+
/**
|
|
209
|
+
* Negates the components of a vec2
|
|
210
|
+
*
|
|
211
|
+
* @param out the receiving vector
|
|
212
|
+
* @param a vector to negate
|
|
213
|
+
* @returns out
|
|
214
|
+
*/
|
|
215
|
+
export declare function negate(out: Vec2, a: Vec2): Vec2;
|
|
216
|
+
/**
|
|
217
|
+
* Returns the inverse of the components of a vec2
|
|
218
|
+
*
|
|
219
|
+
* @param out the receiving vector
|
|
220
|
+
* @param a vector to invert
|
|
221
|
+
* @returns out
|
|
222
|
+
*/
|
|
223
|
+
export declare function inverse(out: Vec2, a: Vec2): Vec2;
|
|
224
|
+
/**
|
|
225
|
+
* Normalize a vec2
|
|
226
|
+
*
|
|
227
|
+
* @param out the receiving vector
|
|
228
|
+
* @param a vector to normalize
|
|
229
|
+
* @returns out
|
|
230
|
+
*/
|
|
231
|
+
export declare function normalize(out: Vec2, a: Vec2): Vec2;
|
|
232
|
+
/**
|
|
233
|
+
* Calculates the dot product of two vec2's
|
|
234
|
+
*
|
|
235
|
+
* @param a the first operand
|
|
236
|
+
* @param b the second operand
|
|
237
|
+
* @returns dot product of a and b
|
|
238
|
+
*/
|
|
239
|
+
export declare function dot(a: Vec2, b: Vec2): number;
|
|
240
|
+
/**
|
|
241
|
+
* Computes the cross product of two vec2's
|
|
242
|
+
* Note that the cross product must by definition produce a 3D vector
|
|
243
|
+
*
|
|
244
|
+
* @param out the receiving vector
|
|
245
|
+
* @param a the first operand
|
|
246
|
+
* @param b the second operand
|
|
247
|
+
* @returns out
|
|
248
|
+
*/
|
|
249
|
+
export declare function cross(out: Vec3, a: Vec2, b: Vec2): Vec3;
|
|
250
|
+
/**
|
|
251
|
+
* Performs a linear interpolation between two vec2's
|
|
252
|
+
*
|
|
253
|
+
* @param out the receiving vector
|
|
254
|
+
* @param a the first operand
|
|
255
|
+
* @param b the second operand
|
|
256
|
+
* @param t interpolation amount, in the range [0-1], between the two inputs
|
|
257
|
+
* @returns out
|
|
258
|
+
*/
|
|
259
|
+
export declare function lerp(out: Vec2, a: Vec2, b: Vec2, t: number): Vec2;
|
|
260
|
+
/**
|
|
261
|
+
* Quadratic interpolation through three vectors using Lagrange interpolation.
|
|
262
|
+
* Passes through a at t=0, b at t=0.5, and c at t=1.
|
|
263
|
+
*
|
|
264
|
+
* @param out the receiving vector
|
|
265
|
+
* @param a vector at t=0
|
|
266
|
+
* @param b vector at t=0.5
|
|
267
|
+
* @param c vector at t=1
|
|
268
|
+
* @param t interpolation amount
|
|
269
|
+
* @returns out
|
|
270
|
+
*/
|
|
271
|
+
export declare function lagrange(out: Vec2, a: Vec2, b: Vec2, c: Vec2, t: number): Vec2;
|
|
272
|
+
/**
|
|
273
|
+
* Transforms the vec2 with a mat2
|
|
274
|
+
*
|
|
275
|
+
* @param out the receiving vector
|
|
276
|
+
* @param a the vector to transform
|
|
277
|
+
* @param m matrix to transform with
|
|
278
|
+
* @returns out
|
|
279
|
+
*/
|
|
280
|
+
export declare function transformMat2(out: Vec2, a: Vec2, m: Mat2): Vec2;
|
|
281
|
+
/**
|
|
282
|
+
* Transforms the vec2 with a mat2d
|
|
283
|
+
*
|
|
284
|
+
* @param out the receiving vector
|
|
285
|
+
* @param a the vector to transform
|
|
286
|
+
* @param m matrix to transform with
|
|
287
|
+
* @returns out
|
|
288
|
+
*/
|
|
289
|
+
export declare function transformMat2d(out: Vec2, a: Vec2, m: Mat2d): Vec2;
|
|
290
|
+
/**
|
|
291
|
+
* Transforms the vec2 with a mat3
|
|
292
|
+
* 3rd vector component is implicitly '1'
|
|
293
|
+
*
|
|
294
|
+
* @param out the receiving vector
|
|
295
|
+
* @param a the vector to transform
|
|
296
|
+
* @param m matrix to transform with
|
|
297
|
+
* @returns out
|
|
298
|
+
*/
|
|
299
|
+
export declare function transformMat3(out: Vec2, a: Vec2, m: Mat3): Vec2;
|
|
300
|
+
/**
|
|
301
|
+
* Transforms the vec2 with a mat4
|
|
302
|
+
* 3rd vector component is implicitly '0'
|
|
303
|
+
* 4th vector component is implicitly '1'
|
|
304
|
+
*
|
|
305
|
+
* @param out the receiving vector
|
|
306
|
+
* @param a the vector to transform
|
|
307
|
+
* @param m matrix to transform with
|
|
308
|
+
* @returns out
|
|
309
|
+
*/
|
|
310
|
+
export declare function transformMat4(out: Vec2, a: Vec2, m: Mat4): Vec2;
|
|
311
|
+
/**
|
|
312
|
+
* Rotate a 2D vector
|
|
313
|
+
* @param out The receiving vec2
|
|
314
|
+
* @param a The vec2 point to rotate
|
|
315
|
+
* @param b The origin of the rotation
|
|
316
|
+
* @param rad The angle of rotation in radians
|
|
317
|
+
* @returns out
|
|
318
|
+
*/
|
|
319
|
+
export declare function rotate(out: Vec2, a: Vec2, b: Vec2, rad: number): Vec2;
|
|
320
|
+
/**
|
|
321
|
+
* Get the angle between two 2D vectors
|
|
322
|
+
* @param a The first operand
|
|
323
|
+
* @param b The second operand
|
|
324
|
+
* @returns The angle in radians
|
|
325
|
+
*/
|
|
326
|
+
export declare function angle(a: Vec2, b: Vec2): number;
|
|
327
|
+
/**
|
|
328
|
+
* Get the signed angle from `a` to `b`, in the range (-PI, PI].
|
|
329
|
+
*
|
|
330
|
+
* Positive is counter-clockwise. Returns 0 if either vector is zero length.
|
|
331
|
+
*
|
|
332
|
+
* Unlike {@link angle}, this distinguishes the two directions of rotation, which is what
|
|
333
|
+
* joint limits and turn directions need.
|
|
334
|
+
*
|
|
335
|
+
* @param a the first operand
|
|
336
|
+
* @param b the second operand
|
|
337
|
+
* @returns the signed angle in radians
|
|
338
|
+
*/
|
|
339
|
+
export declare function signedAngle(a: Vec2, b: Vec2): number;
|
|
340
|
+
/**
|
|
341
|
+
* Set the components of a vec2 to zero
|
|
342
|
+
*
|
|
343
|
+
* @param out the receiving vector
|
|
344
|
+
* @returns out
|
|
345
|
+
*/
|
|
346
|
+
export declare function zero(out: Vec2): Vec2;
|
|
347
|
+
/**
|
|
348
|
+
* Returns a string representation of a vector
|
|
349
|
+
*
|
|
350
|
+
* @param a vector to represent as a string
|
|
351
|
+
* @returns string representation of the vector
|
|
352
|
+
*/
|
|
353
|
+
export declare function str(a: Vec2): string;
|
|
354
|
+
/**
|
|
355
|
+
* Returns whether or not the vectors exactly have the same elements in the same position (when compared with ===)
|
|
356
|
+
*
|
|
357
|
+
* @param a The first vector.
|
|
358
|
+
* @param b The second vector.
|
|
359
|
+
* @returns True if the vectors are equal, false otherwise.
|
|
360
|
+
*/
|
|
361
|
+
export declare function exactEquals(a: Vec2, b: Vec2): boolean;
|
|
362
|
+
/**
|
|
363
|
+
* Returns whether or not the vectors have approximately the same elements in the same position.
|
|
364
|
+
*
|
|
365
|
+
* @param a The first vector.
|
|
366
|
+
* @param b The second vector.
|
|
367
|
+
* @returns True if the vectors are equal, false otherwise.
|
|
368
|
+
*/
|
|
369
|
+
export declare function equals(a: Vec2, b: Vec2): boolean;
|
|
370
|
+
/**
|
|
371
|
+
* Returns whether or not the vector is finite
|
|
372
|
+
* @param a vector to test
|
|
373
|
+
* @returns whether or not the vector is finite
|
|
374
|
+
*/
|
|
375
|
+
export declare function finite(a: Vec2): boolean;
|
|
376
|
+
/**
|
|
377
|
+
* Alias for {@link length}
|
|
378
|
+
*/
|
|
379
|
+
export declare const len: typeof length;
|
|
380
|
+
/**
|
|
381
|
+
* Alias for {@link subtract}
|
|
382
|
+
*/
|
|
383
|
+
export declare const sub: typeof subtract;
|
|
384
|
+
/**
|
|
385
|
+
* Alias for {@link multiply}
|
|
386
|
+
*/
|
|
387
|
+
export declare const mul: typeof multiply;
|
|
388
|
+
/**
|
|
389
|
+
* Alias for {@link divide}
|
|
390
|
+
*/
|
|
391
|
+
export declare const div: typeof divide;
|
|
392
|
+
/**
|
|
393
|
+
* Alias for {@link distance}
|
|
394
|
+
*/
|
|
395
|
+
export declare const dist: typeof distance;
|
|
396
|
+
/**
|
|
397
|
+
* Alias for {@link squaredDistance}
|
|
398
|
+
*/
|
|
399
|
+
export declare const sqrDist: typeof squaredDistance;
|
|
400
|
+
/**
|
|
401
|
+
* Alias for {@link squaredLength}
|
|
402
|
+
*/
|
|
403
|
+
export declare const sqrLen: typeof squaredLength;
|