linearly 0.3.0 → 0.4.1

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