@pawells/math-extended 1.1.1 → 3.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/README.md +15 -21
- package/build/angles.d.ts +28 -18
- package/build/angles.d.ts.map +1 -1
- package/build/angles.js +28 -18
- package/build/angles.js.map +1 -1
- package/build/clamp.d.ts +2 -0
- package/build/clamp.d.ts.map +1 -1
- package/build/clamp.js +2 -0
- package/build/clamp.js.map +1 -1
- package/build/core.d.ts +23 -0
- package/build/core.d.ts.map +1 -0
- package/build/core.js +25 -0
- package/build/core.js.map +1 -0
- package/build/index.d.ts +1 -4
- package/build/index.d.ts.map +1 -1
- package/build/index.js +1 -6
- package/build/index.js.map +1 -1
- package/build/interpolation.d.ts +62 -13
- package/build/interpolation.d.ts.map +1 -1
- package/build/interpolation.js +66 -23
- package/build/interpolation.js.map +1 -1
- package/build/matrices/arithmetic.d.ts +65 -76
- package/build/matrices/arithmetic.d.ts.map +1 -1
- package/build/matrices/arithmetic.js +65 -107
- package/build/matrices/arithmetic.js.map +1 -1
- package/build/matrices/asserts.d.ts +26 -273
- package/build/matrices/asserts.d.ts.map +1 -1
- package/build/matrices/asserts.js +106 -350
- package/build/matrices/asserts.js.map +1 -1
- package/build/matrices/core.d.ts +150 -79
- package/build/matrices/core.d.ts.map +1 -1
- package/build/matrices/core.js +128 -104
- package/build/matrices/core.js.map +1 -1
- package/build/matrices/decompositions.d.ts +41 -44
- package/build/matrices/decompositions.d.ts.map +1 -1
- package/build/matrices/decompositions.js +51 -94
- package/build/matrices/decompositions.js.map +1 -1
- package/build/matrices/index.d.ts +2 -2
- package/build/matrices/index.d.ts.map +1 -1
- package/build/matrices/index.js +2 -2
- package/build/matrices/index.js.map +1 -1
- package/build/matrices/linear-algebra.d.ts +56 -19
- package/build/matrices/linear-algebra.d.ts.map +1 -1
- package/build/matrices/linear-algebra.js +80 -36
- package/build/matrices/linear-algebra.js.map +1 -1
- package/build/matrices/normalization.d.ts +36 -15
- package/build/matrices/normalization.d.ts.map +1 -1
- package/build/matrices/normalization.js +32 -23
- package/build/matrices/normalization.js.map +1 -1
- package/build/matrices/transformations.d.ts +39 -52
- package/build/matrices/transformations.d.ts.map +1 -1
- package/build/matrices/transformations.js +8 -11
- package/build/matrices/transformations.js.map +1 -1
- package/build/matrices/types.d.ts +39 -67
- package/build/matrices/types.d.ts.map +1 -1
- package/build/matrices/types.js +63 -1
- package/build/matrices/types.js.map +1 -1
- package/build/quaternions/asserts.d.ts +114 -15
- package/build/quaternions/asserts.d.ts.map +1 -1
- package/build/quaternions/asserts.js +189 -51
- package/build/quaternions/asserts.js.map +1 -1
- package/build/quaternions/conversions.d.ts +18 -8
- package/build/quaternions/conversions.d.ts.map +1 -1
- package/build/quaternions/conversions.js +14 -4
- package/build/quaternions/conversions.js.map +1 -1
- package/build/quaternions/core.d.ts +31 -2
- package/build/quaternions/core.d.ts.map +1 -1
- package/build/quaternions/core.js +32 -4
- package/build/quaternions/core.js.map +1 -1
- package/build/quaternions/index.d.ts +2 -2
- package/build/quaternions/index.d.ts.map +1 -1
- package/build/quaternions/index.js +3 -2
- package/build/quaternions/index.js.map +1 -1
- package/build/quaternions/interpolation.d.ts +7 -1
- package/build/quaternions/interpolation.d.ts.map +1 -1
- package/build/quaternions/interpolation.js +12 -6
- package/build/quaternions/interpolation.js.map +1 -1
- package/build/quaternions/predefined.d.ts +7 -1
- package/build/quaternions/predefined.d.ts.map +1 -1
- package/build/quaternions/predefined.js +6 -0
- package/build/quaternions/predefined.js.map +1 -1
- package/build/quaternions/types.d.ts +24 -13
- package/build/quaternions/types.d.ts.map +1 -1
- package/build/quaternions/types.js +51 -1
- package/build/quaternions/types.js.map +1 -1
- package/build/random.d.ts +66 -20
- package/build/random.d.ts.map +1 -1
- package/build/random.js +73 -20
- package/build/random.js.map +1 -1
- package/build/vectors/asserts.d.ts +33 -99
- package/build/vectors/asserts.d.ts.map +1 -1
- package/build/vectors/asserts.js +145 -181
- package/build/vectors/asserts.js.map +1 -1
- package/build/vectors/core.d.ts +76 -44
- package/build/vectors/core.d.ts.map +1 -1
- package/build/vectors/core.js +128 -119
- package/build/vectors/core.js.map +1 -1
- package/build/vectors/index.d.ts.map +1 -1
- package/build/vectors/index.js +1 -0
- package/build/vectors/index.js.map +1 -1
- package/build/vectors/interpolation.d.ts +13 -1
- package/build/vectors/interpolation.d.ts.map +1 -1
- package/build/vectors/interpolation.js +48 -47
- package/build/vectors/interpolation.js.map +1 -1
- package/build/vectors/predefined.d.ts +73 -25
- package/build/vectors/predefined.d.ts.map +1 -1
- package/build/vectors/predefined.js +62 -18
- package/build/vectors/predefined.js.map +1 -1
- package/build/vectors/types.d.ts +26 -4
- package/build/vectors/types.d.ts.map +1 -1
- package/build/vectors/types.js +50 -1
- package/build/vectors/types.js.map +1 -1
- package/package.json +4 -3
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
* Core quaternion mathematics operations for rotation and orientation calculations.
|
|
3
3
|
* Provides comprehensive quaternion operations with conversion utilities and interpolation.
|
|
4
4
|
*/
|
|
5
|
-
import { TVector3 } from '../vectors/types.js';
|
|
6
|
-
import { TQuaternion, TEulerAngles, TAxisAngle } from './types.js';
|
|
5
|
+
import type { TVector3 } from '../vectors/types.js';
|
|
6
|
+
import type { TQuaternion, TEulerAngles, TAxisAngle } from './types.js';
|
|
7
|
+
export declare const QUATERNION_TOLERANCE = 0.000001;
|
|
7
8
|
/**
|
|
8
9
|
* Creates an identity quaternion representing no rotation.
|
|
9
10
|
* The identity quaternion is [0, 0, 0, 1] (x, y, z, w).
|
|
@@ -11,8 +12,10 @@ import { TQuaternion, TEulerAngles, TAxisAngle } from './types.js';
|
|
|
11
12
|
* @returns Identity quaternion [0, 0, 0, 1]
|
|
12
13
|
*
|
|
13
14
|
* @example
|
|
15
|
+
* ```typescript
|
|
14
16
|
* const identity = QuaternionIdentity();
|
|
15
17
|
* console.log(identity); // [0, 0, 0, 1]
|
|
18
|
+
* ```
|
|
16
19
|
*/
|
|
17
20
|
export declare function QuaternionIdentity(): TQuaternion;
|
|
18
21
|
/**
|
|
@@ -23,9 +26,11 @@ export declare function QuaternionIdentity(): TQuaternion;
|
|
|
23
26
|
* @returns A new quaternion with identical components
|
|
24
27
|
*
|
|
25
28
|
* @example
|
|
29
|
+
* ```typescript
|
|
26
30
|
* const original = [0, 0, 0.707, 0.707];
|
|
27
31
|
* const copy = QuaternionClone(original);
|
|
28
32
|
* copy[0] = 1; // original remains unchanged
|
|
33
|
+
* ```
|
|
29
34
|
*/
|
|
30
35
|
export declare function QuaternionClone(quaternion: TQuaternion): TQuaternion;
|
|
31
36
|
/**
|
|
@@ -40,10 +45,12 @@ export declare function QuaternionClone(quaternion: TQuaternion): TQuaternion;
|
|
|
40
45
|
* @returns True if quaternions are equal within tolerance
|
|
41
46
|
*
|
|
42
47
|
* @example
|
|
48
|
+
* ```typescript
|
|
43
49
|
* const q1 = [0, 0, 0, 1];
|
|
44
50
|
* const q2 = [0, 0, 0, -1];
|
|
45
51
|
* console.log(QuaternionEquals(q1, q2)); // false (different components)
|
|
46
52
|
* console.log(QuaternionEquals(q1, q2, 1e-6, true)); // true (same rotation)
|
|
53
|
+
* ```
|
|
47
54
|
*/
|
|
48
55
|
export declare function QuaternionEquals(a: TQuaternion, b: TQuaternion, tolerance?: number, checkEquivalence?: boolean): boolean;
|
|
49
56
|
/**
|
|
@@ -54,8 +61,10 @@ export declare function QuaternionEquals(a: TQuaternion, b: TQuaternion, toleran
|
|
|
54
61
|
* @returns The magnitude of the quaternion
|
|
55
62
|
*
|
|
56
63
|
* @example
|
|
64
|
+
* ```typescript
|
|
57
65
|
* const q = [0, 0, 0, 1];
|
|
58
66
|
* console.log(QuaternionMagnitude(q)); // 1
|
|
67
|
+
* ```
|
|
59
68
|
*/
|
|
60
69
|
export declare function QuaternionMagnitude(quaternion: TQuaternion): number;
|
|
61
70
|
/**
|
|
@@ -66,9 +75,11 @@ export declare function QuaternionMagnitude(quaternion: TQuaternion): number;
|
|
|
66
75
|
* @returns A normalized quaternion with magnitude 1
|
|
67
76
|
*
|
|
68
77
|
* @example
|
|
78
|
+
* ```typescript
|
|
69
79
|
* const q = [1, 1, 1, 1];
|
|
70
80
|
* const normalized = QuaternionNormalize(q);
|
|
71
81
|
* console.log(QuaternionMagnitude(normalized)); // 1
|
|
82
|
+
* ```
|
|
72
83
|
*/
|
|
73
84
|
export declare function QuaternionNormalize(quaternion: TQuaternion): TQuaternion;
|
|
74
85
|
/**
|
|
@@ -80,9 +91,11 @@ export declare function QuaternionNormalize(quaternion: TQuaternion): TQuaternio
|
|
|
80
91
|
* @returns The conjugate quaternion
|
|
81
92
|
*
|
|
82
93
|
* @example
|
|
94
|
+
* ```typescript
|
|
83
95
|
* const q = [0.5, 0.5, 0.5, 0.5];
|
|
84
96
|
* const conjugate = QuaternionConjugate(q);
|
|
85
97
|
* console.log(conjugate); // [-0.5, -0.5, -0.5, 0.5]
|
|
98
|
+
* ```
|
|
86
99
|
*/
|
|
87
100
|
export declare function QuaternionConjugate(quaternion: TQuaternion): TQuaternion;
|
|
88
101
|
/**
|
|
@@ -94,8 +107,10 @@ export declare function QuaternionConjugate(quaternion: TQuaternion): TQuaternio
|
|
|
94
107
|
* @returns The inverse quaternion
|
|
95
108
|
*
|
|
96
109
|
* @example
|
|
110
|
+
* ```typescript
|
|
97
111
|
* const q = [0, 0, 0.707, 0.707]; // 90° rotation around Z
|
|
98
112
|
* const inverse = QuaternionInverse(q); // -90° rotation around Z
|
|
113
|
+
* ```
|
|
99
114
|
*/
|
|
100
115
|
export declare function QuaternionInverse(quaternion: TQuaternion): TQuaternion;
|
|
101
116
|
/**
|
|
@@ -108,9 +123,11 @@ export declare function QuaternionInverse(quaternion: TQuaternion): TQuaternion;
|
|
|
108
123
|
* @returns The product quaternion representing the combined rotation
|
|
109
124
|
*
|
|
110
125
|
* @example
|
|
126
|
+
* ```typescript
|
|
111
127
|
* const rotX = QuaternionFromAxisAngle([1, 0, 0], Math.PI/2); // 90° around X
|
|
112
128
|
* const rotY = QuaternionFromAxisAngle([0, 1, 0], Math.PI/2); // 90° around Y
|
|
113
129
|
* const combined = QuaternionMultiply(rotX, rotY); // Y rotation then X rotation
|
|
130
|
+
* ```
|
|
114
131
|
*/
|
|
115
132
|
export declare function QuaternionMultiply(a: TQuaternion, b: TQuaternion): TQuaternion;
|
|
116
133
|
/**
|
|
@@ -122,9 +139,11 @@ export declare function QuaternionMultiply(a: TQuaternion, b: TQuaternion): TQua
|
|
|
122
139
|
* @returns A quaternion representing the rotation
|
|
123
140
|
*
|
|
124
141
|
* @example
|
|
142
|
+
* ```typescript
|
|
125
143
|
* const axis = [0, 1, 0]; // Y-axis
|
|
126
144
|
* const angle = Math.PI / 2; // 90 degrees
|
|
127
145
|
* const q = QuaternionFromAxisAngle(axis, angle);
|
|
146
|
+
* ```
|
|
128
147
|
*/
|
|
129
148
|
export declare function QuaternionFromAxisAngle(axis: TVector3, angle: number): TQuaternion;
|
|
130
149
|
/**
|
|
@@ -145,9 +164,11 @@ export declare function QuaternionFromAxisAngleVector(axisAngle: TAxisAngle): TQ
|
|
|
145
164
|
* @throws {Error} If the quaternion is not normalized
|
|
146
165
|
*
|
|
147
166
|
* @example
|
|
167
|
+
* ```typescript
|
|
148
168
|
* const q = [0, 0.707, 0, 0.707]; // 90° around Y-axis
|
|
149
169
|
* const axisAngle = QuaternionToAxisAngle(q);
|
|
150
170
|
* console.log(axisAngle); // [0, 1, 0, π/2]
|
|
171
|
+
* ```
|
|
151
172
|
*/
|
|
152
173
|
export declare function QuaternionToAxisAngle(quaternion: TQuaternion): TAxisAngle;
|
|
153
174
|
/**
|
|
@@ -158,8 +179,10 @@ export declare function QuaternionToAxisAngle(quaternion: TQuaternion): TAxisAng
|
|
|
158
179
|
* @returns A quaternion representing the rotation
|
|
159
180
|
*
|
|
160
181
|
* @example
|
|
182
|
+
* ```typescript
|
|
161
183
|
* const euler = [0, Math.PI/4, 0]; // 45° pitch
|
|
162
184
|
* const q = QuaternionFromEuler(euler);
|
|
185
|
+
* ```
|
|
163
186
|
*/
|
|
164
187
|
export declare function QuaternionFromEuler(euler: TEulerAngles): TQuaternion;
|
|
165
188
|
/**
|
|
@@ -170,9 +193,11 @@ export declare function QuaternionFromEuler(euler: TEulerAngles): TQuaternion;
|
|
|
170
193
|
* @returns Euler angles as [x, y, z] in radians
|
|
171
194
|
*
|
|
172
195
|
* @example
|
|
196
|
+
* ```typescript
|
|
173
197
|
* const q = [0, 0.383, 0, 0.924]; // ~45° around Y-axis
|
|
174
198
|
* const euler = QuaternionToEuler(q);
|
|
175
199
|
* console.log(euler); // [0, π/4, 0]
|
|
200
|
+
* ```
|
|
176
201
|
*/
|
|
177
202
|
export declare function QuaternionToEuler(quaternion: TQuaternion): TEulerAngles;
|
|
178
203
|
/**
|
|
@@ -184,9 +209,11 @@ export declare function QuaternionToEuler(quaternion: TQuaternion): TEulerAngles
|
|
|
184
209
|
* @returns The rotated vector
|
|
185
210
|
*
|
|
186
211
|
* @example
|
|
212
|
+
* ```typescript
|
|
187
213
|
* const q = QuaternionFromAxisAngle([0, 0, 1], Math.PI/2); // 90° around Z
|
|
188
214
|
* const v = [1, 0, 0]; // Point along X-axis
|
|
189
215
|
* const rotated = QuaternionRotateVector(q, v); // Should point along Y-axis
|
|
216
|
+
* ```
|
|
190
217
|
*/
|
|
191
218
|
export declare function QuaternionRotateVector(quaternion: TQuaternion, vector: TVector3): TVector3;
|
|
192
219
|
/**
|
|
@@ -199,9 +226,11 @@ export declare function QuaternionRotateVector(quaternion: TQuaternion, vector:
|
|
|
199
226
|
* @returns Interpolated quaternion
|
|
200
227
|
*
|
|
201
228
|
* @example
|
|
229
|
+
* ```typescript
|
|
202
230
|
* const q1 = QuaternionIdentity();
|
|
203
231
|
* const q2 = QuaternionFromAxisAngle([0, 1, 0], Math.PI/2);
|
|
204
232
|
* const halfway = QuaternionSLERP(q1, q2, 0.5); // 45° rotation
|
|
233
|
+
* ```
|
|
205
234
|
*/
|
|
206
235
|
export declare function QuaternionSLERP(a: TQuaternion, b: TQuaternion, t: number): TQuaternion;
|
|
207
236
|
//# sourceMappingURL=core.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../src/quaternions/core.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../src/quaternions/core.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAGxE,eAAO,MAAM,oBAAoB,WAAO,CAAC;AAGzC;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,IAAI,WAAW,CAEhD;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,WAAW,GAAG,WAAW,CAGpE;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,WAAW,EAAE,SAAS,GAAE,MAAa,EAAE,gBAAgB,GAAE,OAAe,GAAG,OAAO,CAcrI;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,WAAW,GAAG,MAAM,CAGnE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,WAAW,GAAG,WAAW,CAGxE;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,WAAW,GAAG,WAAW,CAKxE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,WAAW,GAAG,WAAW,CAiBtE;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,WAAW,GAAG,WAAW,CAa9E;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,GAAG,WAAW,CAYlF;AAED;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAAC,SAAS,EAAE,UAAU,GAAG,WAAW,CAKhF;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,WAAW,GAAG,UAAU,CA4BzE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,YAAY,GAAG,WAAW,CAiBpE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,WAAW,GAAG,YAAY,CAoBvE;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,GAAG,QAAQ,CAsB1F;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,MAAM,GAAG,WAAW,CAwCtF"}
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
* Provides comprehensive quaternion operations with conversion utilities and interpolation.
|
|
4
4
|
*/
|
|
5
5
|
import { VectorClone, VectorDot, VectorMagnitude, VectorNormalize, VectorEquals, Vector3Cross } from '../vectors/core.js';
|
|
6
|
-
import { AssertQuaternion, AssertNormalizedQuaternion, AssertEulerAngles, AssertAxisAngle } from './asserts.js';
|
|
6
|
+
import { AssertQuaternion, AssertNormalizedQuaternion, AssertEulerAngles, AssertAxisAngle, QuaternionError } from './asserts.js';
|
|
7
7
|
const QUATERNION_MAGNITUDE_TOLERANCE = 1e-10;
|
|
8
|
-
const
|
|
8
|
+
export const QUATERNION_TOLERANCE = 1e-6;
|
|
9
9
|
const SLERP_DOT_THRESHOLD = 0.9995;
|
|
10
10
|
/**
|
|
11
11
|
* Creates an identity quaternion representing no rotation.
|
|
@@ -14,8 +14,10 @@ const SLERP_DOT_THRESHOLD = 0.9995;
|
|
|
14
14
|
* @returns Identity quaternion [0, 0, 0, 1]
|
|
15
15
|
*
|
|
16
16
|
* @example
|
|
17
|
+
* ```typescript
|
|
17
18
|
* const identity = QuaternionIdentity();
|
|
18
19
|
* console.log(identity); // [0, 0, 0, 1]
|
|
20
|
+
* ```
|
|
19
21
|
*/
|
|
20
22
|
export function QuaternionIdentity() {
|
|
21
23
|
return [0, 0, 0, 1];
|
|
@@ -28,9 +30,11 @@ export function QuaternionIdentity() {
|
|
|
28
30
|
* @returns A new quaternion with identical components
|
|
29
31
|
*
|
|
30
32
|
* @example
|
|
33
|
+
* ```typescript
|
|
31
34
|
* const original = [0, 0, 0.707, 0.707];
|
|
32
35
|
* const copy = QuaternionClone(original);
|
|
33
36
|
* copy[0] = 1; // original remains unchanged
|
|
37
|
+
* ```
|
|
34
38
|
*/
|
|
35
39
|
export function QuaternionClone(quaternion) {
|
|
36
40
|
AssertQuaternion(quaternion);
|
|
@@ -48,10 +52,12 @@ export function QuaternionClone(quaternion) {
|
|
|
48
52
|
* @returns True if quaternions are equal within tolerance
|
|
49
53
|
*
|
|
50
54
|
* @example
|
|
55
|
+
* ```typescript
|
|
51
56
|
* const q1 = [0, 0, 0, 1];
|
|
52
57
|
* const q2 = [0, 0, 0, -1];
|
|
53
58
|
* console.log(QuaternionEquals(q1, q2)); // false (different components)
|
|
54
59
|
* console.log(QuaternionEquals(q1, q2, 1e-6, true)); // true (same rotation)
|
|
60
|
+
* ```
|
|
55
61
|
*/
|
|
56
62
|
export function QuaternionEquals(a, b, tolerance = 1e-6, checkEquivalence = false) {
|
|
57
63
|
AssertQuaternion(a);
|
|
@@ -73,8 +79,10 @@ export function QuaternionEquals(a, b, tolerance = 1e-6, checkEquivalence = fals
|
|
|
73
79
|
* @returns The magnitude of the quaternion
|
|
74
80
|
*
|
|
75
81
|
* @example
|
|
82
|
+
* ```typescript
|
|
76
83
|
* const q = [0, 0, 0, 1];
|
|
77
84
|
* console.log(QuaternionMagnitude(q)); // 1
|
|
85
|
+
* ```
|
|
78
86
|
*/
|
|
79
87
|
export function QuaternionMagnitude(quaternion) {
|
|
80
88
|
AssertQuaternion(quaternion);
|
|
@@ -88,9 +96,11 @@ export function QuaternionMagnitude(quaternion) {
|
|
|
88
96
|
* @returns A normalized quaternion with magnitude 1
|
|
89
97
|
*
|
|
90
98
|
* @example
|
|
99
|
+
* ```typescript
|
|
91
100
|
* const q = [1, 1, 1, 1];
|
|
92
101
|
* const normalized = QuaternionNormalize(q);
|
|
93
102
|
* console.log(QuaternionMagnitude(normalized)); // 1
|
|
103
|
+
* ```
|
|
94
104
|
*/
|
|
95
105
|
export function QuaternionNormalize(quaternion) {
|
|
96
106
|
AssertQuaternion(quaternion);
|
|
@@ -105,9 +115,11 @@ export function QuaternionNormalize(quaternion) {
|
|
|
105
115
|
* @returns The conjugate quaternion
|
|
106
116
|
*
|
|
107
117
|
* @example
|
|
118
|
+
* ```typescript
|
|
108
119
|
* const q = [0.5, 0.5, 0.5, 0.5];
|
|
109
120
|
* const conjugate = QuaternionConjugate(q);
|
|
110
121
|
* console.log(conjugate); // [-0.5, -0.5, -0.5, 0.5]
|
|
122
|
+
* ```
|
|
111
123
|
*/
|
|
112
124
|
export function QuaternionConjugate(quaternion) {
|
|
113
125
|
AssertQuaternion(quaternion);
|
|
@@ -123,15 +135,17 @@ export function QuaternionConjugate(quaternion) {
|
|
|
123
135
|
* @returns The inverse quaternion
|
|
124
136
|
*
|
|
125
137
|
* @example
|
|
138
|
+
* ```typescript
|
|
126
139
|
* const q = [0, 0, 0.707, 0.707]; // 90° rotation around Z
|
|
127
140
|
* const inverse = QuaternionInverse(q); // -90° rotation around Z
|
|
141
|
+
* ```
|
|
128
142
|
*/
|
|
129
143
|
export function QuaternionInverse(quaternion) {
|
|
130
144
|
AssertQuaternion(quaternion);
|
|
131
145
|
const conjugate = QuaternionConjugate(quaternion);
|
|
132
146
|
const magnitudeSquared = VectorDot(quaternion, quaternion);
|
|
133
147
|
if (Math.abs(magnitudeSquared) < QUATERNION_MAGNITUDE_TOLERANCE) {
|
|
134
|
-
throw new
|
|
148
|
+
throw new QuaternionError('Cannot invert quaternion with zero magnitude');
|
|
135
149
|
}
|
|
136
150
|
// For unit quaternions, magnitude squared is 1, so this is just the conjugate
|
|
137
151
|
return [
|
|
@@ -151,9 +165,11 @@ export function QuaternionInverse(quaternion) {
|
|
|
151
165
|
* @returns The product quaternion representing the combined rotation
|
|
152
166
|
*
|
|
153
167
|
* @example
|
|
168
|
+
* ```typescript
|
|
154
169
|
* const rotX = QuaternionFromAxisAngle([1, 0, 0], Math.PI/2); // 90° around X
|
|
155
170
|
* const rotY = QuaternionFromAxisAngle([0, 1, 0], Math.PI/2); // 90° around Y
|
|
156
171
|
* const combined = QuaternionMultiply(rotX, rotY); // Y rotation then X rotation
|
|
172
|
+
* ```
|
|
157
173
|
*/
|
|
158
174
|
export function QuaternionMultiply(a, b) {
|
|
159
175
|
AssertQuaternion(a);
|
|
@@ -176,9 +192,11 @@ export function QuaternionMultiply(a, b) {
|
|
|
176
192
|
* @returns A quaternion representing the rotation
|
|
177
193
|
*
|
|
178
194
|
* @example
|
|
195
|
+
* ```typescript
|
|
179
196
|
* const axis = [0, 1, 0]; // Y-axis
|
|
180
197
|
* const angle = Math.PI / 2; // 90 degrees
|
|
181
198
|
* const q = QuaternionFromAxisAngle(axis, angle);
|
|
199
|
+
* ```
|
|
182
200
|
*/
|
|
183
201
|
export function QuaternionFromAxisAngle(axis, angle) {
|
|
184
202
|
const normalizedAxis = VectorNormalize(axis);
|
|
@@ -214,9 +232,11 @@ export function QuaternionFromAxisAngleVector(axisAngle) {
|
|
|
214
232
|
* @throws {Error} If the quaternion is not normalized
|
|
215
233
|
*
|
|
216
234
|
* @example
|
|
235
|
+
* ```typescript
|
|
217
236
|
* const q = [0, 0.707, 0, 0.707]; // 90° around Y-axis
|
|
218
237
|
* const axisAngle = QuaternionToAxisAngle(q);
|
|
219
238
|
* console.log(axisAngle); // [0, 1, 0, π/2]
|
|
239
|
+
* ```
|
|
220
240
|
*/
|
|
221
241
|
export function QuaternionToAxisAngle(quaternion) {
|
|
222
242
|
AssertNormalizedQuaternion(quaternion);
|
|
@@ -230,7 +250,7 @@ export function QuaternionToAxisAngle(quaternion) {
|
|
|
230
250
|
}
|
|
231
251
|
const angle = 2 * Math.acos(Math.min(1, qw));
|
|
232
252
|
const sinHalfAngle = Math.sqrt(1 - (qw * qw));
|
|
233
|
-
if (sinHalfAngle <
|
|
253
|
+
if (sinHalfAngle < QUATERNION_TOLERANCE) {
|
|
234
254
|
// Avoid division by zero for small angles
|
|
235
255
|
return [1, 0, 0, 0];
|
|
236
256
|
}
|
|
@@ -249,8 +269,10 @@ export function QuaternionToAxisAngle(quaternion) {
|
|
|
249
269
|
* @returns A quaternion representing the rotation
|
|
250
270
|
*
|
|
251
271
|
* @example
|
|
272
|
+
* ```typescript
|
|
252
273
|
* const euler = [0, Math.PI/4, 0]; // 45° pitch
|
|
253
274
|
* const q = QuaternionFromEuler(euler);
|
|
275
|
+
* ```
|
|
254
276
|
*/
|
|
255
277
|
export function QuaternionFromEuler(euler) {
|
|
256
278
|
AssertEulerAngles(euler);
|
|
@@ -276,9 +298,11 @@ export function QuaternionFromEuler(euler) {
|
|
|
276
298
|
* @returns Euler angles as [x, y, z] in radians
|
|
277
299
|
*
|
|
278
300
|
* @example
|
|
301
|
+
* ```typescript
|
|
279
302
|
* const q = [0, 0.383, 0, 0.924]; // ~45° around Y-axis
|
|
280
303
|
* const euler = QuaternionToEuler(q);
|
|
281
304
|
* console.log(euler); // [0, π/4, 0]
|
|
305
|
+
* ```
|
|
282
306
|
*/
|
|
283
307
|
export function QuaternionToEuler(quaternion) {
|
|
284
308
|
AssertNormalizedQuaternion(quaternion);
|
|
@@ -305,9 +329,11 @@ export function QuaternionToEuler(quaternion) {
|
|
|
305
329
|
* @returns The rotated vector
|
|
306
330
|
*
|
|
307
331
|
* @example
|
|
332
|
+
* ```typescript
|
|
308
333
|
* const q = QuaternionFromAxisAngle([0, 0, 1], Math.PI/2); // 90° around Z
|
|
309
334
|
* const v = [1, 0, 0]; // Point along X-axis
|
|
310
335
|
* const rotated = QuaternionRotateVector(q, v); // Should point along Y-axis
|
|
336
|
+
* ```
|
|
311
337
|
*/
|
|
312
338
|
export function QuaternionRotateVector(quaternion, vector) {
|
|
313
339
|
AssertNormalizedQuaternion(quaternion);
|
|
@@ -339,9 +365,11 @@ export function QuaternionRotateVector(quaternion, vector) {
|
|
|
339
365
|
* @returns Interpolated quaternion
|
|
340
366
|
*
|
|
341
367
|
* @example
|
|
368
|
+
* ```typescript
|
|
342
369
|
* const q1 = QuaternionIdentity();
|
|
343
370
|
* const q2 = QuaternionFromAxisAngle([0, 1, 0], Math.PI/2);
|
|
344
371
|
* const halfway = QuaternionSLERP(q1, q2, 0.5); // 45° rotation
|
|
372
|
+
* ```
|
|
345
373
|
*/
|
|
346
374
|
export function QuaternionSLERP(a, b, t) {
|
|
347
375
|
AssertNormalizedQuaternion(a);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.js","sourceRoot":"","sources":["../../src/quaternions/core.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,eAAe,EAAE,eAAe,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAE1H,OAAO,EAAE,gBAAgB,EAAE,0BAA0B,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"core.js","sourceRoot":"","sources":["../../src/quaternions/core.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,E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,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
export * from './types.js';
|
|
2
|
+
export * from './core.js';
|
|
1
3
|
export * from './asserts.js';
|
|
2
4
|
export * from './conversions.js';
|
|
3
|
-
export * from './core.js';
|
|
4
5
|
export * from './interpolation.js';
|
|
5
6
|
export * from './predefined.js';
|
|
6
|
-
export * from './types.js';
|
|
7
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/quaternions/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/quaternions/index.ts"],"names":[],"mappings":"AACA,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
// Named re-exports for direct access
|
|
2
|
+
export * from './types.js';
|
|
3
|
+
export * from './core.js';
|
|
1
4
|
export * from './asserts.js';
|
|
2
5
|
export * from './conversions.js';
|
|
3
|
-
export * from './core.js';
|
|
4
6
|
export * from './interpolation.js';
|
|
5
7
|
export * from './predefined.js';
|
|
6
|
-
export * from './types.js';
|
|
7
8
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/quaternions/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/quaternions/index.ts"],"names":[],"mappings":"AAAA,qCAAqC;AACrC,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Advanced interpolation utilities for quaternions.
|
|
3
3
|
* Provides specialized interpolation methods for smooth rotation animations.
|
|
4
4
|
*/
|
|
5
|
-
import { TQuaternion } from './types.js';
|
|
5
|
+
import type { TQuaternion } from './types.js';
|
|
6
6
|
/**
|
|
7
7
|
* Performs normalized linear interpolation (NLERP) between two quaternions.
|
|
8
8
|
* NLERP is faster than SLERP but doesn't maintain constant angular velocity.
|
|
@@ -14,9 +14,11 @@ import { TQuaternion } from './types.js';
|
|
|
14
14
|
* @returns Interpolated and normalized quaternion
|
|
15
15
|
*
|
|
16
16
|
* @example
|
|
17
|
+
* ```typescript
|
|
17
18
|
* const q1 = [0, 0, 0, 1];
|
|
18
19
|
* const q2 = [0, 0, 0.707, 0.707];
|
|
19
20
|
* const interpolated = QuaternionNLERP(q1, q2, 0.5);
|
|
21
|
+
* ```
|
|
20
22
|
*/
|
|
21
23
|
export declare function QuaternionNLERP(a: TQuaternion, b: TQuaternion, t: number): TQuaternion;
|
|
22
24
|
/**
|
|
@@ -31,9 +33,11 @@ export declare function QuaternionNLERP(a: TQuaternion, b: TQuaternion, t: numbe
|
|
|
31
33
|
* @returns Smoothly interpolated quaternion
|
|
32
34
|
*
|
|
33
35
|
* @example
|
|
36
|
+
* ```typescript
|
|
34
37
|
* // Create a smooth path through multiple rotations
|
|
35
38
|
* const path = [q0, q1, q2, q3]; // Array of quaternions
|
|
36
39
|
* const smooth = QuaternionSQUAD(path[0], path[1], path[2], path[3], 0.5);
|
|
40
|
+
* ```
|
|
37
41
|
*/
|
|
38
42
|
export declare function QuaternionSQUAD(q0: TQuaternion, q1: TQuaternion, q2: TQuaternion, q3: TQuaternion, t: number): TQuaternion;
|
|
39
43
|
/**
|
|
@@ -46,9 +50,11 @@ export declare function QuaternionSQUAD(q0: TQuaternion, q1: TQuaternion, q2: TQ
|
|
|
46
50
|
* @returns Function that takes t ∈ [0, 1] and returns interpolated quaternion
|
|
47
51
|
*
|
|
48
52
|
* @example
|
|
53
|
+
* ```typescript
|
|
49
54
|
* const path = [q1, q2, q3, q4];
|
|
50
55
|
* const interpolator = QuaternionCreatePath(path, 'slerp');
|
|
51
56
|
* const halfway = interpolator(0.5); // Interpolated quaternion at 50% along path
|
|
57
|
+
* ```
|
|
52
58
|
*/
|
|
53
59
|
export declare function QuaternionCreatePath(quaternions: TQuaternion[], method?: 'slerp' | 'nlerp' | 'squad'): (t: number) => TQuaternion;
|
|
54
60
|
//# sourceMappingURL=interpolation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interpolation.d.ts","sourceRoot":"","sources":["../../src/quaternions/interpolation.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"interpolation.d.ts","sourceRoot":"","sources":["../../src/quaternions/interpolation.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAK9C;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,MAAM,GAAG,WAAW,CAoBtF;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,eAAe,CAAC,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE,WAAW,EAAE,CAAC,EAAE,MAAM,GAAG,WAAW,CAiB1H;AAkFD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,oBAAoB,CACnC,WAAW,EAAE,WAAW,EAAE,EAC1B,MAAM,GAAE,OAAO,GAAG,OAAO,GAAG,OAAiB,GAC3C,CAAC,CAAC,EAAE,MAAM,KAAK,WAAW,CAkD5B"}
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { AssertArray, AssertNumber } from '@pawells/typescript-common';
|
|
6
6
|
import { AssertNormalizedQuaternion } from './asserts.js';
|
|
7
|
-
import { QuaternionSLERP, QuaternionNormalize, QuaternionMultiply, QuaternionInverse } from './core.js';
|
|
7
|
+
import { QuaternionSLERP, QuaternionNormalize, QuaternionMultiply, QuaternionInverse, QUATERNION_TOLERANCE } from './core.js';
|
|
8
|
+
import { VectorMagnitude } from '../vectors/core.js';
|
|
8
9
|
import { Clamp } from '../clamp.js';
|
|
9
|
-
const QUATERNION_LOG_TOLERANCE = 1e-6;
|
|
10
10
|
/**
|
|
11
11
|
* Performs normalized linear interpolation (NLERP) between two quaternions.
|
|
12
12
|
* NLERP is faster than SLERP but doesn't maintain constant angular velocity.
|
|
@@ -18,9 +18,11 @@ const QUATERNION_LOG_TOLERANCE = 1e-6;
|
|
|
18
18
|
* @returns Interpolated and normalized quaternion
|
|
19
19
|
*
|
|
20
20
|
* @example
|
|
21
|
+
* ```typescript
|
|
21
22
|
* const q1 = [0, 0, 0, 1];
|
|
22
23
|
* const q2 = [0, 0, 0.707, 0.707];
|
|
23
24
|
* const interpolated = QuaternionNLERP(q1, q2, 0.5);
|
|
25
|
+
* ```
|
|
24
26
|
*/
|
|
25
27
|
export function QuaternionNLERP(a, b, t) {
|
|
26
28
|
AssertNormalizedQuaternion(a);
|
|
@@ -52,9 +54,11 @@ export function QuaternionNLERP(a, b, t) {
|
|
|
52
54
|
* @returns Smoothly interpolated quaternion
|
|
53
55
|
*
|
|
54
56
|
* @example
|
|
57
|
+
* ```typescript
|
|
55
58
|
* // Create a smooth path through multiple rotations
|
|
56
59
|
* const path = [q0, q1, q2, q3]; // Array of quaternions
|
|
57
60
|
* const smooth = QuaternionSQUAD(path[0], path[1], path[2], path[3], 0.5);
|
|
61
|
+
* ```
|
|
58
62
|
*/
|
|
59
63
|
export function QuaternionSQUAD(q0, q1, q2, q3, t) {
|
|
60
64
|
AssertNormalizedQuaternion(q0);
|
|
@@ -110,8 +114,8 @@ function quaternionSquadControlPoint(q0, q1, q2) {
|
|
|
110
114
|
function quaternionLog(quaternion) {
|
|
111
115
|
AssertNormalizedQuaternion(quaternion);
|
|
112
116
|
const [x, y, z, w] = quaternion;
|
|
113
|
-
const vectorLength =
|
|
114
|
-
if (vectorLength <
|
|
117
|
+
const vectorLength = VectorMagnitude([x, y, z]);
|
|
118
|
+
if (vectorLength < QUATERNION_TOLERANCE)
|
|
115
119
|
return [0, 0, 0, 0];
|
|
116
120
|
const angle = Math.atan2(vectorLength, w);
|
|
117
121
|
const scale = angle / vectorLength;
|
|
@@ -126,8 +130,8 @@ function quaternionLog(quaternion) {
|
|
|
126
130
|
*/
|
|
127
131
|
function quaternionExp(quaternion) {
|
|
128
132
|
const [x, y, z, w] = quaternion;
|
|
129
|
-
const vectorLength =
|
|
130
|
-
if (vectorLength <
|
|
133
|
+
const vectorLength = VectorMagnitude([x, y, z]);
|
|
134
|
+
if (vectorLength < QUATERNION_TOLERANCE)
|
|
131
135
|
return [0, 0, 0, 1];
|
|
132
136
|
const expW = Math.exp(w);
|
|
133
137
|
const cosV = Math.cos(vectorLength);
|
|
@@ -150,9 +154,11 @@ function quaternionExp(quaternion) {
|
|
|
150
154
|
* @returns Function that takes t ∈ [0, 1] and returns interpolated quaternion
|
|
151
155
|
*
|
|
152
156
|
* @example
|
|
157
|
+
* ```typescript
|
|
153
158
|
* const path = [q1, q2, q3, q4];
|
|
154
159
|
* const interpolator = QuaternionCreatePath(path, 'slerp');
|
|
155
160
|
* const halfway = interpolator(0.5); // Interpolated quaternion at 50% along path
|
|
161
|
+
* ```
|
|
156
162
|
*/
|
|
157
163
|
export function QuaternionCreatePath(quaternions, method = 'slerp') {
|
|
158
164
|
AssertArray(quaternions, { minSize: 2 });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interpolation.js","sourceRoot":"","sources":["../../src/quaternions/interpolation.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW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ined quaternions for common rotations and orientations.
|
|
3
3
|
* Provides convenient constants for frequently used quaternion values.
|
|
4
4
|
*/
|
|
5
|
-
import { TQuaternion } from './types.js';
|
|
5
|
+
import type { TQuaternion } from './types.js';
|
|
6
6
|
/**
|
|
7
7
|
* Creates a quaternion representing rotation around the X-axis.
|
|
8
8
|
*
|
|
@@ -10,7 +10,9 @@ import { TQuaternion } from './types.js';
|
|
|
10
10
|
* @returns Quaternion representing rotation around X-axis
|
|
11
11
|
*
|
|
12
12
|
* @example
|
|
13
|
+
* ```typescript
|
|
13
14
|
* const q = QuaternionRotationX(Math.PI / 2); // 90° rotation around X-axis
|
|
15
|
+
* ```
|
|
14
16
|
*/
|
|
15
17
|
export declare function QuaternionRotationX(angle: number): TQuaternion;
|
|
16
18
|
/**
|
|
@@ -20,7 +22,9 @@ export declare function QuaternionRotationX(angle: number): TQuaternion;
|
|
|
20
22
|
* @returns Quaternion representing rotation around Y-axis
|
|
21
23
|
*
|
|
22
24
|
* @example
|
|
25
|
+
* ```typescript
|
|
23
26
|
* const q = QuaternionRotationY(Math.PI / 4); // 45° rotation around Y-axis
|
|
27
|
+
* ```
|
|
24
28
|
*/
|
|
25
29
|
export declare function QuaternionRotationY(angle: number): TQuaternion;
|
|
26
30
|
/**
|
|
@@ -30,7 +34,9 @@ export declare function QuaternionRotationY(angle: number): TQuaternion;
|
|
|
30
34
|
* @returns Quaternion representing rotation around Z-axis
|
|
31
35
|
*
|
|
32
36
|
* @example
|
|
37
|
+
* ```typescript
|
|
33
38
|
* const q = QuaternionRotationZ(Math.PI); // 180° rotation around Z-axis
|
|
39
|
+
* ```
|
|
34
40
|
*/
|
|
35
41
|
export declare function QuaternionRotationZ(angle: number): TQuaternion;
|
|
36
42
|
//# sourceMappingURL=predefined.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"predefined.d.ts","sourceRoot":"","sources":["../../src/quaternions/predefined.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"predefined.d.ts","sourceRoot":"","sources":["../../src/quaternions/predefined.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAG9C;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW,CAE9D;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW,CAE9D;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW,CAE9D"}
|