@ac-kit/math-linear 0.2.1 → 0.3.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.
Files changed (178) hide show
  1. package/CHANGELOG.md +257 -0
  2. package/README.md +229 -16
  3. package/dist/_brand.d.ts +14 -0
  4. package/dist/_brand.d.ts.map +1 -0
  5. package/dist/_brand.js +2 -0
  6. package/dist/_brand.js.map +1 -0
  7. package/dist/_invert.d.ts +19 -0
  8. package/dist/_invert.d.ts.map +1 -0
  9. package/dist/_invert.js +48 -0
  10. package/dist/_invert.js.map +1 -0
  11. package/dist/_slerp.d.ts +15 -0
  12. package/dist/_slerp.d.ts.map +1 -1
  13. package/dist/_slerp.js +47 -0
  14. package/dist/_slerp.js.map +1 -1
  15. package/dist/_strided-range.d.ts +23 -0
  16. package/dist/_strided-range.d.ts.map +1 -0
  17. package/dist/_strided-range.js +75 -0
  18. package/dist/_strided-range.js.map +1 -0
  19. package/dist/_trs.d.ts +38 -0
  20. package/dist/_trs.d.ts.map +1 -0
  21. package/dist/_trs.js +132 -0
  22. package/dist/_trs.js.map +1 -0
  23. package/dist/affine2-array.d.ts +53 -0
  24. package/dist/affine2-array.d.ts.map +1 -0
  25. package/dist/affine2-array.js +107 -0
  26. package/dist/affine2-array.js.map +1 -0
  27. package/dist/affine2-componentwise.d.ts +28 -0
  28. package/dist/affine2-componentwise.d.ts.map +1 -0
  29. package/dist/affine2-componentwise.js +66 -0
  30. package/dist/affine2-componentwise.js.map +1 -0
  31. package/dist/affine2.d.ts +144 -0
  32. package/dist/affine2.d.ts.map +1 -0
  33. package/dist/affine2.js +375 -0
  34. package/dist/affine2.js.map +1 -0
  35. package/dist/affine3-array.d.ts +53 -0
  36. package/dist/affine3-array.d.ts.map +1 -0
  37. package/dist/affine3-array.js +137 -0
  38. package/dist/affine3-array.js.map +1 -0
  39. package/dist/affine3-componentwise.d.ts +32 -0
  40. package/dist/affine3-componentwise.d.ts.map +1 -0
  41. package/dist/affine3-componentwise.js +100 -0
  42. package/dist/affine3-componentwise.js.map +1 -0
  43. package/dist/affine3.d.ts +192 -0
  44. package/dist/affine3.d.ts.map +1 -0
  45. package/dist/affine3.js +718 -0
  46. package/dist/affine3.js.map +1 -0
  47. package/dist/checked/index.d.ts +35 -0
  48. package/dist/checked/index.d.ts.map +1 -0
  49. package/dist/checked/index.js +58 -0
  50. package/dist/checked/index.js.map +1 -0
  51. package/dist/euler.d.ts +65 -0
  52. package/dist/euler.d.ts.map +1 -0
  53. package/dist/euler.js +217 -0
  54. package/dist/euler.js.map +1 -0
  55. package/dist/index.d.ts +29 -0
  56. package/dist/index.d.ts.map +1 -1
  57. package/dist/index.js +29 -0
  58. package/dist/index.js.map +1 -1
  59. package/dist/kl-activations.d.ts.map +1 -1
  60. package/dist/kl-activations.js +4 -3
  61. package/dist/kl-activations.js.map +1 -1
  62. package/dist/mat2x2-array.d.ts +36 -0
  63. package/dist/mat2x2-array.d.ts.map +1 -0
  64. package/dist/mat2x2-array.js +71 -0
  65. package/dist/mat2x2-array.js.map +1 -0
  66. package/dist/mat2x2-componentwise.d.ts +86 -0
  67. package/dist/mat2x2-componentwise.d.ts.map +1 -0
  68. package/dist/mat2x2-componentwise.js +199 -0
  69. package/dist/mat2x2-componentwise.js.map +1 -0
  70. package/dist/mat2x2.d.ts +67 -25
  71. package/dist/mat2x2.d.ts.map +1 -1
  72. package/dist/mat2x2.js +150 -94
  73. package/dist/mat2x2.js.map +1 -1
  74. package/dist/mat3x3-array.d.ts +36 -0
  75. package/dist/mat3x3-array.d.ts.map +1 -0
  76. package/dist/mat3x3-array.js +91 -0
  77. package/dist/mat3x3-array.js.map +1 -0
  78. package/dist/mat3x3-componentwise.d.ts +86 -0
  79. package/dist/mat3x3-componentwise.d.ts.map +1 -0
  80. package/dist/mat3x3-componentwise.js +299 -0
  81. package/dist/mat3x3-componentwise.js.map +1 -0
  82. package/dist/mat3x3.d.ts +131 -48
  83. package/dist/mat3x3.d.ts.map +1 -1
  84. package/dist/mat3x3.js +434 -193
  85. package/dist/mat3x3.js.map +1 -1
  86. package/dist/mat4x4-array.d.ts +46 -0
  87. package/dist/mat4x4-array.d.ts.map +1 -0
  88. package/dist/mat4x4-array.js +133 -0
  89. package/dist/mat4x4-array.js.map +1 -0
  90. package/dist/mat4x4-componentwise.d.ts +87 -0
  91. package/dist/mat4x4-componentwise.d.ts.map +1 -0
  92. package/dist/mat4x4-componentwise.js +434 -0
  93. package/dist/mat4x4-componentwise.js.map +1 -0
  94. package/dist/mat4x4.d.ts +195 -67
  95. package/dist/mat4x4.d.ts.map +1 -1
  96. package/dist/mat4x4.js +849 -335
  97. package/dist/mat4x4.js.map +1 -1
  98. package/dist/projection.d.ts +98 -0
  99. package/dist/projection.d.ts.map +1 -0
  100. package/dist/projection.js +369 -0
  101. package/dist/projection.js.map +1 -0
  102. package/dist/quaternion-array.d.ts +47 -0
  103. package/dist/quaternion-array.d.ts.map +1 -0
  104. package/dist/quaternion-array.js +86 -0
  105. package/dist/quaternion-array.js.map +1 -0
  106. package/dist/quaternion.d.ts +104 -22
  107. package/dist/quaternion.d.ts.map +1 -1
  108. package/dist/quaternion.js +294 -181
  109. package/dist/quaternion.js.map +1 -1
  110. package/dist/transform.d.ts +220 -0
  111. package/dist/transform.d.ts.map +1 -0
  112. package/dist/transform.js +412 -0
  113. package/dist/transform.js.map +1 -0
  114. package/dist/tridiagonal.d.ts +52 -0
  115. package/dist/tridiagonal.d.ts.map +1 -0
  116. package/dist/tridiagonal.js +90 -0
  117. package/dist/tridiagonal.js.map +1 -0
  118. package/dist/upload.d.ts +55 -0
  119. package/dist/upload.d.ts.map +1 -0
  120. package/dist/upload.js +129 -0
  121. package/dist/upload.js.map +1 -0
  122. package/dist/vec2-array-componentwise.d.ts +189 -0
  123. package/dist/vec2-array-componentwise.d.ts.map +1 -0
  124. package/dist/vec2-array-componentwise.js +424 -0
  125. package/dist/vec2-array-componentwise.js.map +1 -0
  126. package/dist/vec2-array.d.ts +53 -0
  127. package/dist/vec2-array.d.ts.map +1 -0
  128. package/dist/vec2-array.js +123 -0
  129. package/dist/vec2-array.js.map +1 -0
  130. package/dist/vec2-componentwise.d.ts +311 -0
  131. package/dist/vec2-componentwise.d.ts.map +1 -0
  132. package/dist/vec2-componentwise.js +542 -0
  133. package/dist/vec2-componentwise.js.map +1 -0
  134. package/dist/vec2.d.ts +97 -82
  135. package/dist/vec2.d.ts.map +1 -1
  136. package/dist/vec2.js +121 -216
  137. package/dist/vec2.js.map +1 -1
  138. package/dist/vec3-array-componentwise.d.ts +189 -0
  139. package/dist/vec3-array-componentwise.d.ts.map +1 -0
  140. package/dist/vec3-array-componentwise.js +458 -0
  141. package/dist/vec3-array-componentwise.js.map +1 -0
  142. package/dist/vec3-array.d.ts +102 -0
  143. package/dist/vec3-array.d.ts.map +1 -0
  144. package/dist/vec3-array.js +299 -0
  145. package/dist/vec3-array.js.map +1 -0
  146. package/dist/vec3-componentwise.d.ts +310 -0
  147. package/dist/vec3-componentwise.d.ts.map +1 -0
  148. package/dist/vec3-componentwise.js +594 -0
  149. package/dist/vec3-componentwise.js.map +1 -0
  150. package/dist/vec3.d.ts +177 -87
  151. package/dist/vec3.d.ts.map +1 -1
  152. package/dist/vec3.js +366 -273
  153. package/dist/vec3.js.map +1 -1
  154. package/dist/vec4-array-componentwise.d.ts +155 -0
  155. package/dist/vec4-array-componentwise.d.ts.map +1 -0
  156. package/dist/vec4-array-componentwise.js +401 -0
  157. package/dist/vec4-array-componentwise.js.map +1 -0
  158. package/dist/vec4-array.d.ts +12 -0
  159. package/dist/vec4-array.d.ts.map +1 -0
  160. package/dist/vec4-array.js +43 -0
  161. package/dist/vec4-array.js.map +1 -0
  162. package/dist/vec4-componentwise.d.ts +299 -0
  163. package/dist/vec4-componentwise.d.ts.map +1 -0
  164. package/dist/vec4-componentwise.js +637 -0
  165. package/dist/vec4-componentwise.js.map +1 -0
  166. package/dist/vec4.d.ts +57 -53
  167. package/dist/vec4.d.ts.map +1 -1
  168. package/dist/vec4.js +94 -246
  169. package/dist/vec4.js.map +1 -1
  170. package/dist/view-basis.d.ts +15 -0
  171. package/dist/view-basis.d.ts.map +1 -0
  172. package/dist/view-basis.js +29 -0
  173. package/dist/view-basis.js.map +1 -0
  174. package/dist/viewport.d.ts +114 -0
  175. package/dist/viewport.d.ts.map +1 -0
  176. package/dist/viewport.js +250 -0
  177. package/dist/viewport.js.map +1 -0
  178. package/package.json +18 -9
