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,493 @@
|
|
|
1
|
+
import type { MutableArrayLike } from './arrays.js';
|
|
2
|
+
import type { Mat3 } from './mat3.js';
|
|
3
|
+
import type { Mat4 } from './mat4.js';
|
|
4
|
+
import type { Quat } from './quat.js';
|
|
5
|
+
/** A 3D vector */
|
|
6
|
+
export type Vec3 = [x: number, y: number, z: number];
|
|
7
|
+
/**
|
|
8
|
+
* Creates a new, empty vec3
|
|
9
|
+
*
|
|
10
|
+
* @returns a new 3D vector
|
|
11
|
+
*/
|
|
12
|
+
export declare function create(): Vec3;
|
|
13
|
+
/**
|
|
14
|
+
* Creates a new vec3 initialized with values from an existing vector
|
|
15
|
+
*
|
|
16
|
+
* @param a vector to clone
|
|
17
|
+
* @returns a new 3D vector
|
|
18
|
+
*/
|
|
19
|
+
export declare function clone(a: Vec3): Vec3;
|
|
20
|
+
/**
|
|
21
|
+
* Creates a new vec3 initialized with the given values
|
|
22
|
+
*
|
|
23
|
+
* @param x X component
|
|
24
|
+
* @param y Y component
|
|
25
|
+
* @param z Z component
|
|
26
|
+
* @returns a new 3D vector
|
|
27
|
+
*/
|
|
28
|
+
export declare function fromValues(x: number, y: number, z: number): Vec3;
|
|
29
|
+
/**
|
|
30
|
+
* Calculates the length of a vec3
|
|
31
|
+
*
|
|
32
|
+
* @param a vector to calculate length of
|
|
33
|
+
* @returns length of a
|
|
34
|
+
*/
|
|
35
|
+
export declare function length(a: Vec3): number;
|
|
36
|
+
/**
|
|
37
|
+
* Copy the values from one vec3 to another
|
|
38
|
+
*
|
|
39
|
+
* @param out the receiving vector
|
|
40
|
+
* @param a the source vector
|
|
41
|
+
* @returns out
|
|
42
|
+
*/
|
|
43
|
+
export declare function copy(out: Vec3, a: Vec3): Vec3;
|
|
44
|
+
/**
|
|
45
|
+
* Set the components of a vec3 to the given values
|
|
46
|
+
*
|
|
47
|
+
* @param out the receiving vector
|
|
48
|
+
* @param x X component
|
|
49
|
+
* @param y Y component
|
|
50
|
+
* @param z Z component
|
|
51
|
+
* @returns out
|
|
52
|
+
*/
|
|
53
|
+
export declare function set(out: Vec3, x: number, y: number, z: number): Vec3;
|
|
54
|
+
/**
|
|
55
|
+
* Sets all components of a vec3 to the given scalar value
|
|
56
|
+
*
|
|
57
|
+
* @param out the receiving vector
|
|
58
|
+
* @param s scalar value to set
|
|
59
|
+
* @returns out
|
|
60
|
+
*/
|
|
61
|
+
export declare function setScalar(out: Vec3, s: number): Vec3;
|
|
62
|
+
/**
|
|
63
|
+
* Sets the components of a vec3 from a buffer
|
|
64
|
+
* @param out the receiving vector
|
|
65
|
+
* @param buffer the source buffer
|
|
66
|
+
* @param startIndex the starting index in the buffer
|
|
67
|
+
* @returns out
|
|
68
|
+
*/
|
|
69
|
+
export declare function fromBuffer(out: Vec3, buffer: ArrayLike<number>, startIndex: number): Vec3;
|
|
70
|
+
/**
|
|
71
|
+
* Writes the components of a vec3 to a buffer
|
|
72
|
+
* @param outBuffer The output buffer
|
|
73
|
+
* @param vec The source vector
|
|
74
|
+
* @param startIndex The starting index in the buffer
|
|
75
|
+
* @returns The output buffer
|
|
76
|
+
*/
|
|
77
|
+
export declare function toBuffer(outBuffer: MutableArrayLike<number>, vec: Vec3, startIndex: number): MutableArrayLike<number>;
|
|
78
|
+
/**
|
|
79
|
+
* Adds two vec3's
|
|
80
|
+
*
|
|
81
|
+
* @param out the receiving vector
|
|
82
|
+
* @param a the first operand
|
|
83
|
+
* @param b the second operand
|
|
84
|
+
* @returns out
|
|
85
|
+
*/
|
|
86
|
+
export declare function add(out: Vec3, a: Vec3, b: Vec3): Vec3;
|
|
87
|
+
/**
|
|
88
|
+
* Adds a scalar value to all components of a vec3
|
|
89
|
+
*
|
|
90
|
+
* @param out the receiving vector
|
|
91
|
+
* @param a the source vector
|
|
92
|
+
* @param b the scalar value to add
|
|
93
|
+
* @returns out
|
|
94
|
+
*/
|
|
95
|
+
export declare function addScalar(out: Vec3, a: Vec3, b: number): Vec3;
|
|
96
|
+
/**
|
|
97
|
+
* Subtracts vector b from vector a
|
|
98
|
+
*
|
|
99
|
+
* @param out the receiving vector
|
|
100
|
+
* @param a the first operand
|
|
101
|
+
* @param b the second operand
|
|
102
|
+
* @returns out
|
|
103
|
+
*/
|
|
104
|
+
export declare function subtract(out: Vec3, a: Vec3, b: Vec3): Vec3;
|
|
105
|
+
/**
|
|
106
|
+
* Subtracts a scalar value from all components of a vec3
|
|
107
|
+
*
|
|
108
|
+
* @param out the receiving vector
|
|
109
|
+
* @param a the source vector
|
|
110
|
+
* @param b the scalar value to subtract
|
|
111
|
+
* @returns out
|
|
112
|
+
*/
|
|
113
|
+
export declare function subtractScalar(out: Vec3, a: Vec3, b: number): Vec3;
|
|
114
|
+
/**
|
|
115
|
+
* Multiplies two vec3's
|
|
116
|
+
*
|
|
117
|
+
* @param out the receiving vector
|
|
118
|
+
* @param a the first operand
|
|
119
|
+
* @param b the second operand
|
|
120
|
+
* @returns out
|
|
121
|
+
*/
|
|
122
|
+
export declare function multiply(out: Vec3, a: Vec3, b: Vec3): Vec3;
|
|
123
|
+
/**
|
|
124
|
+
* Divides two vec3's
|
|
125
|
+
*
|
|
126
|
+
* @param out the receiving vector
|
|
127
|
+
* @param a the first operand
|
|
128
|
+
* @param b the second operand
|
|
129
|
+
* @returns out
|
|
130
|
+
*/
|
|
131
|
+
export declare function divide(out: Vec3, a: Vec3, b: Vec3): Vec3;
|
|
132
|
+
/**
|
|
133
|
+
* Math.ceil the components of a vec3
|
|
134
|
+
*
|
|
135
|
+
* @param out the receiving vector
|
|
136
|
+
* @param a vector to ceil
|
|
137
|
+
* @returns out
|
|
138
|
+
*/
|
|
139
|
+
export declare function ceil(out: Vec3, a: Vec3): Vec3;
|
|
140
|
+
/**
|
|
141
|
+
* Math.floor the components of a vec3
|
|
142
|
+
*
|
|
143
|
+
* @param out the receiving vector
|
|
144
|
+
* @param a vector to floor
|
|
145
|
+
* @returns out
|
|
146
|
+
*/
|
|
147
|
+
export declare function floor(out: Vec3, a: Vec3): Vec3;
|
|
148
|
+
/**
|
|
149
|
+
* Returns the minimum of two vec3's
|
|
150
|
+
*
|
|
151
|
+
* @param out the receiving vector
|
|
152
|
+
* @param a the first operand
|
|
153
|
+
* @param b the second operand
|
|
154
|
+
* @returns out
|
|
155
|
+
*/
|
|
156
|
+
export declare function min(out: Vec3, a: Vec3, b: Vec3): Vec3;
|
|
157
|
+
/**
|
|
158
|
+
* Returns the maximum of two vec3's
|
|
159
|
+
*
|
|
160
|
+
* @param out the receiving vector
|
|
161
|
+
* @param a the first operand
|
|
162
|
+
* @param b the second operand
|
|
163
|
+
* @returns out
|
|
164
|
+
*/
|
|
165
|
+
export declare function max(out: Vec3, a: Vec3, b: Vec3): Vec3;
|
|
166
|
+
/**
|
|
167
|
+
* symmetric round the components of a vec3
|
|
168
|
+
*
|
|
169
|
+
* @param out the receiving vector
|
|
170
|
+
* @param a vector to round
|
|
171
|
+
* @returns out
|
|
172
|
+
*/
|
|
173
|
+
export declare function round(out: Vec3, a: Vec3): Vec3;
|
|
174
|
+
/**
|
|
175
|
+
* Scales a vec3 by a scalar number
|
|
176
|
+
*
|
|
177
|
+
* @param out the receiving vector
|
|
178
|
+
* @param a the vector to scale
|
|
179
|
+
* @param b amount to scale the vector by
|
|
180
|
+
* @returns out
|
|
181
|
+
*/
|
|
182
|
+
export declare function scale(out: Vec3, a: Vec3, b: number): Vec3;
|
|
183
|
+
/**
|
|
184
|
+
* Adds two vec3's after scaling the second operand by a scalar value
|
|
185
|
+
*
|
|
186
|
+
* @param out the receiving vector
|
|
187
|
+
* @param a the first operand
|
|
188
|
+
* @param b the second operand
|
|
189
|
+
* @param scale the amount to scale b by before adding
|
|
190
|
+
* @returns out
|
|
191
|
+
*/
|
|
192
|
+
export declare function scaleAndAdd(out: Vec3, a: Vec3, b: Vec3, scale: number): Vec3;
|
|
193
|
+
/**
|
|
194
|
+
* Calculates the euclidian distance between two vec3's
|
|
195
|
+
*
|
|
196
|
+
* @param a the first operand
|
|
197
|
+
* @param b the second operand
|
|
198
|
+
* @returns distance between a and b
|
|
199
|
+
*/
|
|
200
|
+
export declare function distance(a: Vec3, b: Vec3): number;
|
|
201
|
+
/**
|
|
202
|
+
* Calculates the squared euclidian distance between two vec3's
|
|
203
|
+
*
|
|
204
|
+
* @param a the first operand
|
|
205
|
+
* @param b the second operand
|
|
206
|
+
* @returns squared distance between a and b
|
|
207
|
+
*/
|
|
208
|
+
export declare function squaredDistance(a: Vec3, b: Vec3): number;
|
|
209
|
+
/**
|
|
210
|
+
* Calculates the squared length of a vec3
|
|
211
|
+
*
|
|
212
|
+
* @param a vector to calculate squared length of
|
|
213
|
+
* @returns squared length of a
|
|
214
|
+
*/
|
|
215
|
+
export declare function squaredLength(a: Vec3): number;
|
|
216
|
+
/**
|
|
217
|
+
* Negates the components of a vec3
|
|
218
|
+
*
|
|
219
|
+
* @param out the receiving vector
|
|
220
|
+
* @param a vector to negate
|
|
221
|
+
* @returns out
|
|
222
|
+
*/
|
|
223
|
+
export declare function negate(out: Vec3, a: Vec3): Vec3;
|
|
224
|
+
/**
|
|
225
|
+
* Returns the inverse of the components of a vec3
|
|
226
|
+
*
|
|
227
|
+
* @param out the receiving vector
|
|
228
|
+
* @param a vector to invert
|
|
229
|
+
* @returns out
|
|
230
|
+
*/
|
|
231
|
+
export declare function inverse(out: Vec3, a: Vec3): Vec3;
|
|
232
|
+
/**
|
|
233
|
+
* Normalize a vec3
|
|
234
|
+
*
|
|
235
|
+
* @param out the receiving vector
|
|
236
|
+
* @param a vector to normalize
|
|
237
|
+
* @returns out
|
|
238
|
+
*/
|
|
239
|
+
export declare function normalize(out: Vec3, a: Vec3): Vec3;
|
|
240
|
+
/**
|
|
241
|
+
* Calculates the dot product of two vec3's
|
|
242
|
+
*
|
|
243
|
+
* @param a the first operand
|
|
244
|
+
* @param b the second operand
|
|
245
|
+
* @returns dot product of a and b
|
|
246
|
+
*/
|
|
247
|
+
export declare function dot(a: Vec3, b: Vec3): number;
|
|
248
|
+
/**
|
|
249
|
+
* Computes the cross product of two vec3's
|
|
250
|
+
*
|
|
251
|
+
* @param out the receiving vector
|
|
252
|
+
* @param a the first operand
|
|
253
|
+
* @param b the second operand
|
|
254
|
+
* @returns out
|
|
255
|
+
*/
|
|
256
|
+
export declare function cross(out: Vec3, a: Vec3, b: Vec3): Vec3;
|
|
257
|
+
/**
|
|
258
|
+
* Calculates a normalized perpendicular vector to the given vector.
|
|
259
|
+
* Useful for finding an arbitrary orthogonal basis vector.
|
|
260
|
+
*
|
|
261
|
+
* The zero vector has no unique perpendicular - every direction qualifies - so it returns the X
|
|
262
|
+
* axis rather than NaN.
|
|
263
|
+
*
|
|
264
|
+
* @param out the receiving vector
|
|
265
|
+
* @param a the source vector
|
|
266
|
+
* @returns the out vector
|
|
267
|
+
*/
|
|
268
|
+
export declare function perpendicular(out: Vec3, a: Vec3): Vec3;
|
|
269
|
+
/**
|
|
270
|
+
* Performs a linear interpolation between two vec3's
|
|
271
|
+
*
|
|
272
|
+
* @param out the receiving vector
|
|
273
|
+
* @param a the first operand
|
|
274
|
+
* @param b the second operand
|
|
275
|
+
* @param t interpolation amount, in the range [0-1], between the two inputs
|
|
276
|
+
* @returns out
|
|
277
|
+
*/
|
|
278
|
+
export declare function lerp(out: Vec3, a: Vec3, b: Vec3, t: number): Vec3;
|
|
279
|
+
/**
|
|
280
|
+
* Quadratic interpolation through three vectors using Lagrange interpolation.
|
|
281
|
+
* Passes through a at t=0, b at t=0.5, and c at t=1.
|
|
282
|
+
*
|
|
283
|
+
* @param out the receiving vector
|
|
284
|
+
* @param a vector at t=0
|
|
285
|
+
* @param b vector at t=0.5
|
|
286
|
+
* @param c vector at t=1
|
|
287
|
+
* @param t interpolation amount
|
|
288
|
+
* @returns out
|
|
289
|
+
*/
|
|
290
|
+
export declare function lagrange(out: Vec3, a: Vec3, b: Vec3, c: Vec3, t: number): Vec3;
|
|
291
|
+
/**
|
|
292
|
+
* Performs a spherical linear interpolation between two vec3's
|
|
293
|
+
*
|
|
294
|
+
* @param out the receiving vector
|
|
295
|
+
* @param a the first operand
|
|
296
|
+
* @param b the second operand
|
|
297
|
+
* @param t interpolation amount, in the range [0-1], between the two inputs
|
|
298
|
+
* @returns out
|
|
299
|
+
*/
|
|
300
|
+
export declare function slerp(out: Vec3, a: Vec3, b: Vec3, t: number): Vec3;
|
|
301
|
+
/**
|
|
302
|
+
* Performs a hermite interpolation with two control points
|
|
303
|
+
*
|
|
304
|
+
* @param out the receiving vector
|
|
305
|
+
* @param a the first operand
|
|
306
|
+
* @param b the second operand
|
|
307
|
+
* @param c the third operand
|
|
308
|
+
* @param d the fourth operand
|
|
309
|
+
* @param t interpolation amount, in the range [0-1], between the two inputs
|
|
310
|
+
* @returns out
|
|
311
|
+
*/
|
|
312
|
+
export declare function hermite(out: Vec3, a: Vec3, b: Vec3, c: Vec3, d: Vec3, t: number): Vec3;
|
|
313
|
+
/**
|
|
314
|
+
* Performs a bezier interpolation with two control points
|
|
315
|
+
*
|
|
316
|
+
* @param out the receiving vector
|
|
317
|
+
* @param a the first operand
|
|
318
|
+
* @param b the second operand
|
|
319
|
+
* @param c the third operand
|
|
320
|
+
* @param d the fourth operand
|
|
321
|
+
* @param t interpolation amount, in the range [0-1], between the two inputs
|
|
322
|
+
* @returns out
|
|
323
|
+
*/
|
|
324
|
+
export declare function bezier(out: Vec3, a: Vec3, b: Vec3, c: Vec3, d: Vec3, t: number): Vec3;
|
|
325
|
+
/**
|
|
326
|
+
* Transforms the vec3 with a mat4.
|
|
327
|
+
* 4th vector component is implicitly '1'
|
|
328
|
+
*
|
|
329
|
+
* @param out the receiving vector
|
|
330
|
+
* @param a the vector to transform
|
|
331
|
+
* @param m matrix to transform with
|
|
332
|
+
* @returns out
|
|
333
|
+
*/
|
|
334
|
+
export declare function transformMat4(out: Vec3, a: Vec3, m: Mat4): Vec3;
|
|
335
|
+
/**
|
|
336
|
+
* Transforms the vec3 with a mat3.
|
|
337
|
+
*
|
|
338
|
+
* @param out the receiving vector
|
|
339
|
+
* @param a the vector to transform
|
|
340
|
+
* @param m the 3x3 matrix to transform with
|
|
341
|
+
* @returns out
|
|
342
|
+
*/
|
|
343
|
+
export declare function transformMat3(out: Vec3, a: Vec3, m: Mat3): Vec3;
|
|
344
|
+
/**
|
|
345
|
+
* Transforms the vec3 with a quat
|
|
346
|
+
* Can also be used for dual quaternions. (Multiply it with the real part)
|
|
347
|
+
*
|
|
348
|
+
* @param out the receiving vector
|
|
349
|
+
* @param a the vector to transform
|
|
350
|
+
* @param q quaternion to transform with
|
|
351
|
+
* @returns out
|
|
352
|
+
*/
|
|
353
|
+
export declare function transformQuat(out: Vec3, a: Vec3, q: Quat): Vec3;
|
|
354
|
+
/**
|
|
355
|
+
* Rotate a 3D vector around the x-axis
|
|
356
|
+
* @param out The receiving vec3
|
|
357
|
+
* @param a The vec3 point to rotate
|
|
358
|
+
* @param b The origin of the rotation
|
|
359
|
+
* @param rad The angle of rotation in radians
|
|
360
|
+
* @returns out
|
|
361
|
+
*/
|
|
362
|
+
export declare function rotateX(out: Vec3, a: Vec3, b: Vec3, rad: number): Vec3;
|
|
363
|
+
/**
|
|
364
|
+
* Rotate a 3D vector around the y-axis
|
|
365
|
+
* @param out The receiving vec3
|
|
366
|
+
* @param a The vec3 point to rotate
|
|
367
|
+
* @param b The origin of the rotation
|
|
368
|
+
* @param rad The angle of rotation in radians
|
|
369
|
+
* @returns out
|
|
370
|
+
*/
|
|
371
|
+
export declare function rotateY(out: Vec3, a: Vec3, b: Vec3, rad: number): Vec3;
|
|
372
|
+
/**
|
|
373
|
+
* Rotate a 3D vector around the z-axis
|
|
374
|
+
* @param out The receiving vec3
|
|
375
|
+
* @param a The vec3 point to rotate
|
|
376
|
+
* @param b The origin of the rotation
|
|
377
|
+
* @param rad The angle of rotation in radians
|
|
378
|
+
* @returns out
|
|
379
|
+
*/
|
|
380
|
+
export declare function rotateZ(out: Vec3, a: Vec3, b: Vec3, rad: number): Vec3;
|
|
381
|
+
/**
|
|
382
|
+
* Get the angle between two 3D vectors
|
|
383
|
+
* @param a The first operand
|
|
384
|
+
* @param b The second operand
|
|
385
|
+
* @returns The angle in radians
|
|
386
|
+
*/
|
|
387
|
+
export declare function angle(a: Vec3, b: Vec3): number;
|
|
388
|
+
/**
|
|
389
|
+
* Get the signed angle from `a` to `b` measured about `axis`, in the range (-PI, PI].
|
|
390
|
+
*
|
|
391
|
+
* Positive is counter-clockwise when `axis` points toward the viewer. Only the components of
|
|
392
|
+
* `a` and `b` in the plane perpendicular to `axis` contribute, so they need not be
|
|
393
|
+
* perpendicular to it. Returns 0 if either projects to the zero vector.
|
|
394
|
+
*
|
|
395
|
+
* Unlike {@link angle}, this distinguishes the two directions of rotation, which is what
|
|
396
|
+
* hinge limits and turn directions need.
|
|
397
|
+
*
|
|
398
|
+
* @param a the first operand
|
|
399
|
+
* @param b the second operand
|
|
400
|
+
* @param axis the axis to measure the rotation about, assumed to be unit length
|
|
401
|
+
* @returns the signed angle in radians
|
|
402
|
+
*/
|
|
403
|
+
export declare function signedAngle(a: Vec3, b: Vec3, axis: Vec3): number;
|
|
404
|
+
/**
|
|
405
|
+
* Rotates the unit vector `from` toward the unit vector `to` by at most `maxAngle` radians.
|
|
406
|
+
*
|
|
407
|
+
* When the two are already within `maxAngle` this copies `to`, so the function doubles as a
|
|
408
|
+
* cone clamp: the result is `to`, limited to lie within `maxAngle` of `from`. That is the form
|
|
409
|
+
* a rotor joint limit and a per-frame turn rate both want.
|
|
410
|
+
*
|
|
411
|
+
* Both inputs are assumed to be unit length, and the result is unit length. `maxAngle` is treated
|
|
412
|
+
* as 0 if negative. When the inputs are exactly antiparallel the rotation plane is undefined
|
|
413
|
+
* and an arbitrary perpendicular is used.
|
|
414
|
+
*
|
|
415
|
+
* @param out the receiving vector
|
|
416
|
+
* @param from the unit vector to rotate away from
|
|
417
|
+
* @param to the unit vector to rotate toward
|
|
418
|
+
* @param maxAngle the maximum rotation, in radians
|
|
419
|
+
* @returns out
|
|
420
|
+
*/
|
|
421
|
+
export declare function rotateTowards(out: Vec3, from: Vec3, to: Vec3, maxAngle: number): Vec3;
|
|
422
|
+
/**
|
|
423
|
+
* Set the components of a vec3 to zero
|
|
424
|
+
*
|
|
425
|
+
* @param out the receiving vector
|
|
426
|
+
* @returns out
|
|
427
|
+
*/
|
|
428
|
+
export declare function zero(out: Vec3): Vec3;
|
|
429
|
+
/**
|
|
430
|
+
* Returns a string representation of a vector
|
|
431
|
+
*
|
|
432
|
+
* @param a vector to represent as a string
|
|
433
|
+
* @returns string representation of the vector
|
|
434
|
+
*/
|
|
435
|
+
export declare function str(a: Vec3): string;
|
|
436
|
+
/**
|
|
437
|
+
* Returns whether or not the vectors have exactly the same elements in the same position (when compared with ===)
|
|
438
|
+
*
|
|
439
|
+
* @param a The first vector.
|
|
440
|
+
* @param b The second vector.
|
|
441
|
+
* @returns True if the vectors are equal, false otherwise.
|
|
442
|
+
*/
|
|
443
|
+
export declare function exactEquals(a: Vec3, b: Vec3): boolean;
|
|
444
|
+
/**
|
|
445
|
+
* Returns whether or not the vectors have approximately the same elements in the same position.
|
|
446
|
+
*
|
|
447
|
+
* @param a The first vector.
|
|
448
|
+
* @param b The second vector.
|
|
449
|
+
* @returns True if the vectors are equal, false otherwise.
|
|
450
|
+
*/
|
|
451
|
+
export declare function equals(a: Vec3, b: Vec3): boolean;
|
|
452
|
+
/**
|
|
453
|
+
* Returns whether or not the vector is finite
|
|
454
|
+
* @param a vector to test
|
|
455
|
+
* @returns whether or not the vector is finite
|
|
456
|
+
*/
|
|
457
|
+
export declare function finite(a: Vec3): boolean;
|
|
458
|
+
/**
|
|
459
|
+
* Determines if a scale vector represents an inside-out transformation (reflection)
|
|
460
|
+
* Returns true if an odd number of scale components are negative
|
|
461
|
+
*
|
|
462
|
+
* @param scale The scale vector to test
|
|
463
|
+
* @returns true if the scale represents a reflection (odd number of negative components)
|
|
464
|
+
*/
|
|
465
|
+
export declare function isScaleInsideOut(scale: Vec3): boolean;
|
|
466
|
+
/**
|
|
467
|
+
* Alias for {@link subtract}
|
|
468
|
+
*/
|
|
469
|
+
export declare const sub: typeof subtract;
|
|
470
|
+
/**
|
|
471
|
+
* Alias for {@link multiply}
|
|
472
|
+
*/
|
|
473
|
+
export declare const mul: typeof multiply;
|
|
474
|
+
/**
|
|
475
|
+
* Alias for {@link divide}
|
|
476
|
+
*/
|
|
477
|
+
export declare const div: typeof divide;
|
|
478
|
+
/**
|
|
479
|
+
* Alias for {@link distance}
|
|
480
|
+
*/
|
|
481
|
+
export declare const dist: typeof distance;
|
|
482
|
+
/**
|
|
483
|
+
* Alias for {@link squaredDistance}
|
|
484
|
+
*/
|
|
485
|
+
export declare const sqrDist: typeof squaredDistance;
|
|
486
|
+
/**
|
|
487
|
+
* Alias for {@link length}
|
|
488
|
+
*/
|
|
489
|
+
export declare const len: typeof length;
|
|
490
|
+
/**
|
|
491
|
+
* Alias for {@link squaredLength}
|
|
492
|
+
*/
|
|
493
|
+
export declare const sqrLen: typeof squaredLength;
|