@lakuna/umath 1.3.9 → 1.4.2

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 (162) hide show
  1. package/README.md +1 -1
  2. package/dist/algorithms/approx.d.ts +9 -0
  3. package/dist/algorithms/approx.d.ts.map +1 -0
  4. package/dist/algorithms/approx.js +12 -0
  5. package/dist/algorithms/approx.js.map +1 -0
  6. package/dist/algorithms/approxRelative.d.ts +9 -0
  7. package/dist/algorithms/approxRelative.d.ts.map +1 -0
  8. package/dist/algorithms/approxRelative.js +12 -0
  9. package/dist/algorithms/approxRelative.js.map +1 -0
  10. package/dist/algorithms/combinations.d.ts +2 -1
  11. package/dist/algorithms/combinations.d.ts.map +1 -1
  12. package/dist/algorithms/combinations.js +2 -1
  13. package/dist/algorithms/combinations.js.map +1 -1
  14. package/dist/algorithms/degreesToRadians.d.ts +3 -2
  15. package/dist/algorithms/degreesToRadians.d.ts.map +1 -1
  16. package/dist/algorithms/degreesToRadians.js +5 -3
  17. package/dist/algorithms/degreesToRadians.js.map +1 -1
  18. package/dist/algorithms/factorial.d.ts +2 -1
  19. package/dist/algorithms/factorial.d.ts.map +1 -1
  20. package/dist/algorithms/factorial.js +2 -1
  21. package/dist/algorithms/factorial.js.map +1 -1
  22. package/dist/algorithms/fibonacci.d.ts +2 -1
  23. package/dist/algorithms/fibonacci.d.ts.map +1 -1
  24. package/dist/algorithms/fibonacci.js +6 -2
  25. package/dist/algorithms/fibonacci.js.map +1 -1
  26. package/dist/algorithms/greatestCommonDivisor.d.ts +4 -2
  27. package/dist/algorithms/greatestCommonDivisor.d.ts.map +1 -1
  28. package/dist/algorithms/greatestCommonDivisor.js +5 -2
  29. package/dist/algorithms/greatestCommonDivisor.js.map +1 -1
  30. package/dist/algorithms/hypergeometricPmf.d.ts +3 -2
  31. package/dist/algorithms/hypergeometricPmf.d.ts.map +1 -1
  32. package/dist/algorithms/hypergeometricPmf.js +3 -2
  33. package/dist/algorithms/hypergeometricPmf.js.map +1 -1
  34. package/dist/algorithms/isPrime.d.ts +2 -1
  35. package/dist/algorithms/isPrime.d.ts.map +1 -1
  36. package/dist/algorithms/isPrime.js +2 -1
  37. package/dist/algorithms/isPrime.js.map +1 -1
  38. package/dist/algorithms/permutations.d.ts +2 -1
  39. package/dist/algorithms/permutations.d.ts.map +1 -1
  40. package/dist/algorithms/permutations.js +2 -1
  41. package/dist/algorithms/permutations.js.map +1 -1
  42. package/dist/algorithms/primeFactorization.d.ts +2 -1
  43. package/dist/algorithms/primeFactorization.d.ts.map +1 -1
  44. package/dist/algorithms/primeFactorization.js +2 -1
  45. package/dist/algorithms/primeFactorization.js.map +1 -1
  46. package/dist/algorithms/radiansToDegrees.d.ts +3 -2
  47. package/dist/algorithms/radiansToDegrees.d.ts.map +1 -1
  48. package/dist/algorithms/radiansToDegrees.js +5 -3
  49. package/dist/algorithms/radiansToDegrees.js.map +1 -1
  50. package/dist/algorithms/summation.d.ts +2 -1
  51. package/dist/algorithms/summation.d.ts.map +1 -1
  52. package/dist/algorithms/summation.js +2 -1
  53. package/dist/algorithms/summation.js.map +1 -1
  54. package/dist/linalg/DualQuaternion.d.ts +102 -32
  55. package/dist/linalg/DualQuaternion.d.ts.map +1 -1
  56. package/dist/linalg/DualQuaternion.js +243 -272
  57. package/dist/linalg/DualQuaternion.js.map +1 -1
  58. package/dist/linalg/Matrix.d.ts +14 -10
  59. package/dist/linalg/Matrix.d.ts.map +1 -1
  60. package/dist/linalg/Matrix2.d.ts +74 -51
  61. package/dist/linalg/Matrix2.d.ts.map +1 -1
  62. package/dist/linalg/Matrix2.js +95 -171
  63. package/dist/linalg/Matrix2.js.map +1 -1
  64. package/dist/linalg/Matrix3.d.ts +122 -72
  65. package/dist/linalg/Matrix3.d.ts.map +1 -1
  66. package/dist/linalg/Matrix3.js +186 -355
  67. package/dist/linalg/Matrix3.js.map +1 -1
  68. package/dist/linalg/Matrix4.d.ts +266 -149
  69. package/dist/linalg/Matrix4.d.ts.map +1 -1
  70. package/dist/linalg/Matrix4.js +512 -852
  71. package/dist/linalg/Matrix4.js.map +1 -1
  72. package/dist/linalg/Quaternion.d.ts +252 -34
  73. package/dist/linalg/Quaternion.d.ts.map +1 -1
  74. package/dist/linalg/Quaternion.js +436 -166
  75. package/dist/linalg/Quaternion.js.map +1 -1
  76. package/dist/linalg/SlowMatrix.d.ts +10 -9
  77. package/dist/linalg/SlowMatrix.d.ts.map +1 -1
  78. package/dist/linalg/SlowMatrix.js +10 -9
  79. package/dist/linalg/SlowMatrix.js.map +1 -1
  80. package/dist/linalg/SlowSquareMatrix.d.ts +10 -9
  81. package/dist/linalg/SlowSquareMatrix.d.ts.map +1 -1
  82. package/dist/linalg/SlowSquareMatrix.js +10 -9
  83. package/dist/linalg/SlowSquareMatrix.js.map +1 -1
  84. package/dist/linalg/SquareMatrix.d.ts +6 -5
  85. package/dist/linalg/SquareMatrix.d.ts.map +1 -1
  86. package/dist/linalg/Vector.d.ts +8 -4
  87. package/dist/linalg/Vector.d.ts.map +1 -1
  88. package/dist/linalg/Vector2.d.ts +82 -31
  89. package/dist/linalg/Vector2.d.ts.map +1 -1
  90. package/dist/linalg/Vector2.js +112 -154
  91. package/dist/linalg/Vector2.js.map +1 -1
  92. package/dist/linalg/Vector3.d.ts +93 -41
  93. package/dist/linalg/Vector3.d.ts.map +1 -1
  94. package/dist/linalg/Vector3.js +171 -282
  95. package/dist/linalg/Vector3.js.map +1 -1
  96. package/dist/linalg/Vector4.d.ts +71 -21
  97. package/dist/linalg/Vector4.d.ts.map +1 -1
  98. package/dist/linalg/Vector4.js +121 -195
  99. package/dist/linalg/Vector4.js.map +1 -1
  100. package/dist/types/AxisAngle.d.ts +4 -1
  101. package/dist/types/AxisAngle.d.ts.map +1 -1
  102. package/dist/types/FieldOfView.d.ts +4 -1
  103. package/dist/types/FieldOfView.d.ts.map +1 -1
  104. package/dist/utility/BigNumber.d.ts +4 -1
  105. package/dist/utility/BigNumber.d.ts.map +1 -1
  106. package/dist/utility/BigNumber.js +4 -1
  107. package/dist/utility/BigNumber.js.map +1 -1
  108. package/dist/utility/MagnitudeError.d.ts +4 -1
  109. package/dist/utility/MagnitudeError.d.ts.map +1 -1
  110. package/dist/utility/MagnitudeError.js +4 -1
  111. package/dist/utility/MagnitudeError.js.map +1 -1
  112. package/dist/utility/MatrixSizeError.d.ts +4 -1
  113. package/dist/utility/MatrixSizeError.d.ts.map +1 -1
  114. package/dist/utility/MatrixSizeError.js +4 -1
  115. package/dist/utility/MatrixSizeError.js.map +1 -1
  116. package/dist/utility/PartialMatrixError.d.ts +4 -1
  117. package/dist/utility/PartialMatrixError.d.ts.map +1 -1
  118. package/dist/utility/PartialMatrixError.js +4 -1
  119. package/dist/utility/PartialMatrixError.js.map +1 -1
  120. package/dist/utility/SingularMatrixError.d.ts +2 -1
  121. package/dist/utility/SingularMatrixError.d.ts.map +1 -1
  122. package/dist/utility/SingularMatrixError.js +2 -1
  123. package/dist/utility/SingularMatrixError.js.map +1 -1
  124. package/dist/utility/epsilon.d.ts +4 -1
  125. package/dist/utility/epsilon.d.ts.map +1 -1
  126. package/dist/utility/epsilon.js +4 -1
  127. package/dist/utility/epsilon.js.map +1 -1
  128. package/package.json +11 -11
  129. package/src/algorithms/approx.ts +12 -0
  130. package/src/algorithms/approxRelative.ts +12 -0
  131. package/src/algorithms/combinations.ts +2 -1
  132. package/src/algorithms/degreesToRadians.ts +6 -3
  133. package/src/algorithms/factorial.ts +3 -1
  134. package/src/algorithms/fibonacci.ts +7 -2
  135. package/src/algorithms/greatestCommonDivisor.ts +9 -4
  136. package/src/algorithms/hypergeometricPmf.ts +3 -2
  137. package/src/algorithms/isPrime.ts +2 -1
  138. package/src/algorithms/permutations.ts +2 -1
  139. package/src/algorithms/primeFactorization.ts +2 -1
  140. package/src/algorithms/radiansToDegrees.ts +6 -3
  141. package/src/algorithms/summation.ts +2 -1
  142. package/src/linalg/DualQuaternion.ts +424 -289
  143. package/src/linalg/Matrix.ts +14 -10
  144. package/src/linalg/Matrix2.ts +141 -188
  145. package/src/linalg/Matrix3.ts +400 -375
  146. package/src/linalg/Matrix4.ts +1083 -905
  147. package/src/linalg/Quaternion.ts +706 -188
  148. package/src/linalg/SlowMatrix.ts +10 -9
  149. package/src/linalg/SlowSquareMatrix.ts +10 -9
  150. package/src/linalg/SquareMatrix.ts +6 -5
  151. package/src/linalg/Vector.ts +8 -4
  152. package/src/linalg/Vector2.ts +146 -173
  153. package/src/linalg/Vector3.ts +293 -326
  154. package/src/linalg/Vector4.ts +227 -215
  155. package/src/types/AxisAngle.ts +4 -1
  156. package/src/types/FieldOfView.ts +4 -1
  157. package/src/utility/BigNumber.ts +6 -3
  158. package/src/utility/MagnitudeError.ts +4 -1
  159. package/src/utility/MatrixSizeError.ts +4 -1
  160. package/src/utility/PartialMatrixError.ts +4 -1
  161. package/src/utility/SingularMatrixError.ts +2 -1
  162. package/src/utility/epsilon.ts +4 -1