@@ -0,0 +1,47 @@
1
+ import type { ReadonlyQuaternion, Quaternion } from "@ac-kit/math-complex";
2
+ /**
3
+ * Creates a buffer for `count` quaternion elements: a zero-filled
4
+ * `Float64Array` of `count × 4` numbers, element `i` at `[i·4, i·4 + 4)`, a
5
+ * zero element being the all-zero quaternion (use {@link quaternionStore} with
6
+ * the identity to fill it with identities). Allocates.
7
+ *
8
+ * @throws {RangeError} When `count` is not a non-negative safe integer or
9
+ * `count × 4` is not a valid typed array length.
10
+ */
11
+ export declare function quaternionArrayCreate(count: number): Float64Array<ArrayBuffer>;
12
+ /**
13
+ * Writes element `index` of `array`, the numbers at `[index·4, index·4 + 4)`,
14
+ * into `out`. Each component is written as `+array[i]`, so an index past the
15
+ * end of `array` gives `NaN`, never `undefined`: the quaternion stays clean
16
+ * whatever the caller does. Checking the index is the job of the checked
17
+ * layer.
18
+ *
19
+ * The quaternion is copied: it is never a view of `array`. O(1).
20
+ */
21
+ export declare function quaternionLoad(out: Quaternion, array: Float64Array, index: number): Quaternion;
22
+ /**
23
+ * Writes `value` into `array` as element `index`, at `[index·4, index·4 + 4)`.
24
+ * An element past the end of `array` writes nothing, as a typed array drops an
25
+ * out-of-range write. O(1).
26
+ */
27
+ export declare function quaternionStore(array: Float64Array, index: number, value: ReadonlyQuaternion): void;
28
+ /**
29
+ * Like {@link quaternionLoad} for interleaved data: element `index` starts at
30
+ * `offset + index·stride`, both counted in numbers, and its 4 components follow
31
+ * one another. An index past the end gives `NaN` components. O(1).
32
+ */
33
+ export declare function quaternionLoadStrided(out: Quaternion, array: Float64Array, offset: number, stride: number, index: number): Quaternion;
34
+ /**
35
+ * Like {@link quaternionStore} for interleaved data: element `index` starts at
36
+ * `offset + index·stride`, both counted in numbers. A component past the end of
37
+ * `array` writes nothing. O(1).
38
+ */
39
+ export declare function quaternionStoreStrided(array: Float64Array, offset: number, stride: number, index: number, value: ReadonlyQuaternion): void;
40
+ /**
41
+ * Whether every number of `array` is finite: the check for a buffer of
42
+ * quaternion elements read from untrusted data or about to be uploaded. The
43
+ * length is not required to be a multiple of 4 (see `assertFiniteBuffer` for
44
+ * that). O(n).
45
+ */
46
+ export declare function quaternionArrayIsFinite(array: Float64Array): boolean;
47
+ //# sourceMappingURL=quaternion-array.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"quaternion-array.d.ts","sourceRoot":"","sources":["../src/quaternion-array.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAE3E;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CACpC,KAAK,EAAE,MAAM,GACX,YAAY,CAAC,WAAW,CAAC,CAG3B;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAC7B,GAAG,EAAE,UAAU,EACf,KAAK,EAAE,YAAY,EACnB,KAAK,EAAE,MAAM,GACX,UAAU,CAQZ;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAC9B,KAAK,EAAE,YAAY,EACnB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,kBAAkB,GACvB,IAAI,CAMN;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CACpC,GAAG,EAAE,UAAU,EACf,KAAK,EAAE,YAAY,EACnB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,GACX,UAAU,CAQZ;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CACrC,KAAK,EAAE,YAAY,EACnB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,kBAAkB,GACvB,IAAI,CAMN;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAOpE"}
@@ -0,0 +1,86 @@
1
+ // Generated from scripts/templates/value-array.liquid by scripts/generate-componentwise.ts. Do not edit.
2
+ import { assertInteger } from "@ac-kit/core";
3
+ /**
4
+ * Creates a buffer for `count` quaternion elements: a zero-filled
5
+ * `Float64Array` of `count × 4` numbers, element `i` at `[i·4, i·4 + 4)`, a
6
+ * zero element being the all-zero quaternion (use {@link quaternionStore} with
7
+ * the identity to fill it with identities). Allocates.
8
+ *
9
+ * @throws {RangeError} When `count` is not a non-negative safe integer or
10
+ * `count × 4` is not a valid typed array length.
11
+ */
12
+ export function quaternionArrayCreate(count) {
13
+ assertInteger(count, "quaternionArrayCreate: count", 0);
14
+ return new Float64Array(count * 4);
15
+ }
16
+ /**
17
+ * Writes element `index` of `array`, the numbers at `[index·4, index·4 + 4)`,
18
+ * into `out`. Each component is written as `+array[i]`, so an index past the
19
+ * end of `array` gives `NaN`, never `undefined`: the quaternion stays clean
20
+ * whatever the caller does. Checking the index is the job of the checked
21
+ * layer.
22
+ *
23
+ * The quaternion is copied: it is never a view of `array`. O(1).
24
+ */
25
+ export function quaternionLoad(out, array, index) {
26
+ const base = index * 4;
27
+ // The `!` is for the compiler: past the end `+undefined` is `NaN`.
28
+ out[0] = +array[base];
29
+ out[1] = +array[base + 1];
30
+ out[2] = +array[base + 2];
31
+ out[3] = +array[base + 3];
32
+ return out;
33
+ }
34
+ /**
35
+ * Writes `value` into `array` as element `index`, at `[index·4, index·4 + 4)`.
36
+ * An element past the end of `array` writes nothing, as a typed array drops an
37
+ * out-of-range write. O(1).
38
+ */
39
+ export function quaternionStore(array, index, value) {
40
+ const base = index * 4;
41
+ array[base] = value[0];
42
+ array[base + 1] = value[1];
43
+ array[base + 2] = value[2];
44
+ array[base + 3] = value[3];
45
+ }
46
+ /**
47
+ * Like {@link quaternionLoad} for interleaved data: element `index` starts at
48
+ * `offset + index·stride`, both counted in numbers, and its 4 components follow
49
+ * one another. An index past the end gives `NaN` components. O(1).
50
+ */
51
+ export function quaternionLoadStrided(out, array, offset, stride, index) {
52
+ const base = offset + index * stride;
53
+ // The `!` is for the compiler: past the end `+undefined` is `NaN`.
54
+ out[0] = +array[base];
55
+ out[1] = +array[base + 1];
56
+ out[2] = +array[base + 2];
57
+ out[3] = +array[base + 3];
58
+ return out;
59
+ }
60
+ /**
61
+ * Like {@link quaternionStore} for interleaved data: element `index` starts at
62
+ * `offset + index·stride`, both counted in numbers. A component past the end of
63
+ * `array` writes nothing. O(1).
64
+ */
65
+ export function quaternionStoreStrided(array, offset, stride, index, value) {
66
+ const base = offset + index * stride;
67
+ array[base] = value[0];
68
+ array[base + 1] = value[1];
69
+ array[base + 2] = value[2];
70
+ array[base + 3] = value[3];
71
+ }
72
+ /**
73
+ * Whether every number of `array` is finite: the check for a buffer of
74
+ * quaternion elements read from untrusted data or about to be uploaded. The
75
+ * length is not required to be a multiple of 4 (see `assertFiniteBuffer` for
76
+ * that). O(n).
77
+ */
78
+ export function quaternionArrayIsFinite(array) {
79
+ for (let index = 0; index < array.length; index++) {
80
+ if (!Number.isFinite(array[index])) {
81
+ return false;
82
+ }
83
+ }
84
+ return true;
85
+ }
86
+ //# sourceMappingURL=quaternion-array.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"quaternion-array.js","sourceRoot":"","sources":["../src/quaternion-array.ts"],"names":[],"mappings":"AAAA,yGAAyG;AAEzG,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAG7C;;;;;;;;GAQG;AACH,MAAM,UAAU,qBAAqB,CACpC,KAAa;IAEb,aAAa,CAAC,KAAK,EAAE,8BAA8B,EAAE,CAAC,CAAC,CAAC;IACxD,OAAO,IAAI,YAAY,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;AACpC,CA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CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,CAAE,CAAC;IAC3B,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,CAAE,CAAC;IAC3B,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,CAAE,CAAC;IAC3B,OAAO,GAAG,CAAC;AACZ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CACrC,KAAmB,EACnB,MAAc,EACd,MAAc,EACd,KAAa,EACb,KAAyB;IAEzB,MAAM,IAAI,GAAG,MAAM,GAAG,KAAK,GAAG,MAAM,CAAC;IACrC,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IACvB,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IAC3B,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IAC3B,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;AAC5B,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,uBAAuB,CAAC,KAAmB;IAC1D,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC;QACnD,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;YACpC,OAAO,KAAK,CAAC;QACd,CAAC;IACF,CAAC;IACD,OAAO,IAAI,CAAC;AACb,CAAC"}
@@ -1,23 +1,105 @@
1
- import { type Quaternion } from "@ac-kit/math-complex";
2
- import { Mat4x4 } from "./mat4x4.js";
3
- import { Vec3 } from "./vec3.js";
4
- export type { Quaternion } from "@ac-kit/math-complex";
5
- export declare function quaternionAngle(q: Quaternion): number;
6
- export declare function quaternionAxis(q: Quaternion): Vec3;
7
- export declare function quaternionFromAxisAngle(axis: Vec3, angle: number): Quaternion;
8
- /** Converts a rotation matrix to a quaternion. */
9
- export declare function quaternionFromRotationMatrix(m: Mat4x4): Quaternion;
10
- /**
11
- * Creates the shortest-arc quaternion that rotates `from` to `to`. Both vectors
12
- * must be non-zero; they do not need to be unit-length. Handles the
13
- * anti-parallel (180°) case by using an arbitrary perpendicular axis.
14
- */
15
- export declare function quaternionFromVec3ToVec3(from: Vec3, to: Vec3): Quaternion;
16
- /**
17
- * Non-normalized linear interpolation between two quaternions. Faster than
18
- * slerp but does not preserve unit length — normalize if needed.
19
- */
20
- export declare function quaternionLerp(q1: Quaternion, q2: Quaternion, t: number): Quaternion;
21
- export declare function quaternionSlerp(q1: Quaternion, q2: Quaternion, t: number): Quaternion;
22
- export declare function quaternionToRotationMatrix(q: Quaternion): Mat4x4;
1
+ import { type Quaternion, type ReadonlyQuaternion } from "@ac-kit/math-complex";
2
+ import type { ReadonlyMat3x3 } from "./mat3x3.js";
3
+ import type { ReadonlyMat4x4 } from "./mat4x4.js";
4
+ import { type ReadonlyVec3, type Vec3 } from "./vec3.js";
5
+ export { type Quaternion, quaternionAdd, quaternionClone, quaternionConjugate, quaternionCopy, quaternionCreate, quaternionDot, quaternionEquals, quaternionFromArray, quaternionIdentity, quaternionInvert, quaternionInvertScaled, quaternionIsClose, quaternionIsFinite, quaternionLength, quaternionLengthScaled, quaternionLengthSquared, quaternionMultiply, quaternionMultiplyScalar, quaternionNegate, quaternionNormalize, quaternionNormalizeScaled, quaternionOf, quaternionSet, quaternionSubtract, type ReadonlyQuaternion, } from "@ac-kit/math-complex";
6
+ /**
7
+ * The angle of the rotation of `q`, `2·atan2(|v|, |w|)` with `v` the vector
8
+ * part and `w` the scalar part: in `[0, π]` for `q` and `−q` alike (the same
9
+ * rotation), accurate for small angles where `2·acos(w)` is not, and right for
10
+ * a quaternion that is not unit length, as long as its components are between
11
+ * about `1e-150` and `1e150` (the vector part is squared): the zero quaternion
12
+ * gives `0`, and so does a rotation under about `1e-154` rad, while components
13
+ * beyond about `1e154` overflow to `π`. `NaN` gives `NaN`.
14
+ */
15
+ export declare function quaternionAngle(q: ReadonlyQuaternion): number;
16
+ /**
17
+ * Writes the axis of the rotation of `q` into `out`: the unit vector `v / |v|`
18
+ * of the vector part, negated when the scalar part is negative so that the pair
19
+ * of this axis and {@link quaternionAngle} (in `[0, π]`) is the rotation of `q`
20
+ * and of `−q` alike. A quaternion with no vector part, the identity, has no
21
+ * axis and gives `[1, 0, 0]`. Accurate at every angle, however small, and for a
22
+ * quaternion that is not unit length. `NaN` gives `NaN`.
23
+ */
24
+ export declare function quaternionAxis(out: Vec3, q: ReadonlyQuaternion): Vec3;
25
+ /**
26
+ * Writes the rotation by `angle` radians about the unit vector `axis`
27
+ * (right-hand rule) into `out`: `[axis · sin(angle/2), cos(angle/2)]`. `axis`
28
+ * is not normalised here.
29
+ */
30
+ export declare function quaternionFromAxisAngle(out: Quaternion, axis: ReadonlyVec3, angle: number): Quaternion;
31
+ /**
32
+ * Writes the unit quaternion of a rotation matrix into `out` (Shepperd's
33
+ * method: the largest of the trace and the diagonal entries picks the formula,
34
+ * so the divisor never vanishes). `m` must be orthonormal with a positive
35
+ * determinant; the result is not normalised, and `q` and `−q` are the same
36
+ * rotation.
37
+ */
38
+ export declare function quaternionFromMat3x3(out: Quaternion, m: ReadonlyMat3x3): Quaternion;
39
+ /**
40
+ * Writes the unit quaternion of the rotation in the upper-left 3 × 3 block of
41
+ * `m` into `out`, as {@link quaternionFromMat3x3}; the translation and the last
42
+ * row are ignored.
43
+ */
44
+ export declare function quaternionFromMat4x4(out: Quaternion, m: ReadonlyMat4x4): Quaternion;
45
+ /**
46
+ * Writes into `out` the shortest-arc rotation that turns the direction `from`
47
+ * onto the direction `to`. Neither needs to be unit length (they are normalised
48
+ * at any magnitude). Opposite directions, whose shortest arc is not unique,
49
+ * turn by `π` about {@link vec3Perpendicular} of `from`. A zero vector has no
50
+ * direction and gives the identity; `NaN` gives `NaN`. The rotation misses `to`
51
+ * by a few `1e-16` rad except near opposite directions, where no method does
52
+ * better than a few `1e-8` rad.
53
+ */
54
+ export declare function quaternionFromVec3ToVec3(out: Quaternion, from: ReadonlyVec3, to: ReadonlyVec3): Quaternion;
55
+ /**
56
+ * Writes `q · Rx(angle)` into `out`: the rotation by `angle` radians about the
57
+ * x axis applied first, in the local frame of `q`. `out` may be `q`.
58
+ */
59
+ export declare function quaternionRotateX(out: Quaternion, q: ReadonlyQuaternion, angle: number): Quaternion;
60
+ /**
61
+ * Writes `q · Ry(angle)` into `out`, as {@link quaternionRotateX} about the y
62
+ * axis. `out` may be `q`.
63
+ */
64
+ export declare function quaternionRotateY(out: Quaternion, q: ReadonlyQuaternion, angle: number): Quaternion;
65
+ /**
66
+ * Writes `q · Rz(angle)` into `out`, as {@link quaternionRotateX} about the z
67
+ * axis. `out` may be `q`.
68
+ */
69
+ export declare function quaternionRotateZ(out: Quaternion, q: ReadonlyQuaternion, angle: number): Quaternion;
70
+ /**
71
+ * Writes into `out` the normalised linear interpolation from `a` to `b`, along
72
+ * the shorter arc: `b` is negated first when the two lie in opposite
73
+ * hemispheres (`a · b < 0`, decided exactly where the plain dot product is
74
+ * within its own rounding error), then `a + t·(b − a)` is scaled to unit
75
+ * length. Cheaper than {@link quaternionSlerp} and the same path, but the angle
76
+ * does not grow evenly with `t`, and `t` outside `[0, 1]` extrapolates (the
77
+ * result is right for `|t|` up to about `1e150`, beyond which the normalisation
78
+ * overflows). `out` may be `a` or `b`.
79
+ */
80
+ export declare function quaternionNlerp(out: Quaternion, a: ReadonlyQuaternion, b: ReadonlyQuaternion, t: number): Quaternion;
81
+ /**
82
+ * Writes into `out` the spherical linear interpolation from `a` to `b` along
83
+ * the shorter arc, at constant angular speed: `t = 0` is `a`, `t = 1` is `b` or
84
+ * `−b` (the same rotation), and `t` outside `[0, 1]` extrapolates along the
85
+ * same arc at the same speed. The hemisphere is decided as in
86
+ * {@link quaternionNlerp}. Both must be unit length. Within `[0, 1]`, where the
87
+ * two are within about `1.8°` of each other, the interpolation is the
88
+ * normalised linear one, the same arc to within `1e-3` rad of parameterisation;
89
+ * outside `[0, 1]` the arc formula is kept. The angle `t · θ` it turns is right
90
+ * to its last digits while `|t · θ|` is below about `1e15` rad (a sine of a
91
+ * larger angle has none left), and `t` past about `1e150` overflows. `out` may
92
+ * be `a` or `b`.
93
+ */
94
+ export declare function quaternionSlerp(out: Quaternion, a: ReadonlyQuaternion, b: ReadonlyQuaternion, t: number): Quaternion;
95
+ /**
96
+ * The angle of the rotation that turns `a` into `b`, that of `a⁻¹ · b`, in `[0,
97
+ * π]`: `q` and `−q` count as the same rotation, and the angle is accurate for
98
+ * rotations that nearly coincide where `2·acos(a · b)` is not. Right for
99
+ * quaternions that are not unit length, as long as their components are between
100
+ * about `1e-150` and `1e150` (the products are squared): the angle reads `0`
101
+ * for a rotation under about `1e-154` rad and overflows to `π` beyond about
102
+ * `1e154`. `NaN` gives `NaN`.
103
+ */
104
+ export declare function quaternionAngleBetween(a: ReadonlyQuaternion, b: ReadonlyQuaternion): number;
23
105
  //# sourceMappingURL=quaternion.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"quaternion.d.ts","sourceRoot":"","sources":["../src/quaternion.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,UAAU,EAIf,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,IAAI,EAAiD,MAAM,WAAW,CAAC;AAEhF,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAoEvD,wBAAgB,eAAe,CAAC,CAAC,EAAE,UAAU,GAAG,MAAM,CAErD;AAED,wBAAgB,cAAc,CAAC,CAAC,EAAE,UAAU,GAAG,IAAI,CAMlD;AAED,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,GAAG,UA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