linearly 0.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/LICENSE +21 -0
- package/README.md +3 -0
- package/lib/common.d.ts +11 -0
- package/lib/common.js +16 -0
- package/lib/index.d.ts +16 -0
- package/lib/index.js +9 -0
- package/lib/mat2.d.ts +78 -0
- package/lib/mat2.js +155 -0
- package/lib/mat2d.d.ts +89 -0
- package/lib/mat2d.js +238 -0
- package/lib/mat2d.test.d.ts +1 -0
- package/lib/mat2d.test.js +88 -0
- package/lib/mat3.d.ts +117 -0
- package/lib/mat3.js +390 -0
- package/lib/mat4.d.ts +310 -0
- package/lib/mat4.js +1173 -0
- package/lib/quat.d.ts +218 -0
- package/lib/quat.js +459 -0
- package/lib/vec2.d.ts +58 -0
- package/lib/vec2.js +135 -0
- package/lib/vec2.test.d.ts +1 -0
- package/lib/vec2.test.js +105 -0
- package/lib/vec3.d.ts +159 -0
- package/lib/vec3.js +326 -0
- package/lib/vec3.test.d.ts +1 -0
- package/lib/vec3.test.js +105 -0
- package/lib/vec4.d.ts +108 -0
- package/lib/vec4.js +241 -0
- package/package.json +50 -0
package/lib/quat.d.ts
ADDED
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import * as Common from './common';
|
|
2
|
+
import type { Mat3 } from './mat3';
|
|
3
|
+
import type { Vec3 } from './vec3';
|
|
4
|
+
import * as vec4 from './vec4';
|
|
5
|
+
export type Quat = readonly [number, number, number, number];
|
|
6
|
+
/**
|
|
7
|
+
* Quaternion in the format XYZW
|
|
8
|
+
* @module quat
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* The identity quaternion
|
|
12
|
+
*/
|
|
13
|
+
export declare const identity: Quat;
|
|
14
|
+
/**
|
|
15
|
+
* Sets a quat from the given angle and rotation axis,
|
|
16
|
+
* then returns it.
|
|
17
|
+
*
|
|
18
|
+
* @param axis the axis around which to rotate
|
|
19
|
+
* @param rad the angle in radians
|
|
20
|
+
**/
|
|
21
|
+
export declare function setAxisAngle(axis: Vec3, rad: number): Quat;
|
|
22
|
+
interface AxisAngle {
|
|
23
|
+
axis: Vec3;
|
|
24
|
+
rad: number;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Gets the rotation axis and angle for a given
|
|
28
|
+
* quaternion. If a quaternion is created with
|
|
29
|
+
* setAxisAngle, this method will return the same
|
|
30
|
+
* values as providied in the original parameter list
|
|
31
|
+
* OR functionally equivalent values.
|
|
32
|
+
* Example: The quaternion formed by axis [0, 0, 1] and
|
|
33
|
+
* angle -90 is the same as the quaternion formed by
|
|
34
|
+
* [0, 0, 1] and 270. This method favors the latter.
|
|
35
|
+
*
|
|
36
|
+
* @param q Quaternion to be decomposed
|
|
37
|
+
*/
|
|
38
|
+
export declare function getAxisAngle(q: Quat): AxisAngle;
|
|
39
|
+
/**
|
|
40
|
+
* Gets the angular distance between two unit quaternions
|
|
41
|
+
*
|
|
42
|
+
* @param a Origin unit quaternion
|
|
43
|
+
* @param b Destination unit quaternion
|
|
44
|
+
* @return Angle, in radians, between the two quaternions
|
|
45
|
+
*/
|
|
46
|
+
export declare function getAngle(a: Quat, b: Quat): number;
|
|
47
|
+
/**
|
|
48
|
+
* Multiplies two quat's
|
|
49
|
+
*
|
|
50
|
+
* @param a the first operand
|
|
51
|
+
* @param b the second operand
|
|
52
|
+
*/
|
|
53
|
+
export declare function multiply(a: Quat, b: Quat): Quat;
|
|
54
|
+
/**
|
|
55
|
+
* Rotates a quaternion by the given angle about the X axis
|
|
56
|
+
*
|
|
57
|
+
* @param a quat to rotate
|
|
58
|
+
* @param rad angle (in radians) to rotate
|
|
59
|
+
*/
|
|
60
|
+
export declare function rotateX(a: Quat, rad: number): Quat;
|
|
61
|
+
/**
|
|
62
|
+
* Rotates a quaternion by the given angle about the Y axis
|
|
63
|
+
*
|
|
64
|
+
* @param a quat to rotate
|
|
65
|
+
* @param rad angle (in radians) to rotate
|
|
66
|
+
*/
|
|
67
|
+
export declare function rotateY(a: Quat, rad: number): Quat;
|
|
68
|
+
/**
|
|
69
|
+
* Rotates a quaternion by the given angle about the Z axis
|
|
70
|
+
*
|
|
71
|
+
* @param a quat to rotate
|
|
72
|
+
* @param rad angle (in radians) to rotate
|
|
73
|
+
*/
|
|
74
|
+
export declare function rotateZ(a: Quat, rad: number): Quat;
|
|
75
|
+
/**
|
|
76
|
+
* Calculates the W component of a quat from the X, Y, and Z components.
|
|
77
|
+
* Assumes that quaternion is 1 unit in length.
|
|
78
|
+
* Any existing W component will be ignored.
|
|
79
|
+
*/
|
|
80
|
+
export declare function calculateW(a: Quat): Quat;
|
|
81
|
+
/**
|
|
82
|
+
* Calculate the exponential of a unit quaternion.
|
|
83
|
+
*/
|
|
84
|
+
export declare function exp(a: Quat): Quat;
|
|
85
|
+
/**
|
|
86
|
+
* Calculate the natural logarithm of a unit quaternion.
|
|
87
|
+
*/
|
|
88
|
+
export declare function ln(a: Quat): Quat;
|
|
89
|
+
/**
|
|
90
|
+
* Calculate the scalar power of a unit quaternion.
|
|
91
|
+
*/
|
|
92
|
+
export declare function pow(a: Quat, b: number): Quat;
|
|
93
|
+
/**
|
|
94
|
+
* Performs a spherical linear interpolation between two quat
|
|
95
|
+
*
|
|
96
|
+
* @param a the first operand
|
|
97
|
+
* @param b the second operand
|
|
98
|
+
* @param t interpolation amount, in the range [0-1], between the two inputs
|
|
99
|
+
*/
|
|
100
|
+
export declare function slerp(a: Quat, b: Quat, t: number): Quat;
|
|
101
|
+
/**
|
|
102
|
+
* Calculates the inverse of a quat
|
|
103
|
+
*/
|
|
104
|
+
export declare function invert(a: Quat): Quat;
|
|
105
|
+
/**
|
|
106
|
+
* Calculates the conjugate of a quat
|
|
107
|
+
* If the quaternion is normalized, this function is faster than quat.inverse and produces the same result.
|
|
108
|
+
*/
|
|
109
|
+
export declare function conjugate(a: Quat): Quat;
|
|
110
|
+
/**
|
|
111
|
+
* Creates a quaternion from the given 3x3 rotation matrix.
|
|
112
|
+
*
|
|
113
|
+
* NOTE: The resultant quaternion is not normalized, so you should be sure
|
|
114
|
+
* to renormalize the quaternion yourself where necessary.
|
|
115
|
+
*/
|
|
116
|
+
export declare function fromMat3(m: Mat3): Quat;
|
|
117
|
+
/**
|
|
118
|
+
* Creates a quaternion from the given euler angle x, y, z using the provided intrinsic order for the conversion.
|
|
119
|
+
*
|
|
120
|
+
* @param x Angle to rotate around X axis in degrees.
|
|
121
|
+
* @param y Angle to rotate around Y axis in degrees.
|
|
122
|
+
* @param z Angle to rotate around Z axis in degrees.
|
|
123
|
+
* @param order Intrinsic order for conversion, default is zyx.
|
|
124
|
+
* @function
|
|
125
|
+
*/
|
|
126
|
+
export declare function fromEuler(x: number, y: number, z: number, order?: Common.AngleOrder): number[];
|
|
127
|
+
/**
|
|
128
|
+
* Adds two quat's
|
|
129
|
+
*/
|
|
130
|
+
export declare const add: (a: Quat, b: Quat) => Quat;
|
|
131
|
+
/**
|
|
132
|
+
* Scales a quat by a scalar number
|
|
133
|
+
*/
|
|
134
|
+
export declare const scale: (a: Quat, b: number) => Quat;
|
|
135
|
+
/**
|
|
136
|
+
* Calculates the dot product of two quat's
|
|
137
|
+
*/
|
|
138
|
+
export declare const dot: (a: Quat, b: Quat) => number;
|
|
139
|
+
/**
|
|
140
|
+
* Performs a linear interpolation between two quat's
|
|
141
|
+
*
|
|
142
|
+
* @param a the first operand
|
|
143
|
+
* @param b the second operand
|
|
144
|
+
* @param t interpolation amount, in the range [0-1], between the two inputs
|
|
145
|
+
*/
|
|
146
|
+
export declare const lerp: (a: Quat, b: Quat, t: number) => Quat;
|
|
147
|
+
/**
|
|
148
|
+
* Calculates the length of a quat
|
|
149
|
+
*
|
|
150
|
+
* @param a vector to calculate length of
|
|
151
|
+
* @returns length of a
|
|
152
|
+
*/
|
|
153
|
+
export declare const length: typeof vec4.length;
|
|
154
|
+
/**
|
|
155
|
+
* Alias for {@link quat.length}
|
|
156
|
+
* @function
|
|
157
|
+
*/
|
|
158
|
+
export declare const len: typeof vec4.length;
|
|
159
|
+
/**
|
|
160
|
+
* Calculates the squared length of a quat
|
|
161
|
+
*
|
|
162
|
+
* @param a vector to calculate squared length of
|
|
163
|
+
* @returns squared length of a
|
|
164
|
+
* @function
|
|
165
|
+
*/
|
|
166
|
+
export declare const squaredLength: typeof vec4.squaredLength;
|
|
167
|
+
/**
|
|
168
|
+
* Alias for {@link quat.squaredLength}
|
|
169
|
+
* @function
|
|
170
|
+
*/
|
|
171
|
+
export declare const sqrLen: typeof vec4.squaredLength;
|
|
172
|
+
/**
|
|
173
|
+
* Normalize a quat
|
|
174
|
+
*
|
|
175
|
+
* @param a quaternion to normalize
|
|
176
|
+
*/
|
|
177
|
+
export declare const normalize: typeof vec4.normalize;
|
|
178
|
+
/**
|
|
179
|
+
* Returns whether or not the quaternions have exactly the same elements in the same position (when compared with ===)
|
|
180
|
+
*/
|
|
181
|
+
export declare const exactEquals: typeof vec4.exactEquals;
|
|
182
|
+
/**
|
|
183
|
+
* Returns whether or not the quaternions point approximately to the same direction.
|
|
184
|
+
*
|
|
185
|
+
* Both quaternions are assumed to be unit length.
|
|
186
|
+
*/
|
|
187
|
+
export declare function equals(a: Quat, b: Quat): boolean;
|
|
188
|
+
/**
|
|
189
|
+
* Sets a quaternion to represent the shortest rotation from one
|
|
190
|
+
* vector to another.
|
|
191
|
+
*
|
|
192
|
+
* Both vectors are assumed to be unit length.
|
|
193
|
+
*
|
|
194
|
+
* @param a the initial vector
|
|
195
|
+
* @param b the destination vector
|
|
196
|
+
*/
|
|
197
|
+
export declare const rotationTo: (a: Vec3, b: Vec3) => Quat;
|
|
198
|
+
/**
|
|
199
|
+
* Performs a spherical linear interpolation with two control points
|
|
200
|
+
*
|
|
201
|
+
* @param a the first operand
|
|
202
|
+
* @param b the second operand
|
|
203
|
+
* @param c the third operand
|
|
204
|
+
* @param d the fourth operand
|
|
205
|
+
* @param t interpolation amount, in the range [0-1], between the two inputs
|
|
206
|
+
*/
|
|
207
|
+
export declare function sqlerp(a: Quat, b: Quat, c: Quat, d: Quat, t: number): Quat;
|
|
208
|
+
/**
|
|
209
|
+
* Sets the specified quaternion with values corresponding to the given
|
|
210
|
+
* axes. Each axis is a vec3 and is expected to be unit length and
|
|
211
|
+
* perpendicular to all other specified axes.
|
|
212
|
+
*
|
|
213
|
+
* @param view the vector representing the viewing direction
|
|
214
|
+
* @param right the vector representing the local "right" direction
|
|
215
|
+
* @param up the vector representing the local "up" direction
|
|
216
|
+
*/
|
|
217
|
+
export declare function setAxes(view: Vec3, right: Vec3, up: Vec3): Quat;
|
|
218
|
+
export {};
|