@@ -1,11 +1,13 @@
1
- import { getRotation as getMatrix4Rotation, getTranslation as getMatrix4Translation } from "./Matrix4.js";
2
- import Quaternion, { createQuaternionLike, rotateX as quaternionRotateX, rotateY as quaternionRotateY, rotateZ as quaternionRotateZ } from "./Quaternion.js";
3
- import Vector3, { createVector3Like } from "./Vector3.js";
4
- import { dot, getMagnitude, getSquaredMagnitude, copy as xetReal } from "./Vector4.js";
1
+ import { getScaling as matrix4GetScaling } from "./Matrix4.js";
2
+ import Quaternion, { rotateX as quaternionRotateX, rotateY as quaternionRotateY, rotateZ as quaternionRotateZ } from "./Quaternion.js";
3
+ import Vector3, { createVector3Like, fromValues as vector3FromValues } from "./Vector3.js";
4
+ import { copy as vector4Copy, dot as vector4Dot, fromValues as vector4FromValues, getMagnitude as vector4GetMagnitude, getSquaredMagnitude as vector4GetSquaredMagnitude } from "./Vector4.js";
5
+ import approxRelative from "../algorithms/approxRelative.js";
5
6
  import epsilon from "../utility/epsilon.js";
6
7
  /**
7
8
  * Create a dual quaternion-like object.
8
9
  * @returns A dual quaternion-like object.
10
+ * @public
9
11
  */
