@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
package/dist/vec3.d.ts CHANGED
@@ -1,91 +1,181 @@
1
- import { type IsCloseToOptions, type RandomFn, type RoundOptions } from "@ac-kit/core";
2
- import { Mat3x3 } from "./mat3x3.js";
3
- import { Mat4x4 } from "./mat4x4.js";
4
- import { Quaternion } from "./quaternion.js";
5
- import { DistanceType, Vec2 } from "./vec2.js";
6
- export type Vec3 = [number, number, number];
7
- export declare const VEC3_ZERO: [0, 0, 0];
8
- export declare const VEC3_ONE: [1, 1, 1];
9
- export declare function vec3Abs(v: Vec3): Vec3;
10
- export declare function vec3Add(a: Vec3, b: Vec3): Vec3;
11
- export declare function vec3AddScalar(v: Vec3, s: number): Vec3;
12
- export declare function vec3AddScaled(a: Vec3, b: Vec3, s: number): Vec3;
13
- /**
14
- * Computes the angle in radians between two 3D vectors around a given axis. The
15
- * result is in the range (-π, π].
16
- */
17
- export declare function vec3AngleTo(v1: Vec3, v2: Vec3, axis: Vec3): number;
18
- /**
19
- * Computes the angle in radians between two 3D vectors. The result is in the
20
- * range [0, π].
1
+ import type { RandomFn } from "@ac-kit/core";
2
+ import type { ReadonlyQuaternion } from "@ac-kit/math-complex";
3
+ import type { Brand_ } from "./_brand.js";
4
+ import type { ReadonlyAffine3 } from "./affine3.js";
5
+ import type { ReadonlyMat3x3 } from "./mat3x3.js";
6
+ import type { ReadonlyMat4x4 } from "./mat4x4.js";
7
+ import type { ReadonlyVec2 } from "./vec2.js";
8
+ import type { ReadonlyVec4 } from "./vec4.js";
9
+ /**
10
+ * A point, a vector, a size or a direction of space, stored as `[x, y, z]`: a
11
+ * plain array of three binary64 numbers carrying a type-level brand, so an
12
+ * array literal, a `number[]`, a `Float64Array` or a value of another type with
13
+ * three numbers is rejected where a `Vec3` is expected. A buffer of them is a
14
+ * `Float64Array` of `count × 3` numbers, element `i` at `[3i, 3i + 3)`.
21
15
  *
22
- * @throws Error if either vector is a zero-length vector.
23
- */
24
- export declare function vec3AngleBetween(v1: Vec3, v2: Vec3): number;
25
- export declare function vec3ApplyMat3(v: Vec3, m: Mat3x3): Vec3;
26
- /**
27
- * Applies a 4x4 matrix transformation to a 3D vector. The vector is treated as
28
- * a point in homogeneous coordinates (x, y, z, 1).
29
- */
30
- export declare function vec3ApplyMat4(v: Vec3, m: Mat4x4): Vec3;
31
- export declare function vec3ApplyQuaternion(v: Vec3, q: Quaternion): Vec3;
32
- export declare function vec3Clamp(v: Vec3, min: Vec3, max: Vec3): Vec3;
33
- export declare function vec3ClampLength(v: Vec3, minLength: number, maxLength: number): Vec3;
34
- export declare function vec3ClampScalar(v: Vec3, min: number, max: number): Vec3;
35
- export declare function vec3Cross(a: Vec3, b: Vec3): Vec3;
36
- export declare function vec3DistanceTo(a: Vec3, b: Vec3, type?: DistanceType): number;
37
- export declare function vec3DistanceToSq(a: Vec3, b: Vec3): number;
38
- export declare function vec3Divide(a: Vec3, b: Vec3): Vec3;
39
- export declare function vec3DivideScalar(v: Vec3, s: number): Vec3;
40
- export declare function vec3Dot(a: Vec3, b: Vec3): number;
41
- /** Exact component-wise equality. See {@link vec3IsClose} for a tolerant test. */
42
- export declare function vec3Equals(a: Vec3, b: Vec3): boolean;
43
- /**
44
- * Component-wise approximate equality.
16
+ * Only {@link vec3Create}, {@link vec3Of}, {@link vec3Clone},
17
+ * {@link vec3FromArray} and the functions that write an `out` make one. They
18
+ * all start from an array of non-integer doubles, so every `Vec3` is
19
+ * `PACKED_DOUBLE_ELEMENTS` in V8 even when its components are whole numbers,
20
+ * and the hot loops that read it stay monomorphic. An array literal such as
21
+ * `[1, 2, 3]` is an array of small integers instead, and storing one into a
22
+ * shared `out` turns it into a generic array for good.
45
23
  *
46
- * Not transitive, so it is not an equality in the sense a `Set` or `Map` needs,
47
- * and never a basis for ordering — use {@link vec3Equals} there. `tolerance` is
48
- * required: a vector carries no units of its own, so only the caller knows what
49
- * counts as close.
50
- */
51
- export declare function vec3IsClose(a: Vec3, b: Vec3, tolerance: IsCloseToOptions): boolean;
52
- export declare function vec3FromVec2(v: Vec2, z?: number): Vec3;
53
- export declare function vec3Length(v: Vec3, type?: DistanceType): number;
54
- export declare function vec3LengthSq(v: Vec3): number;
55
- export declare function vec3Lerp(a: Vec3, b: Vec3, t: number): Vec3;
56
- export declare function vec3Max(a: Vec3, b: Vec3): Vec3;
57
- export declare function vec3Min(a: Vec3, b: Vec3): Vec3;
58
- export declare function vec3Minmax(vs: readonly Vec3[]): {
59
- min: Vec3;
60
- max: Vec3;
61
- };
62
- export declare function vec3Multiply(a: Vec3, b: Vec3): Vec3;
63
- export declare function vec3MultiplyScalar(v: Vec3, s: number): Vec3;
64
- export declare function vec3Negate(v: Vec3): Vec3;
65
- export declare function vec3Normalize(v: Vec3): Vec3;
66
- /**
67
- * Computes a vector that is perpendicular to the given 3D vector. The result is
68
- * not unique; this function returns one of the possible perpendicular vectors.
24
+ * Rules for callers who bypass the types (JavaScript, casts, `any`): never
25
+ * store anything but a number in a vector, not even briefly; no holes, no
26
+ * `push`, no change of `length`; do not make one with `structuredClone` or
27
+ * `[...float64Array]` (use {@link vec3Clone}, {@link vec3Load},
28
+ * {@link vec3FromArray}); and never pass a `Float64Array` or a hand-made array
29
+ * where a `Vec3` is expected, even once, even in a test.
30
+ */
31
+ export type Vec3 = [x: number, y: number, z: number] & Brand_<"Vec3">;
32
+ /** A {@link Vec3} that is only read. */
33
+ export type ReadonlyVec3 = readonly [x: number, y: number, z: number] & Brand_<"Vec3">;
34
+ /**
35
+ * Writes the cross product `a × b` into `out`, in plain arithmetic: a vector
36
+ * perpendicular to both, of length `|a||b| sin θ`, right-handed (`x × y = z`).
37
+ * Where a component's two terms cancel use {@link vec3CrossPrecise}. `out` may
38
+ * be `a` or `b`.
39
+ */
40
+ export declare function vec3Cross(out: Vec3, a: ReadonlyVec3, b: ReadonlyVec3): Vec3;
41
+ /**
42
+ * {@link vec3Cross} with the rounding of every product recovered
43
+ * (`@ac-kit/math-scalar`'s `diffOfProducts`): each component within 1.5 ULP of
44
+ * the exact value however badly its terms cancel. About five times the cost.
45
+ * `out` may be `a` or `b`.
46
+ */
47
+ export declare function vec3CrossPrecise(out: Vec3, a: ReadonlyVec3, b: ReadonlyVec3): Vec3;
48
+ /**
49
+ * The signed angle from `a` to `b`, positive counter-clockwise when seen from
50
+ * the tip of `axis` (the right-hand rule about `axis`), in `(−π, π]`: `π` for
51
+ * opposite vectors. `axis` need not be a unit vector, and only its side of the
52
+ * plane of `a` and `b` matters. Computed from the compensated cross and dot
53
+ * products, so the angle of nearly parallel vectors keeps its digits. A zero
54
+ * vector gives `0`. Right while the product of the two lengths lies between
55
+ * about `1e−150` and `1e150`, which keeps the squares of the cross product in
56
+ * range (vectors of `1e100` give `Infinity` there and a wrong angle); an angle
57
+ * does not depend on the lengths, so beyond, normalise both vectors with
58
+ * {@link vec3NormalizeScaled} first.
59
+ */
60
+ export declare function vec3AngleTo(a: ReadonlyVec3, b: ReadonlyVec3, axis: ReadonlyVec3): number;
61
+ /**
62
+ * The unsigned angle between two vectors, `atan2(|a × b|, a · b)`, in `[0, π]`,
63
+ * from the compensated cross and dot products. A zero vector gives `0`. Right
64
+ * while the product of the two lengths lies between about `1e−150` and `1e150`,
65
+ * which keeps the squares of the cross product in range (vectors of `1e100`
66
+ * give a wrong angle); an angle does not depend on the lengths, so beyond,
67
+ * normalise both vectors with {@link vec3NormalizeScaled} first.
68
+ */
69
+ export declare function vec3AngleBetween(a: ReadonlyVec3, b: ReadonlyVec3): number;
70
+ /**
71
+ * Writes `[a.x, a.y, z]` into `out`: the plane vector lifted to space.
69
72
  *
70
- * The returned vector is guaranteed to be perpendicular to the input vector,
71
- * but its direction is arbitrary. If the input vector is a zero vector, the
72
- * function will throw an error.
73
- */
74
- export declare function vec3Perpendicular(v: Vec3): Vec3;
75
- export declare function vec3Project(v: Vec3, onto: Vec3): Vec3;
76
- export declare function vec3ProjectOntoPlane(v: Vec3, planeNormal: Vec3): Vec3;
77
- export declare function vec3Random(randFn?: RandomFn | null): Vec3;
78
- export declare function vec3Reflect(v: Vec3, normal: Vec3): Vec3;
79
- export declare function vec3RotateAroundAxis(v: Vec3, axis: Vec3, angle: number): Vec3;
80
- export declare function vec3Round(v: Vec3, options?: RoundOptions): Vec3;
81
- export declare function vec3Sub(a: Vec3, b: Vec3): Vec3;
82
- export declare function vec3SubScalar(v: Vec3, s: number): Vec3;
83
- export declare function vec3SubScaled(a: Vec3, b: Vec3, s: number): Vec3;
84
- /**
85
- * Spherical linear interpolation between two 3D unit vectors. Both `a` and `b`
86
- * should be unit-length for correct results. Falls back to normalized linear
87
- * interpolation when vectors are nearly parallel or anti-parallel.
88
- */
89
- export declare function vec3Slerp(a: Vec3, b: Vec3, t: number): Vec3;
90
- export declare function vec3WeightedMean<T>(items: readonly T[], getWeightedValue: (item: T) => [v: Vec3, w: number]): Vec3;
73
+ * @param z The third component; defaults to `0`.
74
+ */
75
+ export declare function vec3FromVec2(out: Vec3, a: ReadonlyVec2, z?: number): Vec3;
76
+ /**
77
+ * Writes `[x, y, z] / w` into `out`: the Cartesian point of a homogeneous
78
+ * vector, the perspective divide. A `w` of zero (a point at infinity) gives
79
+ * non-finite components, `±Infinity` or `NaN`, not an exception.
80
+ */
81
+ export declare function vec3FromHomogeneous(out: Vec3, a: ReadonlyVec4): Vec3;
82
+ /**
83
+ * Writes `a` rotated by `angle` radians about the unit vector `axis`
84
+ * (Rodrigues' formula), counter-clockwise seen from the tip of `axis`, into
85
+ * `out`. `axis` is not normalised here: a vector that is not unit scales the
86
+ * result. `out` may be `a` or `axis`.
87
+ */
88
+ export declare function vec3RotateAxisAngle(out: Vec3, a: ReadonlyVec3, axis: ReadonlyVec3, angle: number): Vec3;
89
+ /**
90
+ * Writes a unit vector perpendicular to `a` into `out`: `a` crossed with the
91
+ * axis of its smallest component, normalised at any magnitude. The result is
92
+ * not unique; this one is stable, so a continuous input gives it a few jumps
93
+ * only. The zero vector stays zero. `out` may be `a`.
94
+ */
95
+ export declare function vec3Perpendicular(out: Vec3, a: ReadonlyVec3): Vec3;
96
+ /**
97
+ * Writes the tangent and the bitangent that complete the unit vector `normal`
98
+ * to a right-handed orthonormal basis (`tangent × bitangent = normal`), by
99
+ * Duff, Burgess, Christensen, Hery, Kensler, Liani and Villemin's branch-light
100
+ * construction ("Building an Orthonormal Basis, Revisited", 2017): no
101
+ * normalisation and no singularity, whatever the direction of `normal`.
102
+ * `normal` is not normalised here. The outputs may be `normal`.
103
+ */
104
+ export declare function vec3OrthonormalBasis(outTangent: Vec3, outBitangent: Vec3, normal: ReadonlyVec3): void;
105
+ /**
106
+ * Writes `a` minus its component along `normal` into `out`: `a` flattened onto
107
+ * the plane through the origin whose normal is `normal`. `normal` need not be a
108
+ * unit vector; a zero `normal` gives `NaN`. Right when the largest component of
109
+ * `normal` lies between about `1e−150` and `1e150`, where its squared length
110
+ * stays in range: above about `1.3e154` the result is `a` unflattened, and
111
+ * below about `1.5e−154` it is not finite. Beyond, normalise `normal` with
112
+ * {@link vec3NormalizeScaled} first. `out` may be `a` or `normal`.
113
+ */
114
+ export declare function vec3ProjectOntoPlane(out: Vec3, a: ReadonlyVec3, normal: ReadonlyVec3): Vec3;
115
+ /**
116
+ * Writes `m · a` into `out`, the matrix applied to the column vector. `out` may
117
+ * be `a`.
118
+ */
119
+ export declare function vec3TransformMat3x3(out: Vec3, a: ReadonlyVec3, m: ReadonlyMat3x3): Vec3;
120
+ /**
121
+ * {@link vec3TransformMat3x3} with each component a compensated dot product, as
122
+ * accurate as one in doubled precision rounded once. `out` may be `a`.
123
+ */
124
+ export declare function vec3TransformMat3x3Precise(out: Vec3, a: ReadonlyVec3, m: ReadonlyMat3x3): Vec3;
125
+ /**
126
+ * Writes the point `a` (as `[x, y, z, 1]`) transformed by `m` into `out`,
127
+ * divided by the resulting `w`, as gl-matrix and three.js do: for an affine
128
+ * matrix `w` is exactly `1` and nothing changes, for a projection this is the
129
+ * perspective divide. A `w` of zero gives non-finite components, not an
130
+ * exception. `out` may be `a`.
131
+ */
132
+ export declare function vec3TransformMat4x4(out: Vec3, a: ReadonlyVec3, m: ReadonlyMat4x4): Vec3;
133
+ /**
134
+ * Writes the direction `a` transformed by the upper-left 3×3 part of `m`, with
135
+ * no translation and no divide, into `out`. `out` may be `a`.
136
+ */
137
+ export declare function vec3TransformDirectionMat4x4(out: Vec3, a: ReadonlyVec3, m: ReadonlyMat4x4): Vec3;
138
+ /**
139
+ * Writes the point `a` transformed by the affine transform (the linear part
140
+ * applied, then the translation added) into `out`. `out` may be `a`.
141
+ */
142
+ export declare function vec3TransformAffine3(out: Vec3, a: ReadonlyVec3, transform: ReadonlyAffine3): Vec3;
143
+ /**
144
+ * Writes the direction `a` transformed by the linear part of the affine
145
+ * transform, with no translation, into `out`. `out` may be `a`.
146
+ */
147
+ export declare function vec3TransformDirectionAffine3(out: Vec3, a: ReadonlyVec3, transform: ReadonlyAffine3): Vec3;
148
+ /**
149
+ * Writes `a` rotated by the unit quaternion `q` into `out`: `q · a · q⁻¹` in 18
150
+ * multiplications, no matrix. `q` must be unit length; it is not normalised
151
+ * here. `out` may be `a`.
152
+ */
153
+ export declare function vec3TransformQuaternion(out: Vec3, a: ReadonlyVec3, q: ReadonlyQuaternion): Vec3;
154
+ /**
155
+ * Writes the interpolation of `a` and `b` along the great circle into `out`:
156
+ * the direction turns at constant angular speed along the shorter arc, and the
157
+ * length is interpolated linearly. The inputs need not be unit vectors. For `t`
158
+ * in `[0, 1]` and nearly parallel directions (about 1.8° apart or less) the
159
+ * directions are interpolated linearly and normalised, which traces the same
160
+ * arc. The arc lies in the plane of the two vectors, however close to opposite
161
+ * they are (`(1, 0, 0)` to `(−1, 0, 10⁻⁹)` passes through `+z`); for exactly
162
+ * opposite directions, where every great circle is as short, it turns about the
163
+ * axis of {@link vec3Perpendicular} of `a`. The length is interpolated all the
164
+ * same, so `t = 0.5` of opposite vectors has the mean length, never the origin
165
+ * that a straight line between them would give. `t` outside `[0, 1]`
166
+ * extrapolates along the same circle at the same angular speed. A zero vector
167
+ * has no direction: the result is `NaN`. The lengths are `Math.sqrt` of sums of
168
+ * squares, so the result is right for lengths between about `1e−150` and
169
+ * `1e150`; beyond, normalise with {@link vec3NormalizeScaled} first. `out` may
170
+ * be `a` or `b`.
171
+ */
172
+ export declare function vec3Slerp(out: Vec3, a: ReadonlyVec3, b: ReadonlyVec3, t: number): Vec3;
173
+ /**
174
+ * Writes a unit vector in a uniformly random direction (uniform on the sphere:
175
+ * `z` uniform in `[−1, 1]`, the azimuth uniform in `[0, 2π)`) into `out`.
176
+ *
177
+ * @param out The vector to fill.
178
+ * @param random A source of numbers in `[0, 1)`; defaults to `Math.random`.
179
+ */
180
+ export declare function vec3Random(out: Vec3, random?: RandomFn): Vec3;
91
181
  //# sourceMappingURL=vec3.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"vec3.d.ts","sourceRoot":"","sources":["../src/vec3.ts"],"names":[],"mappings":"AAAA,OAAO,EAKN,KAAK,gBAAgB,EACrB,KAAK,QAAQ,EACb,KAAK,YAAY,EACjB,MAAM,cAAc,CAAC;AAItB,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE/C,MAAM,MAAM,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAE5C,eAAO,MAAM,SAAS,WAAoC,CAAC;AAC3D,eAAO,MAAM,QAAQ,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