10
12
  export const createDualQuaternionLike = () => {
11
13
  return new Float32Array(8);
@@ -22,6 +24,7 @@ export const createDualQuaternionLike = () => {
22
24
  * @param w2 - The fourth dual component.
23
25
  * @param out - The dual quaternion to store the result in.
24
26
  * @returns A new dual quaternion.
27
+ * @public
25
28
  */
26
29
  export const fromValues = (x1, y1, z1, w1, x2, y2, z2, w2, out) => {
27
30
  out[0] = x1;
@@ -39,123 +42,145 @@ export const fromValues = (x1, y1, z1, w1, x2, y2, z2, w2, out) => {
39
42
  * @param dualQuaternion - The dual quaternion to copy.
40
43
  * @param out - The dual quaternion to store the result in.
41
44
  * @returns The copy.
45
+ * @public
42
46
  */
43
- export const copy = (dualQuaternion, out) => {
44
- out[0] = dualQuaternion[0];
45
- out[1] = dualQuaternion[1];
46
- out[2] = dualQuaternion[2];
47
- out[3] = dualQuaternion[3];
48
- out[4] = dualQuaternion[4];
49
- out[5] = dualQuaternion[5];
50
- out[6] = dualQuaternion[6];
51
- out[7] = dualQuaternion[7];
52
- return out;
53
- };
47
+ export const copy = (dualQuaternion, out) => fromValues(dualQuaternion[0], dualQuaternion[1], dualQuaternion[2], dualQuaternion[3], dualQuaternion[4], dualQuaternion[5], dualQuaternion[6], dualQuaternion[7], out);
54
48
  /**
55
- * Create a dual quaternion from the given quaternion and translation.
56
- * @param quaternion - The quaternion.
57
- * @param translation - The translation.
49
+ * Create a dual quaternion from the given rotation and translation.
50
+ * @param quaternion - The rotation quaternion.
51
+ * @param translation - The translation vector.
58
52
  * @param out - The dual quaternion to store the result in.
59
53
  * @returns The dual quaternion.
54
+ * @public
60
55
  */
61
56
  export const fromRotationTranslation = (quaternion, translation, out) => {
62
57
  const x = quaternion[0];
63
58
  const y = quaternion[1];
64
59
  const z = quaternion[2];
65
60
  const w = quaternion[3];
66
- const ax = translation[0] * 0.5;
67
- const ay = translation[1] * 0.5;
68
- const az = translation[2] * 0.5;
69
- out[0] = x;
70
- out[1] = y;
71
- out[2] = z;
72
- out[3] = w;
73
- out[4] = ax * w + ay * z - az * y;
74
- out[5] = ay * w + az * x - ax * z;
75
- out[6] = az * w + ax * y - ay * x;
76
- out[7] = -ax * x - ay * y - az * z;
77
- return out;
61
+ const ax = translation[0] / 2;
62
+ const ay = translation[1] / 2;
63
+ const az = translation[2] / 2;
64
+ return fromValues(x, y, z, w, ax * w + ay * z - az * y, ay * w + az * x - ax * z, az * w + ax * y - ay * x, -ax * x - ay * y - az * z, out);
78
65
  };
79
66
  /**
80
67
  * Create a dual quaternion from the given translation.
81
- * @param translation - The translation.
68
+ * @param translation - The translation vector.
82
69
  * @param out - The dual quaternion to store the result in.
83
70
  * @returns The dual quaternion.
71
+ * @public
84
72
  */
85
- export const fromTranslation = (translation, out) => {
86
- out[0] = 0;
87
- out[1] = 0;
88
- out[2] = 0;
89
- out[3] = 1;
90
- out[4] = translation[0] * 0.5;
91
- out[5] = translation[1] * 0.5;
92
- out[6] = translation[2] * 0.5;
93
- out[7] = 0;
94
- return out;
95
- };
73
+ export const fromTranslation = (translation, out) => fromValues(0, 0, 0, 1, translation[0] / 2, translation[1] / 2, translation[2] / 2, 0, out);
96
74
  /**
97
- * Create a dual quaternion from the given quaternion.
98
- * @param quaternion - The quaternion.
75
+ * Create a dual quaternion from the given rotation.
76
+ * @param quaternion - The rotation quaternion.
99
77
  * @param out - The dual quaternion to store the result in.
100
78
  * @returns The dual quaternion.
79
+ * @public
101
80
  */
102
- export const fromRotation = (quaternion, out) => {
103
- out[0] = quaternion[0];
104
- out[1] = quaternion[1];
105
- out[2] = quaternion[2];
106
- out[3] = quaternion[3];
107
- out[4] = 0;
108
- out[5] = 0;
109
- out[6] = 0;
110
- out[7] = 0;
111
- return out;
112
- };
81
+ export const fromRotation = (quaternion, out) => fromValues(quaternion[0], quaternion[1], quaternion[2], quaternion[3], 0, 0, 0, 0, out);
113
82
  // Used to store intermediary values for some functions.
114
- const rotation = createQuaternionLike();
115
- const translation = createVector3Like();
83
+ const iv3 = createVector3Like();
116
84
  /**
117
- * Create a dual quaternion from the given four-by-four matrix.
85
+ * Create a dual quaternion from the given four-by-four matrix. Equivalent to (but faster than) `fromRotationTranslation(getRotation(matrix, createQuaternionLike()), getTranslation(matrix, createVector3Like()), out)`.
118
86
  * @param matrix - The matrix.
119
87
  * @param out - The dual quaternion to store the result in.
120
88
  * @returns The dual quaternion.
89
+ * @public
121
90
  */
122
91
  export const fromMatrix4 = (matrix, out) => {
123
- return fromRotationTranslation(getMatrix4Rotation(matrix, rotation), getMatrix4Translation(matrix, translation), out);
92
+ matrix4GetScaling(matrix, iv3);
93
+ const is1 = 1 / iv3[0];
94
+ const is2 = 1 / iv3[1];
95
+ const is3 = 1 / iv3[2];
96
+ const sm11 = matrix[0] * is1;
97
+ const sm12 = matrix[1] * is2;
98
+ const sm13 = matrix[2] * is3;
99
+ const sm21 = matrix[4] * is1;
100
+ const sm22 = matrix[5] * is2;
101
+ const sm23 = matrix[6] * is3;
102
+ const sm31 = matrix[8] * is1;
103
+ const sm32 = matrix[9] * is2;
104
+ const sm33 = matrix[10] * is3;
105
+ const trace = sm11 + sm22 + sm33;
106
+ // eslint-disable-next-line init-declarations
107
+ let x;
108
+ // eslint-disable-next-line init-declarations
109
+ let y;
110
+ // eslint-disable-next-line init-declarations
111
+ let z;
112
+ // eslint-disable-next-line init-declarations
113
+ let w;
114
+ if (trace > 0) {
115
+ const s = Math.sqrt(trace + 1) * 2;
116
+ x = (sm23 - sm32) / s;
117
+ y = (sm31 - sm13) / s;
118
+ z = (sm12 - sm21) / s;
119
+ w = 0.25 * s;
120
+ }
121
+ else if (sm11 > sm22 && sm11 > sm33) {
122
+ const s = Math.sqrt(1 + sm11 - sm22 - sm33) * 2;
123
+ x = 0.25 * s;
124
+ y = (sm12 + sm21) / s;
125
+ z = (sm31 + sm13) / s;
126
+ w = (sm23 - sm32) / s;
127
+ }
128
+ else if (sm22 > sm33) {
129
+ const s = Math.sqrt(1 + sm22 - sm11 - sm33) * 2;
130
+ x = (sm12 + sm21) / s;
131
+ y = 0.25 * s;
132
+ z = (sm23 + sm32) / s;
133
+ w = (sm31 - sm13) / s;
134
+ }
135
+ else {
136
+ const s = Math.sqrt(1 + sm33 - sm11 - sm22) * 2;
137
+ x = (sm31 + sm13) / s;
138
+ y = (sm23 + sm32) / s;
139
+ z = 0.25 * s;
140
+ w = (sm12 - sm21) / s;
141
+ }
142
+ const ax = matrix[12] / 2;
143
+ const ay = matrix[13] / 2;
144
+ const az = matrix[14] / 2;
145
+ return fromValues(x, y, z, w, ax * w + ay * z - az * y, ay * w + az * x - ax * z, az * w + ax * y - ay * x, -ax * x - ay * y - az * z, out);
124
146
  };
125
147
  /**
126
148
  * Set a dual quaternion to the identity dual quaternion.
127
149
  * @param out - The dual quaternion to store the result in.
128
150
  * @returns The identity dual quaternion.
151
+ * @public
129
152
  */
130
- export const identity = (out) => {
131
- out[0] = 0;
132
- out[1] = 0;
133
- out[2] = 0;
134
- out[3] = 1;
135
- out[4] = 0;
136
- out[5] = 0;
137
- out[6] = 0;
138
- out[7] = 0;
139
- return out;
140
- };
153
+ export const identity = (out) => fromValues(0, 0, 0, 1, 0, 0, 0, 0, out);
154
+ /**
155
+ * Get the real part of a dual quaternion.
156
+ * @param dualQuaternion - The dual quaternion.
157
+ * @param out - The quaternion to store the result in.
158
+ * @returns The real part.
159
+ * @public
160
+ */
161
+ export const getReal = vector4Copy;
141
162
  /**
142
163
  * Get the dual part of a dual quaternion.
143
164
  * @param dualQuaternion - The dual quaternion.
144
165
  * @param out - The quaternion to store the result in.
145
166
  * @returns The dual part.
167
+ * @public
146
168
  */
147
- export const getDual = (dualQuaternion, out) => {
148
- out[0] = dualQuaternion[4];
149
- out[1] = dualQuaternion[5];
150
- out[2] = dualQuaternion[6];
151
- out[3] = dualQuaternion[7];
152
- return out;
153
- };
169
+ export const getDual = (dualQuaternion, out) => vector4FromValues(dualQuaternion[4], dualQuaternion[5], dualQuaternion[6], dualQuaternion[7], out);
170
+ /**
171
+ * Set the real part of a dual quaternion.
172
+ * @param quaternion - The quaternion to set as the real part.
173
+ * @param out - The dual quaternion to store the result in.
174
+ * @returns The dual quaternion.
175
+ * @public
176
+ */
177
+ export const setReal = vector4Copy;
154
178
  /**
155
179
  * Set the dual part of a dual quaternion.
156
180
  * @param quaternion - The quaternion to set as the dual part.
157
181
  * @param out - The dual quaternion to store the result in.
158
182
  * @returns The dual quaternion.
183
+ * @public
159
184
  */
160
185
  export const setDual = (quaternion, out) => {
161
186
  out[4] = quaternion[0];
@@ -168,7 +193,8 @@ export const setDual = (quaternion, out) => {
168
193
  * Get the translation of a normalized dual quaternion.
169
194
  * @param dualQuaternion - The dual quaternion.
170
195
  * @param out - The vector to store the result in.
171
- * @returns The translation.
196
+ * @returns The translation vector.
197
+ * @public
172
198
  */
173
199
  export const getTranslation = (dualQuaternion, out) => {
174
200
  const ax = dualQuaternion[4];
@@ -179,10 +205,7 @@ export const getTranslation = (dualQuaternion, out) => {
179
205
  const by = -dualQuaternion[1];
180
206
  const bz = -dualQuaternion[2];
181
207
  const bw = dualQuaternion[3];
182
- out[0] = (ax * bw + aw * bx + ay * bz - az * by) * 2;
183
- out[1] = (ay * bw + aw * by + az * bx - ax * bz) * 2;
184
- out[2] = (az * bw + aw * bz + ax * by - ay * bx) * 2;
185
- return out;
208
+ return vector3FromValues((ax * bw + aw * bx + ay * bz - az * by) * 2, (ay * bw + aw * by + az * bx - ax * bz) * 2, (az * bw + aw * bz + ax * by - ay * bx) * 2, out);
186
209
  };
187
210
  /**
188
211
  * Translate a dual quaternion by the given vector.
@@ -190,28 +213,21 @@ export const getTranslation = (dualQuaternion, out) => {
190
213
  * @param vector - The vector.
191
214
  * @param out - The dual quaternion to store the result in.
192
215
  * @returns The translated dual quaternion.
216
+ * @public
193
217
  */
194
218
  export const translate = (dualQuaternion, vector, out) => {
195
219
  const ax1 = dualQuaternion[0];
196
220
  const ay1 = dualQuaternion[1];
197
221
  const az1 = dualQuaternion[2];
198
222
  const aw1 = dualQuaternion[3];
199
- const bx1 = vector[0] * 0.5;
200
- const by1 = vector[1] * 0.5;
201
- const bz1 = vector[2] * 0.5;
223
+ const bx1 = vector[0] / 2;
224
+ const by1 = vector[1] / 2;
225
+ const bz1 = vector[2] / 2;
202
226
  const ax2 = dualQuaternion[4];
203
227
  const ay2 = dualQuaternion[5];
204
228
  const az2 = dualQuaternion[6];
205
229
  const aw2 = dualQuaternion[7];
206
- out[0] = ax1;
207
- out[1] = ay1;
208
- out[2] = az1;
209
- out[3] = aw1;
210
- out[4] = aw1 * bx1 + ay1 * bz1 - az1 * by1 + ax2;
211
- out[5] = aw1 * by1 + az1 * bx1 - ax1 * bz1 + ay2;
212
- out[6] = aw1 * bz1 + ax1 * by1 - ay1 * bx1 + az2;
213
- out[7] = -ax1 * bx1 - ay1 * by1 - az1 * bz1 + aw2;
214
- return out;
230
+ return fromValues(ax1, ay1, az1, aw1, aw1 * bx1 + ay1 * bz1 - az1 * by1 + ax2, aw1 * by1 + az1 * bx1 - ax1 * bz1 + ay2, aw1 * bz1 + ax1 * by1 - ay1 * bx1 + az2, -ax1 * bx1 - ay1 * by1 - az1 * bz1 + aw2, out);
215
231
  };
216
232
  /**
217
233
  * Rotate a dual quaternion around the X-axis.
@@ -219,6 +235,7 @@ export const translate = (dualQuaternion, vector, out) => {
219
235
  * @param radians - The angle to rotate by in radians.
220
236
  * @param out - The dual quaternion to store the result in.
221
237
  * @returns The rotated dual quaternion.
238
+ * @public
222
239
  */
223
240
  export const rotateX = (dualQuaternion, radians, out) => {
224
241
  let bx = -dualQuaternion[0];
@@ -250,6 +267,7 @@ export const rotateX = (dualQuaternion, radians, out) => {
250
267
  * @param radians - The angle to rotate by in radians.
251
268
  * @param out - The dual quaternion to store the result in.
252
269
  * @returns The rotated dual quaternion.
270
+ * @public
253
271
  */
254
272
  export const rotateY = (dualQuaternion, radians, out) => {
255
273
  let bx = -dualQuaternion[0];
@@ -281,6 +299,7 @@ export const rotateY = (dualQuaternion, radians, out) => {
281
299
  * @param radians - The angle to rotate by in radians.
282
300
  * @param out - The dual quaternion to store the result in.
283
301
  * @returns The rotated dual quaternion.
302
+ * @public
284
303
  */
285
304
  export const rotateZ = (dualQuaternion, radians, out) => {
286
305
  let bx = -dualQuaternion[0];
@@ -307,11 +326,12 @@ export const rotateZ = (dualQuaternion, radians, out) => {
307
326
  return out;
308
327
  };
309
328
  /**
310
- * Multiply a dual quaternion by a quaternion.
311
- * @param dualQuaternion - The dual quaternion.
312
- * @param quaternion - The quaternion.
329
+ * Rotate a dual quaternion by a quaternion (using the quaternion as the multiplicand).
330
+ * @param dualQuaternion - The dual quaternion to rotate.
331
+ * @param quaternion - The quaternion to rotate by.
313
332
  * @param out - The dual quaternion to store the result in.
314
333
  * @returns The rotated dual quaternion.
334
+ * @public
315
335
  */
316
336
  export const rotateByQuaternionAppend = (dualQuaternion, quaternion, out) => {
317
337
  const qx = quaternion[0];
@@ -337,11 +357,12 @@ export const rotateByQuaternionAppend = (dualQuaternion, quaternion, out) => {
337
357
  return out;
338
358
  };
339
359
  /**
340
- * Multiply a quaternion by a dual quaternion.
341
- * @param quaternion - The quaternion.
342
- * @param dualQuaternion - The dual quaternion.
360
+ * Rotate a dual quaternion by a quaternion (using the quaternion as the multiplier).
361
+ * @param quaternion - The quaternion to rotate by.
362
+ * @param dualQuaternion - The dual quaternion to rotate.
343
363
  * @param out - The dual quaternion to store the result in.
344
364
  * @returns The rotated dual quaternion.
365
+ * @public
345
366
  */
346
367
  export const rotateByQuaternionPrepend = (quaternion, dualQuaternion, out) => {
347
368
  const qx = quaternion[0];
@@ -373,16 +394,18 @@ export const rotateByQuaternionPrepend = (quaternion, dualQuaternion, out) => {
373
394
  * @param radians - The angle of the rotation in radians.
374
395
  * @param out - The dual quaternion to store the result in.
375
396
  * @returns A normalized dual quaternion.
397
+ * @public
376
398
  */
377
399
  export const rotateAroundAxis = (dualQuaternion, axis, radians, out) => {
378
- if (Math.abs(radians) < 0) {
400
+ // Negligible rotation.
401
+ if (Math.abs(radians) < epsilon) {
379
402
  return copy(dualQuaternion, out);
380
403
  }
381
404
  const ax = axis[0];
382
405
  const ay = axis[1];
383
406
  const az = axis[2];
384
- const axisLength = Math.sqrt(ax * ax + ay * ay + az * az);
385
- const r = radians * 0.5;
407
+ const axisLength = Math.sqrt(ax * ax + ay * ay + az * az); // `Math.hypot` is slower.
408
+ const r = radians / 2;
386
409
  const s = Math.sin(r);
387
410
  const bx = (s * ax) / axisLength;
388
411
  const by = (s * ay) / axisLength;
@@ -412,24 +435,16 @@ export const rotateAroundAxis = (dualQuaternion, axis, radians, out) => {
412
435
  * @param b - The addend.
413
436
  * @param out - The dual quaternion to store the result in.
414
437
  * @returns The sum.
438
+ * @public
415
439
  */
416
- export const add = (a, b, out) => {
417
- out[0] = a[0] + b[0];
418
- out[1] = a[1] + b[1];
419
- out[2] = a[2] + b[2];
420
- out[3] = a[3] + b[3];
421
- out[4] = a[4] + b[4];
422
- out[5] = a[5] + b[5];
423
- out[6] = a[6] + b[6];
424
- out[7] = a[7] + b[7];
425
- return out;
426
- };
440
+ export const add = (a, b, out) => fromValues(a[0] + b[0], a[1] + b[1], a[2] + b[2], a[3] + b[3], a[4] + b[4], a[5] + b[5], a[6] + b[6], a[7] + b[7], out);
427
441
  /**
428
442
  * Multiply two dual quaternions.
429
443
  * @param a - The multiplier.
430
444
  * @param b - The multiplicand.
431
445
  * @param out - The dual quaternion to store the result in.
432
446
  * @returns The product.
447
+ * @public
433
448
  */
434
449
  export const multiply = (a, b, out) => {
435
450
  const ax0 = a[0];
@@ -448,203 +463,159 @@ export const multiply = (a, b, out) => {
448
463
  const by1 = b[5];
449
464
  const bz1 = b[6];
450
465
  const bw1 = b[7];
451
- out[0] = ax0 * bw0 + aw0 * bx0 + ay0 * bz0 - az0 * by0;
452
- out[1] = ay0 * bw0 + aw0 * by0 + az0 * bx0 - ax0 * bz0;
453
- out[2] = az0 * bw0 + aw0 * bz0 + ax0 * by0 - ay0 * bx0;
454
- out[3] = aw0 * bw0 - ax0 * bx0 - ay0 * by0 - az0 * bz0;
455
- out[4] =
456
- ax0 * bw1 +
457
- aw0 * bx1 +
458
- ay0 * bz1 -
459
- az0 * by1 +
460
- ax1 * bw0 +
461
- aw1 * bx0 +
462
- ay1 * bz0 -
463
- az1 * by0;
464
- out[5] =
465
- ay0 * bw1 +
466
- aw0 * by1 +
467
- az0 * bx1 -
468
- ax0 * bz1 +
469
- ay1 * bw0 +
470
- aw1 * by0 +
471
- az1 * bx0 -
472
- ax1 * bz0;
473
- out[6] =
474
- az0 * bw1 +
475
- aw0 * bz1 +
476
- ax0 * by1 -
477
- ay0 * bx1 +
478
- az1 * bw0 +
479
- aw1 * bz0 +
480
- ax1 * by0 -
481
- ay1 * bx0;
482
- out[7] =
483
- aw0 * bw1 -
484
- ax0 * bx1 -
485
- ay0 * by1 -
486
- az0 * bz1 +
487
- aw1 * bw0 -
488
- ax1 * bx0 -
489
- ay1 * by0 -
490
- az1 * bz0;
491
- return out;
466
+ return fromValues(ax0 * bw0 + aw0 * bx0 + ay0 * bz0 - az0 * by0, ay0 * bw0 + aw0 * by0 + az0 * bx0 - ax0 * bz0, az0 * bw0 + aw0 * bz0 + ax0 * by0 - ay0 * bx0, aw0 * bw0 - ax0 * bx0 - ay0 * by0 - az0 * bz0, ax0 * bw1 +
467
+ aw0 * bx1 +
468
+ ay0 * bz1 -
469
+ az0 * by1 +
470
+ ax1 * bw0 +
471
+ aw1 * bx0 +
472
+ ay1 * bz0 -
473
+ az1 * by0, ay0 * bw1 +
474
+ aw0 * by1 +
475
+ az0 * bx1 -
476
+ ax0 * bz1 +
477
+ ay1 * bw0 +
478
+ aw1 * by0 +
479
+ az1 * bx0 -
480
+ ax1 * bz0, az0 * bw1 +
481
+ aw0 * bz1 +
482
+ ax0 * by1 -
483
+ ay0 * bx1 +
484
+ az1 * bw0 +
485
+ aw1 * bz0 +
486
+ ax1 * by0 -
487
+ ay1 * bx0, aw0 * bw1 -
488
+ ax0 * bx1 -
489
+ ay0 * by1 -
490
+ az0 * bz1 +
491
+ aw1 * bw0 -
492
+ ax1 * bx0 -
493
+ ay1 * by0 -
494
+ az1 * bz0, out);
492
495
  };
493
496
  /**
494
497
  * Multiply a dual quaternion by a scalar.
495
- * @param dualQuaternion - The multiplicand.
496
- * @param scalar - The multiplier.
498
+ * @param dualQuaternion - The multiplicand (dual quaternion).
499
+ * @param scalar - The multiplier (scalar) to scale the dual quaternion by.
497
500
  * @param out - The dual quaternion to store the result in.
498
- * @returns The sum.
501
+ * @returns The product.
502
+ * @public
499
503
  */
500
- export const scale = (dualQuaternion, scalar, out) => {
501
- out[0] = dualQuaternion[0] * scalar;
502
- out[1] = dualQuaternion[1] * scalar;
503
- out[2] = dualQuaternion[2] * scalar;
504
- out[3] = dualQuaternion[3] * scalar;
505
- out[4] = dualQuaternion[4] * scalar;
506
- out[5] = dualQuaternion[5] * scalar;
507
- out[6] = dualQuaternion[6] * scalar;
508
- out[7] = dualQuaternion[7] * scalar;
509
- return out;
510
- };
504
+ export const scale = (dualQuaternion, scalar, out) => fromValues(dualQuaternion[0] * scalar, dualQuaternion[1] * scalar, dualQuaternion[2] * scalar, dualQuaternion[3] * scalar, dualQuaternion[4] * scalar, dualQuaternion[5] * scalar, dualQuaternion[6] * scalar, dualQuaternion[7] * scalar, out);
505
+ /**
506
+ * Calculate the dot product of two dual quaternions.
507
+ * @param a - The multiplier.
508
+ * @param b - The multiplicand.
509
+ * @returns The dot product.
510
+ * @see {@link https://en.wikipedia.org/wiki/Dot_product | Dot product}
511
+ * @public
512
+ */
513
+ export const dot = vector4Dot;
511
514
  /**
512
515
  * Perform a linear interpolation between two dual quaternions.
513
516
  * @param a - The first dual quaternion.
514
517
  * @param b - The second dual quaternion.
515
518
  * @param t - The interpolation amount in `[0,1]`.
516
- * @param out - The dual quaternion to store the result in.
519
+ * @param out - The dual quaternion to store the result in. Will not always be normalized (most noticeable when `t === 0.5`).
517
520
  * @returns The interpolated value.
521
+ * @public
518
522
  */
519
523
  export const lerp = (a, b, t, out) => {
520
524
  const mt = 1 - t;
521
- const it = dot(a, b) < epsilon ? -t : t;
522
- out[0] = a[0] * mt + b[0] * it;
523
- out[1] = a[1] * mt + b[1] * it;
524
- out[2] = a[2] * mt + b[2] * it;
525
- out[3] = a[3] * mt + b[3] * it;
526
- out[4] = a[4] * mt + b[4] * it;
527
- out[5] = a[5] * mt + b[5] * it;
528
- out[6] = a[6] * mt + b[6] * it;
529
- out[7] = a[7] * mt + b[7] * it;
530
- return out;
525
+ const it = dot(a, b) < 0 ? -t : t;
526
+ return fromValues(a[0] * mt + b[0] * it, a[1] * mt + b[1] * it, a[2] * mt + b[2] * it, a[3] * mt + b[3] * it, a[4] * mt + b[4] * it, a[5] * mt + b[5] * it, a[6] * mt + b[6] * it, a[7] * mt + b[7] * it, out);
531
527
  };
528
+ /**
529
+ * Calculate the magnitude (length) of a dual quaternion.
530
+ * @param dualQuaternion - The dual quaternion.
531
+ * @returns The magnitude.
532
+ * @public
533
+ */
534
+ export const getMagnitude = vector4GetMagnitude;
535
+ /**
536
+ * Calculate the squared magnitude (length) of a dual quaternion.
537
+ * @param dualQuaternion - The dual quaternion.
538
+ * @returns The squared magnitude.
539
+ * @public
540
+ */
541
+ export const getSquaredMagnitude = vector4GetSquaredMagnitude;
532
542
  /**
533
543
  * Calculate the inverse of a dual quaternion. If the dual quaternion is normalized, the conjugate is equivalent and faster to calculate.
534
544
  * @param dualQuaternion - The dual quaternion.
535
545
  * @param out - The dual quaternion to store the result in.
536
546
  * @returns The inverse.
547
+ * @public
537
548
  */
538
549
  export const invert = (dualQuaternion, out) => {
539
550
  const sqm = getSquaredMagnitude(dualQuaternion);
540
- out[0] = -dualQuaternion[0] / sqm;
541
- out[1] = -dualQuaternion[1] / sqm;
542
- out[2] = -dualQuaternion[2] / sqm;
543
- out[3] = dualQuaternion[3] / sqm;
544
- out[4] = -dualQuaternion[4] / sqm;
545
- out[5] = -dualQuaternion[5] / sqm;
546
- out[6] = -dualQuaternion[6] / sqm;
547
- out[7] = dualQuaternion[7] / sqm;
548
- return out;
551
+ return fromValues(-dualQuaternion[0] / sqm, -dualQuaternion[1] / sqm, -dualQuaternion[2] / sqm, dualQuaternion[3] / sqm, -dualQuaternion[4] / sqm, -dualQuaternion[5] / sqm, -dualQuaternion[6] / sqm, dualQuaternion[7] / sqm, out);
549
552
  };
550
553
  /**
551
554
  * Calculate the conjugate of a dual quaternion. If the dual quaternion is normalized, this is equivalent to its inverse and faster to calculate.
552
555
  * @param dualQuaternion - The dual quaternion.
553
556
  * @param out - The dual quaternion to store the result in.
554
557
  * @returns The conjugate.
558
+ * @public
555
559
  */
556
- export const conjugate = (dualQuaternion, out) => {
557
- out[0] = -dualQuaternion[0];
558
- out[1] = -dualQuaternion[1];
559
- out[2] = -dualQuaternion[2];
560
- out[3] = dualQuaternion[3];
561
- out[4] = -dualQuaternion[4];
562
- out[5] = -dualQuaternion[5];
563
- out[6] = -dualQuaternion[6];
564
- out[7] = dualQuaternion[7];
565
- return out;
566
- };
560
+ export const conjugate = (dualQuaternion, out) => fromValues(-dualQuaternion[0], -dualQuaternion[1], -dualQuaternion[2], dualQuaternion[3], -dualQuaternion[4], -dualQuaternion[5], -dualQuaternion[6], dualQuaternion[7], out);
567
561
  /**
568
562
  * Normalize a dual quaternion.
569
563
  * @param dualQuaternion - The dual quaternion.
570
564
  * @param out - The dual quaternion to store the result in.
571
565
  * @returns The normalized dual quaternion.
566
+ * @public
572
567
  */
573
568
  export const normalize = (dualQuaternion, out) => {
574
569
  let magnitude = getSquaredMagnitude(dualQuaternion);
575
- if (magnitude > 0) {
576
- magnitude = Math.sqrt(magnitude);
577
- const a0 = dualQuaternion[0] / magnitude;
578
- const a1 = dualQuaternion[1] / magnitude;
579
- const a2 = dualQuaternion[2] / magnitude;
580
- const a3 = dualQuaternion[3] / magnitude;
581
- const b0 = dualQuaternion[4];
582
- const b1 = dualQuaternion[5];
583
- const b2 = dualQuaternion[6];
584
- const b3 = dualQuaternion[7];
585
- const aDotB = a0 * b0 + a1 * b1 + a2 * b2 + a3 * b3;
586
- out[0] = a0;
587
- out[1] = a1;
588
- out[2] = a2;
589
- out[3] = a3;
590
- out[4] = (b0 - a0 * aDotB) / magnitude;
591
- out[5] = (b1 - a1 * aDotB) / magnitude;
592
- out[6] = (b2 - a2 * aDotB) / magnitude;
593
- out[7] = (b3 - a3 * aDotB) / magnitude;
594
- }
595
- return out;
570
+ if (magnitude <= 0) {
571
+ return out;
572
+ }
573
+ magnitude = Math.sqrt(magnitude);
574
+ const a0 = dualQuaternion[0] / magnitude;
575
+ const a1 = dualQuaternion[1] / magnitude;
576
+ const a2 = dualQuaternion[2] / magnitude;
577
+ const a3 = dualQuaternion[3] / magnitude;
578
+ const b0 = dualQuaternion[4];
579
+ const b1 = dualQuaternion[5];
580
+ const b2 = dualQuaternion[6];
581
+ const b3 = dualQuaternion[7];
582
+ const aDotB = a0 * b0 + a1 * b1 + a2 * b2 + a3 * b3;
583
+ return fromValues(a0, a1, a2, a3, (b0 - a0 * aDotB) / magnitude, (b1 - a1 * aDotB) / magnitude, (b2 - a2 * aDotB) / magnitude, (b3 - a3 * aDotB) / magnitude, out);
596
584
  };
597
585
  /**
598
586
  * Determine whether or not two dual quaternions are exactly equivalent.
599
587
  * @param a - The first dual quaternion.
600
588
  * @param b - The second dual quaternion.
601
589
  * @returns Whether or not the dual quaternions are equivalent.
590
+ * @public
602
591
  */
603
- export const exactEquals = (a, b) => {
604
- return (a[0] === b[0] &&
605
- a[1] === b[1] &&
606
- a[2] === b[2] &&
607
- a[3] === b[3] &&
608
- a[4] === b[4] &&
609
- a[5] === b[5] &&
610
- a[6] === b[6] &&
611
- a[7] === b[7]);
612
- };
592
+ export const exactEquals = (a, b) => a[0] === b[0] &&
593
+ a[1] === b[1] &&
594
+ a[2] === b[2] &&
595
+ a[3] === b[3] &&
596
+ a[4] === b[4] &&
597
+ a[5] === b[5] &&
598
+ a[6] === b[6] &&
599
+ a[7] === b[7];
613
600
  /**
614
601
  * Determine whether or not two dual quaternions are roughly equivalent.
615
602
  * @param a - The first dual quaternion.
616
603
  * @param b - The second dual quaternion.
617
604
  * @returns Whether or not the dual quaternions are equivalent.
605
+ * @public
618
606
  */
619
- export const equals = (a, b) => {
620
- const a0 = a[0];
621
- const a1 = a[1];
622
- const a2 = a[2];
623
- const a3 = a[3];
624
- const a4 = a[4];
625
- const a5 = a[5];
626
- const a6 = a[6];
627
- const a7 = a[7];
628
- const b0 = b[0];
629
- const b1 = b[1];
630
- const b2 = b[2];
631
- const b3 = b[3];
632
- const b4 = b[4];
633
- const b5 = b[5];
634
- const b6 = b[6];
635
- const b7 = b[7];
636
- return (Math.abs(a0 - b0) <= epsilon * Math.max(1, Math.abs(a0), Math.abs(b0)) &&
637
- Math.abs(a1 - b1) <= epsilon * Math.max(1, Math.abs(a1), Math.abs(b1)) &&
638
- Math.abs(a2 - b2) <= epsilon * Math.max(1, Math.abs(a2), Math.abs(b2)) &&
639
- Math.abs(a3 - b3) <= epsilon * Math.max(1, Math.abs(a3), Math.abs(b3)) &&
640
- Math.abs(a4 - b4) <= epsilon * Math.max(1, Math.abs(a4), Math.abs(b4)) &&
641
- Math.abs(a5 - b5) <= epsilon * Math.max(1, Math.abs(a5), Math.abs(b5)) &&
642
- Math.abs(a6 - b6) <= epsilon * Math.max(1, Math.abs(a6), Math.abs(b6)) &&
643
- Math.abs(a7 - b7) <= epsilon * Math.max(1, Math.abs(a7), Math.abs(b7)));
644
- };
607
+ export const equals = (a, b) => approxRelative(a[0], b[0]) &&
608
+ approxRelative(a[1], b[1]) &&
609
+ approxRelative(a[2], b[2]) &&
610
+ approxRelative(a[3], b[3]) &&
611
+ approxRelative(a[4], b[4]) &&
612
+ approxRelative(a[5], b[5]) &&
613
+ approxRelative(a[6], b[6]) &&
614
+ approxRelative(a[7], b[7]);
645
615
  /**
646
616
  * A complex number that is commonly used to describe transformations.
647
- * @see [Dual quaternion](https://en.wikipedia.org/wiki/Dual_quaternion)
617
+ * @see {@link https://en.wikipedia.org/wiki/Dual_quaternion | Dual quaternion}
618
+ * @public
648
619
  */
649
620
  export default class DualQuaternion extends Float32Array {
650
621
  /**
@@ -664,9 +635,9 @@ export default class DualQuaternion extends Float32Array {
664
635
  return fromValues(x1, y1, z1, w1, x2, y2, z2, w2, out);
665
636
  }
666
637
  /**
667
- * Create a dual quaternion from the given quaternion and translation.
668
- * @param q - The quaternion.
669
- * @param t - The translation.
638
+ * Create a dual quaternion from the given rotation and translation.
639
+ * @param q - The rotation quaternion.
640
+ * @param t - The translation vector.
670
641
  * @param out - The dual quaternion to store the result in.
671
642
  * @returns The dual quaternion.
672
643
  */
@@ -675,7 +646,7 @@ export default class DualQuaternion extends Float32Array {
675
646
  }
676
647
  /**
677
648
  * Create a dual quaternion from the given translation.
678
- * @param t - The translation.
649
+ * @param t - The translation vector.
679
650
  * @param out - The dual quaternion to store the result in.
680
651
  * @returns The dual quaternion.
681
652
  */
@@ -683,8 +654,8 @@ export default class DualQuaternion extends Float32Array {
683
654
  return fromTranslation(t, out);
684
655
  }
685
656
  /**
686
- * Create a dual quaternion from the given quaternion.
687
- * @param q - The quaternion.
657
+ * Create a dual quaternion from the given rotation.
658
+ * @param q - The rotation quaternion.
688
659
  * @param out - The dual quaternion to store the result in.
689
660
  * @returns The dual quaternion.
690
661
  */
@@ -702,7 +673,7 @@ export default class DualQuaternion extends Float32Array {
702
673
  }
703
674
  /**
704
675
  * Create an identity dual quaternion.
705
- * @see [Dual quaternion](https://en.wikipedia.org/wiki/Dual_quaternion)
676
+ * @see {@link https://en.wikipedia.org/wiki/Dual_quaternion | Dual quaternion}
706
677
  */
707
678
  constructor() {
708
679
  super(8);
@@ -753,14 +724,14 @@ export default class DualQuaternion extends Float32Array {
753
724
  * @returns The real part.
754
725
  */
755
726
  getReal(out = new Quaternion()) {
756
- return xetReal(this, out);
727
+ return getReal(this, out);
757
728
  }
758
729
  /**
759
730
  * Set the real part of this dual quaternion.
760
731
  * @param q - The quaternion.
761
732
  */
762
733
  setReal(q) {
763
- xetReal(q, this);
734
+ setReal(q, this);
764
735
  }
765
736
  /**
766
737
  * Get the dual part of this dual quaternion.
@@ -822,21 +793,21 @@ export default class DualQuaternion extends Float32Array {
822
793
  return rotateZ(this, r, out);
823
794
  }
824
795
  /**
825
- * Multiply this dual quaternion by a quaternion.
796
+ * Rotate this dual quaternion by a quaternion (using the quaternion as the multiplicand).
826
797
  * @param q - The quaternion.
827
798
  * @param out - The dual quaternion to store the result in.
828
799
  * @returns The rotated dual quaternion.
829
- * @see [Quaternion](https://en.wikipedia.org/wiki/Quaternion)
800
+ * @see {@link https://en.wikipedia.org/wiki/Quaternion | Quaternion}
830
801
  */
831
802
  rotateByQuaternionAppend(q, out = new DualQuaternion()) {
832
803
  return rotateByQuaternionAppend(this, q, out);
833
804
  }
834
805
  /**
835
- * Multiply a quaternion by this dual quaternion.
806
+ * Rotate this dual quaternion by a quaternion (using the quaternion as the multiplier).
836
807
  * @param q - The quaternion.
837
808
  * @param out - The dual quaternion to store the result in.
838
809
  * @returns The rotated dual quaternion.
839
- * @see [Quaternion](https://en.wikipedia.org/wiki/Quaternion)
810
+ * @see {@link https://en.wikipedia.org/wiki/Quaternion | Quaternion}
840
811
  */
841
812
  rotateByQuaternionPrepend(q, out = new DualQuaternion()) {
842
813
  return rotateByQuaternionPrepend(q, this, out);
@@ -882,7 +853,7 @@ export default class DualQuaternion extends Float32Array {
882
853
  * Calculate the dot product of this and another dual quaternion.
883
854
  * @param dq - The other dual quaternion.
884
855
  * @returns The dot product.
885
- * @see [Dot product](https://en.wikipedia.org/wiki/Dot_product)
856
+ * @see {@link https://en.wikipedia.org/wiki/Dot_product | Dot product}
886
857
  */
887
858
  dot(dq) {
888
859
  return dot(this, dq);