@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.
- package/CHANGELOG.md +257 -0
- package/README.md +229 -16
- package/dist/_brand.d.ts +14 -0
- package/dist/_brand.d.ts.map +1 -0
- package/dist/_brand.js +2 -0
- package/dist/_brand.js.map +1 -0
- package/dist/_invert.d.ts +19 -0
- package/dist/_invert.d.ts.map +1 -0
- package/dist/_invert.js +48 -0
- package/dist/_invert.js.map +1 -0
- package/dist/_slerp.d.ts +15 -0
- package/dist/_slerp.d.ts.map +1 -1
- package/dist/_slerp.js +47 -0
- package/dist/_slerp.js.map +1 -1
- package/dist/_strided-range.d.ts +23 -0
- package/dist/_strided-range.d.ts.map +1 -0
- package/dist/_strided-range.js +75 -0
- package/dist/_strided-range.js.map +1 -0
- package/dist/_trs.d.ts +38 -0
- package/dist/_trs.d.ts.map +1 -0
- package/dist/_trs.js +132 -0
- package/dist/_trs.js.map +1 -0
- package/dist/affine2-array.d.ts +53 -0
- package/dist/affine2-array.d.ts.map +1 -0
- package/dist/affine2-array.js +107 -0
- package/dist/affine2-array.js.map +1 -0
- package/dist/affine2-componentwise.d.ts +28 -0
- package/dist/affine2-componentwise.d.ts.map +1 -0
- package/dist/affine2-componentwise.js +66 -0
- package/dist/affine2-componentwise.js.map +1 -0
- package/dist/affine2.d.ts +144 -0
- package/dist/affine2.d.ts.map +1 -0
- package/dist/affine2.js +375 -0
- package/dist/affine2.js.map +1 -0
- package/dist/affine3-array.d.ts +53 -0
- package/dist/affine3-array.d.ts.map +1 -0
- package/dist/affine3-array.js +137 -0
- package/dist/affine3-array.js.map +1 -0
- package/dist/affine3-componentwise.d.ts +32 -0
- package/dist/affine3-componentwise.d.ts.map +1 -0
- package/dist/affine3-componentwise.js +100 -0
- package/dist/affine3-componentwise.js.map +1 -0
- package/dist/affine3.d.ts +192 -0
- package/dist/affine3.d.ts.map +1 -0
- package/dist/affine3.js +718 -0
- package/dist/affine3.js.map +1 -0
- package/dist/checked/index.d.ts +35 -0
- package/dist/checked/index.d.ts.map +1 -0
- package/dist/checked/index.js +58 -0
- package/dist/checked/index.js.map +1 -0
- package/dist/euler.d.ts +65 -0
- package/dist/euler.d.ts.map +1 -0
- package/dist/euler.js +217 -0
- package/dist/euler.js.map +1 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -1
- package/dist/kl-activations.d.ts.map +1 -1
- package/dist/kl-activations.js +4 -3
- package/dist/kl-activations.js.map +1 -1
- package/dist/mat2x2-array.d.ts +36 -0
- package/dist/mat2x2-array.d.ts.map +1 -0
- package/dist/mat2x2-array.js +71 -0
- package/dist/mat2x2-array.js.map +1 -0
- package/dist/mat2x2-componentwise.d.ts +86 -0
- package/dist/mat2x2-componentwise.d.ts.map +1 -0
- package/dist/mat2x2-componentwise.js +199 -0
- package/dist/mat2x2-componentwise.js.map +1 -0
- package/dist/mat2x2.d.ts +67 -25
- package/dist/mat2x2.d.ts.map +1 -1
- package/dist/mat2x2.js +150 -94
- package/dist/mat2x2.js.map +1 -1
- package/dist/mat3x3-array.d.ts +36 -0
- package/dist/mat3x3-array.d.ts.map +1 -0
- package/dist/mat3x3-array.js +91 -0
- package/dist/mat3x3-array.js.map +1 -0
- package/dist/mat3x3-componentwise.d.ts +86 -0
- package/dist/mat3x3-componentwise.d.ts.map +1 -0
- package/dist/mat3x3-componentwise.js +299 -0
- package/dist/mat3x3-componentwise.js.map +1 -0
- package/dist/mat3x3.d.ts +131 -48
- package/dist/mat3x3.d.ts.map +1 -1
- package/dist/mat3x3.js +434 -193
- package/dist/mat3x3.js.map +1 -1
- package/dist/mat4x4-array.d.ts +46 -0
- package/dist/mat4x4-array.d.ts.map +1 -0
- package/dist/mat4x4-array.js +133 -0
- package/dist/mat4x4-array.js.map +1 -0
- package/dist/mat4x4-componentwise.d.ts +87 -0
- package/dist/mat4x4-componentwise.d.ts.map +1 -0
- package/dist/mat4x4-componentwise.js +434 -0
- package/dist/mat4x4-componentwise.js.map +1 -0
- package/dist/mat4x4.d.ts +195 -67
- package/dist/mat4x4.d.ts.map +1 -1
- package/dist/mat4x4.js +849 -335
- package/dist/mat4x4.js.map +1 -1
- package/dist/projection.d.ts +98 -0
- package/dist/projection.d.ts.map +1 -0
- package/dist/projection.js +369 -0
- package/dist/projection.js.map +1 -0
- package/dist/quaternion-array.d.ts +47 -0
- package/dist/quaternion-array.d.ts.map +1 -0
- package/dist/quaternion-array.js +86 -0
- package/dist/quaternion-array.js.map +1 -0
- package/dist/quaternion.d.ts +104 -22
- package/dist/quaternion.d.ts.map +1 -1
- package/dist/quaternion.js +294 -181
- package/dist/quaternion.js.map +1 -1
- package/dist/transform.d.ts +220 -0
- package/dist/transform.d.ts.map +1 -0
- package/dist/transform.js +412 -0
- package/dist/transform.js.map +1 -0
- package/dist/tridiagonal.d.ts +52 -0
- package/dist/tridiagonal.d.ts.map +1 -0
- package/dist/tridiagonal.js +90 -0
- package/dist/tridiagonal.js.map +1 -0
- package/dist/upload.d.ts +55 -0
- package/dist/upload.d.ts.map +1 -0
- package/dist/upload.js +129 -0
- package/dist/upload.js.map +1 -0
- package/dist/vec2-array-componentwise.d.ts +189 -0
- package/dist/vec2-array-componentwise.d.ts.map +1 -0
- package/dist/vec2-array-componentwise.js +424 -0
- package/dist/vec2-array-componentwise.js.map +1 -0
- package/dist/vec2-array.d.ts +53 -0
- package/dist/vec2-array.d.ts.map +1 -0
- package/dist/vec2-array.js +123 -0
- package/dist/vec2-array.js.map +1 -0
- package/dist/vec2-componentwise.d.ts +311 -0
- package/dist/vec2-componentwise.d.ts.map +1 -0
- package/dist/vec2-componentwise.js +542 -0
- package/dist/vec2-componentwise.js.map +1 -0
- package/dist/vec2.d.ts +97 -82
- package/dist/vec2.d.ts.map +1 -1
- package/dist/vec2.js +121 -216
- package/dist/vec2.js.map +1 -1
- package/dist/vec3-array-componentwise.d.ts +189 -0
- package/dist/vec3-array-componentwise.d.ts.map +1 -0
- package/dist/vec3-array-componentwise.js +458 -0
- package/dist/vec3-array-componentwise.js.map +1 -0
- package/dist/vec3-array.d.ts +102 -0
- package/dist/vec3-array.d.ts.map +1 -0
- package/dist/vec3-array.js +299 -0
- package/dist/vec3-array.js.map +1 -0
- package/dist/vec3-componentwise.d.ts +310 -0
- package/dist/vec3-componentwise.d.ts.map +1 -0
- package/dist/vec3-componentwise.js +594 -0
- package/dist/vec3-componentwise.js.map +1 -0
- package/dist/vec3.d.ts +177 -87
- package/dist/vec3.d.ts.map +1 -1
- package/dist/vec3.js +366 -273
- package/dist/vec3.js.map +1 -1
- package/dist/vec4-array-componentwise.d.ts +155 -0
- package/dist/vec4-array-componentwise.d.ts.map +1 -0
- package/dist/vec4-array-componentwise.js +401 -0
- package/dist/vec4-array-componentwise.js.map +1 -0
- package/dist/vec4-array.d.ts +12 -0
- package/dist/vec4-array.d.ts.map +1 -0
- package/dist/vec4-array.js +43 -0
- package/dist/vec4-array.js.map +1 -0
- package/dist/vec4-componentwise.d.ts +299 -0
- package/dist/vec4-componentwise.d.ts.map +1 -0
- package/dist/vec4-componentwise.js +637 -0
- package/dist/vec4-componentwise.js.map +1 -0
- package/dist/vec4.d.ts +57 -53
- package/dist/vec4.d.ts.map +1 -1
- package/dist/vec4.js +94 -246
- package/dist/vec4.js.map +1 -1
- package/dist/view-basis.d.ts +15 -0
- package/dist/view-basis.d.ts.map +1 -0
- package/dist/view-basis.js +29 -0
- package/dist/view-basis.js.map +1 -0
- package/dist/viewport.d.ts +114 -0
- package/dist/viewport.d.ts.map +1 -0
- package/dist/viewport.js +250 -0
- package/dist/viewport.js.map +1 -0
- package/package.json +18 -9
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
import { assertStridedAlias_, assertStridedRange_ } from "./_strided-range.js";
|
|
2
|
+
function assertSameLength_(name, out, input) {
|
|
3
|
+
const length = input.length;
|
|
4
|
+
if (out.length !== length || length % 3 !== 0) {
|
|
5
|
+
throw new RangeError(`${name}: out and input must have the same length, a multiple of 3.`);
|
|
6
|
+
}
|
|
7
|
+
return length;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* The index of the element of `points` nearest to `point` among those within
|
|
11
|
+
* `maxDistance`, or `−1` when there is none (an empty buffer, every point
|
|
12
|
+
* farther, a `NaN` distance). A tie goes to the lower index. Distances are
|
|
13
|
+
* compared squared, in plain arithmetic, so the result is right where the
|
|
14
|
+
* coordinate differences lie between about `1e−150` and `1e150`: beyond, the
|
|
15
|
+
* squares overflow (a point at `[1e200, 0, 0]` is never found, whatever
|
|
16
|
+
* `maxDistance`) or lose their digits. One pass, no allocation. O(n).
|
|
17
|
+
*
|
|
18
|
+
* @param points A buffer of `Vec3` elements.
|
|
19
|
+
* @param maxDistance The largest distance that counts, `Infinity` by default.
|
|
20
|
+
* @returns The element index (not the offset into `points`).
|
|
21
|
+
* @throws {RangeError} Unless `points.length` is a multiple of 3.
|
|
22
|
+
*/
|
|
23
|
+
export function vec3ArrayFindNearest(points, point, maxDistance = Infinity) {
|
|
24
|
+
const length = points.length;
|
|
25
|
+
if (length % 3 !== 0) {
|
|
26
|
+
throw new RangeError("vec3ArrayFindNearest: points must be a multiple of 3 long.");
|
|
27
|
+
}
|
|
28
|
+
const x = point[0];
|
|
29
|
+
const y = point[1];
|
|
30
|
+
const z = point[2];
|
|
31
|
+
const limit = maxDistance < 0 ? -1 : maxDistance * maxDistance;
|
|
32
|
+
let nearest = -1;
|
|
33
|
+
let nearestSquared = Infinity;
|
|
34
|
+
for (let index = 0, element = 0; index < length; index += 3, element++) {
|
|
35
|
+
const dx = points[index] - x;
|
|
36
|
+
const dy = points[index + 1] - y;
|
|
37
|
+
const dz = points[index + 2] - z;
|
|
38
|
+
const squared = dx * dx + dy * dy + dz * dz;
|
|
39
|
+
if (squared <= limit && squared < nearestSquared) {
|
|
40
|
+
nearest = element;
|
|
41
|
+
nearestSquared = squared;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return nearest;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Writes `m · v` for every element `v` of `input` into `out`, as
|
|
48
|
+
* {@link vec3TransformMat3x3} does for one. `out` may be `input`, but not a
|
|
49
|
+
* partially overlapping view. O(n).
|
|
50
|
+
*
|
|
51
|
+
* @returns `out`.
|
|
52
|
+
* @throws {RangeError} Unless `out` and `input` have the same length, a
|
|
53
|
+
* multiple of 3.
|
|
54
|
+
*/
|
|
55
|
+
export function vec3ArrayTransformMat3x3(out, input, m) {
|
|
56
|
+
const length = assertSameLength_("vec3ArrayTransformMat3x3", out, input);
|
|
57
|
+
const m00 = m[0];
|
|
58
|
+
const m10 = m[1];
|
|
59
|
+
const m20 = m[2];
|
|
60
|
+
const m01 = m[3];
|
|
61
|
+
const m11 = m[4];
|
|
62
|
+
const m21 = m[5];
|
|
63
|
+
const m02 = m[6];
|
|
64
|
+
const m12 = m[7];
|
|
65
|
+
const m22 = m[8];
|
|
66
|
+
for (let index = 0; index < length; index += 3) {
|
|
67
|
+
const x = input[index];
|
|
68
|
+
const y = input[index + 1];
|
|
69
|
+
const z = input[index + 2];
|
|
70
|
+
out[index] = m00 * x + m01 * y + m02 * z;
|
|
71
|
+
out[index + 1] = m10 * x + m11 * y + m12 * z;
|
|
72
|
+
out[index + 2] = m20 * x + m21 * y + m22 * z;
|
|
73
|
+
}
|
|
74
|
+
return out;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Transforms every element of `input` by the normal matrix `normalMatrix` (the
|
|
78
|
+
* inverse transpose of a model matrix's linear part), then scales it to unit
|
|
79
|
+
* length, in one pass: a zero result stays zero, a `NaN` gives `NaN` throughout
|
|
80
|
+
* that element. The squared length is plain arithmetic, so the result is right
|
|
81
|
+
* where the transformed components lie between about `1e−150` and `1e150`:
|
|
82
|
+
* beyond, the square overflows or underflows and the element comes back as
|
|
83
|
+
* zeros (`[1e200, 0, 0]` under the identity), as {@link vec3Normalize} does.
|
|
84
|
+
* `out` may be `input`, but not a partially overlapping view. O(n).
|
|
85
|
+
*
|
|
86
|
+
* @returns `out`.
|
|
87
|
+
* @throws {RangeError} Unless `out` and `input` have the same length, a
|
|
88
|
+
* multiple of 3.
|
|
89
|
+
*/
|
|
90
|
+
export function vec3ArrayTransformNormal(out, input, normalMatrix) {
|
|
91
|
+
const length = assertSameLength_("vec3ArrayTransformNormal", out, input);
|
|
92
|
+
const m00 = normalMatrix[0];
|
|
93
|
+
const m10 = normalMatrix[1];
|
|
94
|
+
const m20 = normalMatrix[2];
|
|
95
|
+
const m01 = normalMatrix[3];
|
|
96
|
+
const m11 = normalMatrix[4];
|
|
97
|
+
const m21 = normalMatrix[5];
|
|
98
|
+
const m02 = normalMatrix[6];
|
|
99
|
+
const m12 = normalMatrix[7];
|
|
100
|
+
const m22 = normalMatrix[8];
|
|
101
|
+
for (let index = 0; index < length; index += 3) {
|
|
102
|
+
const x = input[index];
|
|
103
|
+
const y = input[index + 1];
|
|
104
|
+
const z = input[index + 2];
|
|
105
|
+
const tx = m00 * x + m01 * y + m02 * z;
|
|
106
|
+
const ty = m10 * x + m11 * y + m12 * z;
|
|
107
|
+
const tz = m20 * x + m21 * y + m22 * z;
|
|
108
|
+
const lengthSquared = tx * tx + ty * ty + tz * tz;
|
|
109
|
+
const scale = lengthSquared === 0 ? 0 : 1 / Math.sqrt(lengthSquared);
|
|
110
|
+
out[index] = tx * scale;
|
|
111
|
+
out[index + 1] = ty * scale;
|
|
112
|
+
out[index + 2] = tz * scale;
|
|
113
|
+
}
|
|
114
|
+
return out;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Writes every point of `input` transformed by the affine transform (the linear
|
|
118
|
+
* part, then the translation) into `out`, as {@link vec3TransformAffine3} does
|
|
119
|
+
* for one. `out` may be `input`, but not a partially overlapping view. O(n).
|
|
120
|
+
*
|
|
121
|
+
* @returns `out`.
|
|
122
|
+
* @throws {RangeError} Unless `out` and `input` have the same length, a
|
|
123
|
+
* multiple of 3.
|
|
124
|
+
*/
|
|
125
|
+
export function vec3ArrayTransformAffine3(out, input, transform) {
|
|
126
|
+
const length = assertSameLength_("vec3ArrayTransformAffine3", out, input);
|
|
127
|
+
const m00 = transform[0];
|
|
128
|
+
const m10 = transform[1];
|
|
129
|
+
const m20 = transform[2];
|
|
130
|
+
const m01 = transform[3];
|
|
131
|
+
const m11 = transform[4];
|
|
132
|
+
const m21 = transform[5];
|
|
133
|
+
const m02 = transform[6];
|
|
134
|
+
const m12 = transform[7];
|
|
135
|
+
const m22 = transform[8];
|
|
136
|
+
const m03 = transform[9];
|
|
137
|
+
const m13 = transform[10];
|
|
138
|
+
const m23 = transform[11];
|
|
139
|
+
for (let index = 0; index < length; index += 3) {
|
|
140
|
+
const x = input[index];
|
|
141
|
+
const y = input[index + 1];
|
|
142
|
+
const z = input[index + 2];
|
|
143
|
+
out[index] = m00 * x + m01 * y + m02 * z + m03;
|
|
144
|
+
out[index + 1] = m10 * x + m11 * y + m12 * z + m13;
|
|
145
|
+
out[index + 2] = m20 * x + m21 * y + m22 * z + m23;
|
|
146
|
+
}
|
|
147
|
+
return out;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Writes every direction of `input` transformed by the linear part of the
|
|
151
|
+
* affine transform, with no translation, into `out`, as
|
|
152
|
+
* {@link vec3TransformDirectionAffine3} does for one. `out` may be `input`, but
|
|
153
|
+
* not a partially overlapping view. O(n).
|
|
154
|
+
*
|
|
155
|
+
* @returns `out`.
|
|
156
|
+
* @throws {RangeError} Unless `out` and `input` have the same length, a
|
|
157
|
+
* multiple of 3.
|
|
158
|
+
*/
|
|
159
|
+
export function vec3ArrayTransformDirectionAffine3(out, input, transform) {
|
|
160
|
+
const length = assertSameLength_("vec3ArrayTransformDirectionAffine3", out, input);
|
|
161
|
+
const m00 = transform[0];
|
|
162
|
+
const m10 = transform[1];
|
|
163
|
+
const m20 = transform[2];
|
|
164
|
+
const m01 = transform[3];
|
|
165
|
+
const m11 = transform[4];
|
|
166
|
+
const m21 = transform[5];
|
|
167
|
+
const m02 = transform[6];
|
|
168
|
+
const m12 = transform[7];
|
|
169
|
+
const m22 = transform[8];
|
|
170
|
+
for (let index = 0; index < length; index += 3) {
|
|
171
|
+
const x = input[index];
|
|
172
|
+
const y = input[index + 1];
|
|
173
|
+
const z = input[index + 2];
|
|
174
|
+
out[index] = m00 * x + m01 * y + m02 * z;
|
|
175
|
+
out[index + 1] = m10 * x + m11 * y + m12 * z;
|
|
176
|
+
out[index + 2] = m20 * x + m21 * y + m22 * z;
|
|
177
|
+
}
|
|
178
|
+
return out;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Writes every point of `input` (as `[x, y, z, 1]`) transformed by `m` and
|
|
182
|
+
* divided by the resulting `w` into `out`, as {@link vec3TransformMat4x4} does
|
|
183
|
+
* for one: for an affine matrix `w` is exactly `1`, for a projection this is
|
|
184
|
+
* the perspective divide. A `w` of zero gives non-finite components. `out` may
|
|
185
|
+
* be `input`, but not a partially overlapping view. O(n).
|
|
186
|
+
*
|
|
187
|
+
* @returns `out`.
|
|
188
|
+
* @throws {RangeError} Unless `out` and `input` have the same length, a
|
|
189
|
+
* multiple of 3.
|
|
190
|
+
*/
|
|
191
|
+
export function vec3ArrayTransformMat4x4(out, input, m) {
|
|
192
|
+
const length = assertSameLength_("vec3ArrayTransformMat4x4", out, input);
|
|
193
|
+
const m00 = m[0];
|
|
194
|
+
const m10 = m[1];
|
|
195
|
+
const m20 = m[2];
|
|
196
|
+
const m30 = m[3];
|
|
197
|
+
const m01 = m[4];
|
|
198
|
+
const m11 = m[5];
|
|
199
|
+
const m21 = m[6];
|
|
200
|
+
const m31 = m[7];
|
|
201
|
+
const m02 = m[8];
|
|
202
|
+
const m12 = m[9];
|
|
203
|
+
const m22 = m[10];
|
|
204
|
+
const m32 = m[11];
|
|
205
|
+
const m03 = m[12];
|
|
206
|
+
const m13 = m[13];
|
|
207
|
+
const m23 = m[14];
|
|
208
|
+
const m33 = m[15];
|
|
209
|
+
for (let index = 0; index < length; index += 3) {
|
|
210
|
+
const x = input[index];
|
|
211
|
+
const y = input[index + 1];
|
|
212
|
+
const z = input[index + 2];
|
|
213
|
+
const w = m30 * x + m31 * y + m32 * z + m33;
|
|
214
|
+
out[index] = (m00 * x + m01 * y + m02 * z + m03) / w;
|
|
215
|
+
out[index + 1] = (m10 * x + m11 * y + m12 * z + m13) / w;
|
|
216
|
+
out[index + 2] = (m20 * x + m21 * y + m22 * z + m23) / w;
|
|
217
|
+
}
|
|
218
|
+
return out;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* {@link vec3ArrayTransformAffine3} over interleaved data: point `i` is read at
|
|
222
|
+
* `input[inputOffset + i·inputStride …]` and written at `out[outOffset +
|
|
223
|
+
* i·outStride …]`, offsets and strides counted in numbers, for `count` points.
|
|
224
|
+
* `out` may be `input` only as the same elements (one array, offset and stride,
|
|
225
|
+
* so each is read before it is written) or as elements that share no memory:
|
|
226
|
+
* any other overlap is refused. O(n).
|
|
227
|
+
*
|
|
228
|
+
* @returns `out`.
|
|
229
|
+
* @throws {RangeError} Unless `count`, the offsets and the strides are
|
|
230
|
+
* non-negative integers, the strides are at least 3 from two points on, the
|
|
231
|
+
* points fit in both arrays, and `out` and `input` overlap in no other way.
|
|
232
|
+
*/
|
|
233
|
+
export function vec3ArrayTransformAffine3Strided(out, outOffset, outStride, input, inputOffset, inputStride, count, transform) {
|
|
234
|
+
assertStridedRange_("vec3ArrayTransformAffine3Strided", "out", out.length, outOffset, outStride, count, 3);
|
|
235
|
+
assertStridedRange_("vec3ArrayTransformAffine3Strided", "input", input.length, inputOffset, inputStride, count, 3);
|
|
236
|
+
assertStridedAlias_("vec3ArrayTransformAffine3Strided", out, outOffset, outStride, input, inputOffset, inputStride, count, 3);
|
|
237
|
+
const m00 = transform[0];
|
|
238
|
+
const m10 = transform[1];
|
|
239
|
+
const m20 = transform[2];
|
|
240
|
+
const m01 = transform[3];
|
|
241
|
+
const m11 = transform[4];
|
|
242
|
+
const m21 = transform[5];
|
|
243
|
+
const m02 = transform[6];
|
|
244
|
+
const m12 = transform[7];
|
|
245
|
+
const m22 = transform[8];
|
|
246
|
+
const m03 = transform[9];
|
|
247
|
+
const m13 = transform[10];
|
|
248
|
+
const m23 = transform[11];
|
|
249
|
+
for (let element = 0, source = inputOffset, target = outOffset; element < count; element++, source += inputStride, target += outStride) {
|
|
250
|
+
const x = input[source];
|
|
251
|
+
const y = input[source + 1];
|
|
252
|
+
const z = input[source + 2];
|
|
253
|
+
out[target] = m00 * x + m01 * y + m02 * z + m03;
|
|
254
|
+
out[target + 1] = m10 * x + m11 * y + m12 * z + m13;
|
|
255
|
+
out[target + 2] = m20 * x + m21 * y + m22 * z + m23;
|
|
256
|
+
}
|
|
257
|
+
return out;
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* {@link vec3ArrayTransformMat4x4} over interleaved data, with the offsets,
|
|
261
|
+
* strides, count and aliasing rule of {@link vec3ArrayTransformAffine3Strided}
|
|
262
|
+
* (the same elements, or none shared). O(n).
|
|
263
|
+
*
|
|
264
|
+
* @returns `out`.
|
|
265
|
+
* @throws {RangeError} On the conditions of
|
|
266
|
+
* {@link vec3ArrayTransformAffine3Strided}.
|
|
267
|
+
*/
|
|
268
|
+
export function vec3ArrayTransformMat4x4Strided(out, outOffset, outStride, input, inputOffset, inputStride, count, m) {
|
|
269
|
+
assertStridedRange_("vec3ArrayTransformMat4x4Strided", "out", out.length, outOffset, outStride, count, 3);
|
|
270
|
+
assertStridedRange_("vec3ArrayTransformMat4x4Strided", "input", input.length, inputOffset, inputStride, count, 3);
|
|
271
|
+
assertStridedAlias_("vec3ArrayTransformMat4x4Strided", out, outOffset, outStride, input, inputOffset, inputStride, count, 3);
|
|
272
|
+
const m00 = m[0];
|
|
273
|
+
const m10 = m[1];
|
|
274
|
+
const m20 = m[2];
|
|
275
|
+
const m30 = m[3];
|
|
276
|
+
const m01 = m[4];
|
|
277
|
+
const m11 = m[5];
|
|
278
|
+
const m21 = m[6];
|
|
279
|
+
const m31 = m[7];
|
|
280
|
+
const m02 = m[8];
|
|
281
|
+
const m12 = m[9];
|
|
282
|
+
const m22 = m[10];
|
|
283
|
+
const m32 = m[11];
|
|
284
|
+
const m03 = m[12];
|
|
285
|
+
const m13 = m[13];
|
|
286
|
+
const m23 = m[14];
|
|
287
|
+
const m33 = m[15];
|
|
288
|
+
for (let element = 0, source = inputOffset, target = outOffset; element < count; element++, source += inputStride, target += outStride) {
|
|
289
|
+
const x = input[source];
|
|
290
|
+
const y = input[source + 1];
|
|
291
|
+
const z = input[source + 2];
|
|
292
|
+
const w = m30 * x + m31 * y + m32 * z + m33;
|
|
293
|
+
out[target] = (m00 * x + m01 * y + m02 * z + m03) / w;
|
|
294
|
+
out[target + 1] = (m10 * x + m11 * y + m12 * z + m13) / w;
|
|
295
|
+
out[target + 2] = (m20 * x + m21 * y + m22 * z + m23) / w;
|
|
296
|
+
}
|
|
297
|
+
return out;
|
|
298
|
+
}
|
|
299
|
+
//# sourceMappingURL=vec3-array.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vec3-array.js","sourceRoot":"","sources":["../src/vec3-array.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAM/E,SAAS,iBAAiB,CACzB,IAAY,EACZ,GAAiB,EACjB,KAAmB;IAEnB,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;IAC5B,IAAI,GAAG,CAAC,MAAM,KAAK,MAAM,IAAI,MAAM,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;QAC/C,MAAM,IAAI,UAAU,CACnB,GAAG,IAAI,6DAA6D,CACpE,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AACf,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,oBAAoB,CACnC,MAAoB,EACpB,KAAm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
+
/**
|
|
4
|
+
* Creates the zero vector `[0, 0, 0]`.
|
|
5
|
+
*
|
|
6
|
+
* Allocates; keep it out of hot loops.
|
|
7
|
+
*/
|
|
8
|
+
export declare function vec3Create(): Vec3;
|
|
9
|
+
/**
|
|
10
|
+
* Creates the vector `[x, y, z]`. Like every creator it starts from an array of
|
|
11
|
+
* doubles, so a vector made of whole numbers is still `PACKED_DOUBLE_ELEMENTS`
|
|
12
|
+
* in V8, where an array literal such as `[1, 2, 3]` is an array of small
|
|
13
|
+
* integers that a shared `out` would turn into a generic array for good.
|
|
14
|
+
*
|
|
15
|
+
* Allocates; keep it out of hot loops.
|
|
16
|
+
*/
|
|
17
|
+
export declare function vec3Of(x: number, y: number, z: number): Vec3;
|
|
18
|
+
/**
|
|
19
|
+
* Creates a copy of `a`. Like every creator it starts from a clean array, so a
|
|
20
|
+
* clone of an array of small integers is an array of doubles.
|
|
21
|
+
*
|
|
22
|
+
* Allocates; keep it out of hot loops.
|
|
23
|
+
*/
|
|
24
|
+
export declare function vec3Clone(a: ReadonlyVec3): Vec3;
|
|
25
|
+
/**
|
|
26
|
+
* The checked way in from untyped data (JSON, messages, arrays of unknown
|
|
27
|
+
* origin): `source[offset … offset + 3)` copied into `out`, each element that
|
|
28
|
+
* is not a number written as `NaN`, an index below zero or at or past
|
|
29
|
+
* `source.length` too, so `out` never holds a non-number. Test the result with
|
|
30
|
+
* {@link vec3IsFinite} when `NaN` must not get through. A cold path: a
|
|
31
|
+
* `Float64Array` of vectors is read with {@link vec3Load}. O(1).
|
|
32
|
+
*
|
|
33
|
+
* `source` may be `out` itself: the 3 elements are read before the first write.
|
|
34
|
+
*
|
|
35
|
+
* @param out The vector to fill.
|
|
36
|
+
* @param source The array to read, of any length and any content.
|
|
37
|
+
* @param offset The index of the first component in `source`.
|
|
38
|
+
* @returns `out`.
|
|
39
|
+
*/
|
|
40
|
+
export declare function vec3FromArray(out: Vec3, source: ArrayLike<number>, offset?: number): Vec3;
|
|
41
|
+
/** Writes the vector `[x, y, z]` into `out`. */
|
|
42
|
+
export declare function vec3Set(out: Vec3, x: number, y: number, z: number): Vec3;
|
|
43
|
+
/** Writes a copy of `a` into `out`. */
|
|
44
|
+
export declare function vec3Copy(out: Vec3, a: ReadonlyVec3): Vec3;
|
|
45
|
+
/** Writes the zero vector `[0, 0, 0]` into `out`. */
|
|
46
|
+
export declare function vec3Zero(out: Vec3): Vec3;
|
|
47
|
+
/** Writes `a + b` into `out`. `out` may be `a` or `b`. */
|
|
48
|
+
export declare function vec3Add(out: Vec3, a: ReadonlyVec3, b: ReadonlyVec3): Vec3;
|
|
49
|
+
/** Writes `a − b` into `out`. `out` may be `a` or `b`. */
|
|
50
|
+
export declare function vec3Subtract(out: Vec3, a: ReadonlyVec3, b: ReadonlyVec3): Vec3;
|
|
51
|
+
/**
|
|
52
|
+
* Writes the component-wise product of `a` and `b` into `out`: not the dot
|
|
53
|
+
* product, and not a cross product. `out` may be `a` or `b`.
|
|
54
|
+
*/
|
|
55
|
+
export declare function vec3Multiply(out: Vec3, a: ReadonlyVec3, b: ReadonlyVec3): Vec3;
|
|
56
|
+
/**
|
|
57
|
+
* Writes the component-wise quotient `a / b` into `out`. A zero component of
|
|
58
|
+
* `b` gives `±Infinity`, or `NaN` for `0 / 0`; nothing throws. `out` may be `a`
|
|
59
|
+
* or `b`.
|
|
60
|
+
*/
|
|
61
|
+
export declare function vec3Divide(out: Vec3, a: ReadonlyVec3, b: ReadonlyVec3): Vec3;
|
|
62
|
+
/**
|
|
63
|
+
* Writes `a` with `scalar` added to every component into `out`. `out` may be
|
|
64
|
+
* `a`.
|
|
65
|
+
*/
|
|
66
|
+
export declare function vec3AddScalar(out: Vec3, a: ReadonlyVec3, scalar: number): Vec3;
|
|
67
|
+
/** Writes `a · scalar` into `out`. `out` may be `a`. */
|
|
68
|
+
export declare function vec3MultiplyScalar(out: Vec3, a: ReadonlyVec3, scalar: number): Vec3;
|
|
69
|
+
/**
|
|
70
|
+
* Writes `a / scalar` into `out`. A zero `scalar` gives `±Infinity` or `NaN`
|
|
71
|
+
* components, not an exception. `out` may be `a`.
|
|
72
|
+
*/
|
|
73
|
+
export declare function vec3DivideScalar(out: Vec3, a: ReadonlyVec3, scalar: number): Vec3;
|
|
74
|
+
/**
|
|
75
|
+
* Writes `a + b · scale` into `out`: two roundings per component, not a fused
|
|
76
|
+
* multiply-add. `out` may be `a` or `b`.
|
|
77
|
+
*/
|
|
78
|
+
export declare function vec3AddScaled(out: Vec3, a: ReadonlyVec3, b: ReadonlyVec3, scale: number): Vec3;
|
|
79
|
+
/** Writes `−a` into `out`. `out` may be `a`. */
|
|
80
|
+
export declare function vec3Negate(out: Vec3, a: ReadonlyVec3): Vec3;
|
|
81
|
+
/**
|
|
82
|
+
* Writes the absolute value of every component of `a` into `out`. `out` may be
|
|
83
|
+
* `a`.
|
|
84
|
+
*/
|
|
85
|
+
export declare function vec3Abs(out: Vec3, a: ReadonlyVec3): Vec3;
|
|
86
|
+
/**
|
|
87
|
+
* Writes `a` with every component rounded by `@ac-kit/core`'s `round` into
|
|
88
|
+
* `out`: `options` choose the method (round, floor, ceil, trunc) and the digits
|
|
89
|
+
* kept, and none rounds to whole numbers. `out` may be `a`.
|
|
90
|
+
*/
|
|
91
|
+
export declare function vec3Round(out: Vec3, a: ReadonlyVec3, options?: RoundOptions): Vec3;
|
|
92
|
+
/**
|
|
93
|
+
* Writes the component-wise minimum of `a` and `b` into `out`, as `Math.min`
|
|
94
|
+
* takes it: a `NaN` gives `NaN`, and `−0` is below `+0`. `out` may be `a` or
|
|
95
|
+
* `b`.
|
|
96
|
+
*/
|
|
97
|
+
export declare function vec3Min(out: Vec3, a: ReadonlyVec3, b: ReadonlyVec3): Vec3;
|
|
98
|
+
/**
|
|
99
|
+
* Writes the component-wise maximum of `a` and `b` into `out`, as `Math.max`
|
|
100
|
+
* takes it: a `NaN` gives `NaN`, and `+0` is above `−0`. `out` may be `a` or
|
|
101
|
+
* `b`.
|
|
102
|
+
*/
|
|
103
|
+
export declare function vec3Max(out: Vec3, a: ReadonlyVec3, b: ReadonlyVec3): Vec3;
|
|
104
|
+
/**
|
|
105
|
+
* Writes `a` limited component-wise to `[min, max]` into `out`. Where a `min`
|
|
106
|
+
* component is above its `max`, the `max` wins, and a `NaN` gives `NaN`:
|
|
107
|
+
* nothing throws, unlike `@ac-kit/core`'s `clamp`. `out` may be any of the
|
|
108
|
+
* arguments.
|
|
109
|
+
*/
|
|
110
|
+
export declare function vec3Clamp(out: Vec3, a: ReadonlyVec3, min: ReadonlyVec3, max: ReadonlyVec3): Vec3;
|
|
111
|
+
/**
|
|
112
|
+
* Writes `a` with every component limited to `[min, max]` into `out`. Where
|
|
113
|
+
* `min` is above `max` the `max` wins, and a `NaN` gives `NaN`: nothing throws,
|
|
114
|
+
* unlike `@ac-kit/core`'s `clamp`. `out` may be `a`.
|
|
115
|
+
*/
|
|
116
|
+
export declare function vec3ClampScalar(out: Vec3, a: ReadonlyVec3, min: number, max: number): Vec3;
|
|
117
|
+
/**
|
|
118
|
+
* Writes `a + (b − a)·t` into `out`, each component by `@ac-kit/math-scalar`'s
|
|
119
|
+
* `lerp`: exactly `a` at `t = 0`, and `b` at `t = 1` up to rounding when `a`
|
|
120
|
+
* and `b` differ greatly in magnitude. A `t` outside `[0, 1]` extrapolates.
|
|
121
|
+
* `out` may be `a` or `b`.
|
|
122
|
+
*/
|
|
123
|
+
export declare function vec3Lerp(out: Vec3, a: ReadonlyVec3, b: ReadonlyVec3, t: number): Vec3;
|
|
124
|
+
/**
|
|
125
|
+
* Exact component-wise equality: `−0` equals `+0`, and `NaN` equals nothing,
|
|
126
|
+
* itself included. See {@link vec3IsClose} for a tolerant test.
|
|
127
|
+
* {@link vec3CompareLexicographic} returns `0` for exactly the pairs this calls
|
|
128
|
+
* equal (leaving `NaN` aside).
|
|
129
|
+
*/
|
|
130
|
+
export declare function vec3Equals(a: ReadonlyVec3, b: ReadonlyVec3): boolean;
|
|
131
|
+
/**
|
|
132
|
+
* Component-wise approximate equality, each pair compared by `@ac-kit/core`'s
|
|
133
|
+
* `isCloseTo` with `options`: none means exact.
|
|
134
|
+
*
|
|
135
|
+
* Not transitive, so it is not an equality in the sense a `Set` or `Map` needs,
|
|
136
|
+
* and never a basis for ordering — use {@link vec3Equals} there. The tolerance
|
|
137
|
+
* is required: a vector carries no units of its own, so only the caller knows
|
|
138
|
+
* what counts as close.
|
|
139
|
+
*/
|
|
140
|
+
export declare function vec3IsClose(a: ReadonlyVec3, b: ReadonlyVec3, options: IsCloseToOptions): boolean;
|
|
141
|
+
/**
|
|
142
|
+
* Whether every component is a finite number: the check to run after parsing
|
|
143
|
+
* untrusted data or before an upload, as operations never check. A component
|
|
144
|
+
* that is not a number at all (a vector built by a caller who bypassed the
|
|
145
|
+
* types) counts as not finite.
|
|
146
|
+
*/
|
|
147
|
+
export declare function vec3IsFinite(a: ReadonlyVec3): boolean;
|
|
148
|
+
/**
|
|
149
|
+
* Writes element `index` of `array`, the numbers at `[index·3, index·3 + 3)`,
|
|
150
|
+
* into `out`. Each component is written as `+array[i]`, so an index past the
|
|
151
|
+
* end of `array` gives `NaN`, never `undefined`: the vector stays clean
|
|
152
|
+
* whatever the caller does. Checking the index is the job of the checked
|
|
153
|
+
* layer.
|
|
154
|
+
*
|
|
155
|
+
* The vector is copied: it is never a view of `array`. O(1).
|
|
156
|
+
*/
|
|
157
|
+
export declare function vec3Load(out: Vec3, array: Float64Array, index: number): Vec3;
|
|
158
|
+
/**
|
|
159
|
+
* Writes `value` into `array` as element `index`, at `[index·3, index·3 + 3)`.
|
|
160
|
+
* An element past the end of `array` writes nothing, as a typed array drops an
|
|
161
|
+
* out-of-range write. O(1).
|
|
162
|
+
*/
|
|
163
|
+
export declare function vec3Store(array: Float64Array, index: number, value: ReadonlyVec3): void;
|
|
164
|
+
/**
|
|
165
|
+
* Like {@link vec3Load} for interleaved data: element `index` starts at `offset +
|
|
166
|
+
* index·stride`, both counted in numbers, and its 3 components follow one
|
|
167
|
+
* another. An index past the end gives `NaN` components. O(1).
|
|
168
|
+
*/
|
|
169
|
+
export declare function vec3LoadStrided(out: Vec3, array: Float64Array, offset: number, stride: number, index: number): Vec3;
|
|
170
|
+
/**
|
|
171
|
+
* Like {@link vec3Store} for interleaved data: element `index` starts at `offset +
|
|
172
|
+
* index·stride`, both counted in numbers. A component past the end of `array`
|
|
173
|
+
* writes nothing. O(1).
|
|
174
|
+
*/
|
|
175
|
+
export declare function vec3StoreStrided(array: Float64Array, offset: number, stride: number, index: number, value: ReadonlyVec3): void;
|
|
176
|
+
/**
|
|
177
|
+
* Narrows `value` to binary32 and writes its 3 components into `array` from
|
|
178
|
+
* element `offset` on, unrolled: the way to stage a vertex, instance or uniform
|
|
179
|
+
* value for the GPU, where `array.set` costs several times as much for one
|
|
180
|
+
* value. A component past the end of `array` writes nothing. O(1).
|
|
181
|
+
*/
|
|
182
|
+
export declare function vec3StoreFloat32(array: Float32Array, offset: number, value: ReadonlyVec3): void;
|
|
183
|
+
/**
|
|
184
|
+
* Whether every number of `array` is finite: the check for a buffer of vec3
|
|
185
|
+
* elements read from untrusted data or about to be uploaded. The length is not
|
|
186
|
+
* required to be a multiple of 3 (see `assertFiniteBuffer` for that). O(n).
|
|
187
|
+
*/
|
|
188
|
+
export declare function vec3ArrayIsFinite(array: Float64Array): boolean;
|
|
189
|
+
/**
|
|
190
|
+
* The inner product `Σ aᵢ·bᵢ`, in plain arithmetic: where the terms cancel its
|
|
191
|
+
* error can exceed the result, and {@link vec3DotPrecise} is the form to use
|
|
192
|
+
* there.
|
|
193
|
+
*/
|
|
194
|
+
export declare function vec3Dot(a: ReadonlyVec3, b: ReadonlyVec3): number;
|
|
195
|
+
/**
|
|
196
|
+
* The inner product with the rounding error of every product and every addition
|
|
197
|
+
* recovered and folded back in (Ogita–Rump–Oishi's compensated dot product,
|
|
198
|
+
* computed by `@ac-kit/math-scalar`'s `dotPrecise3`, which returns what
|
|
199
|
+
* `dotPrecise` does): as accurate as a dot product in doubled precision rounded
|
|
200
|
+
* once, so it survives the cancellation that leaves {@link vec3Dot} with none of
|
|
201
|
+
* its digits. A few times the cost of the plain form.
|
|
202
|
+
*/
|
|
203
|
+
export declare function vec3DotPrecise(a: ReadonlyVec3, b: ReadonlyVec3): number;
|
|
204
|
+
/**
|
|
205
|
+
* The length `√(Σ aᵢ²)`, right when the largest component lies between about
|
|
206
|
+
* `1e−150` and `1e150`. Beyond, the squares overflow (above about `1.3e154`),
|
|
207
|
+
* or underflow and lose their digits to the subnormal range (below about
|
|
208
|
+
* `1.5e−154`), and the result is `Infinity`, `0` or wrong: use
|
|
209
|
+
* {@link vec3LengthScaled}.
|
|
210
|
+
*/
|
|
211
|
+
export declare function vec3Length(a: ReadonlyVec3): number;
|
|
212
|
+
/**
|
|
213
|
+
* The squared length `Σ aᵢ²`, without the square root, right when the largest
|
|
214
|
+
* component lies between about `1e−150` and `1e150`: beyond, it overflows to
|
|
215
|
+
* `Infinity` or loses its digits to the subnormal range.
|
|
216
|
+
*/
|
|
217
|
+
export declare function vec3LengthSquared(a: ReadonlyVec3): number;
|
|
218
|
+
/**
|
|
219
|
+
* The length at any magnitude: every component is divided by the largest first,
|
|
220
|
+
* so the squares stay in range where {@link vec3Length} returns `0` or
|
|
221
|
+
* `Infinity` beyond about `1e±150`. Zero for the zero vector, `Infinity` for an
|
|
222
|
+
* infinite component, `NaN` for a `NaN` one. About three times the cost.
|
|
223
|
+
*/
|
|
224
|
+
export declare function vec3LengthScaled(a: ReadonlyVec3): number;
|
|
225
|
+
/** The Manhattan length `Σ |aᵢ|`: the distance along the axes. */
|
|
226
|
+
export declare function vec3LengthManhattan(a: ReadonlyVec3): number;
|
|
227
|
+
/** The Chebyshev length `max |aᵢ|`: the largest move along one axis. */
|
|
228
|
+
export declare function vec3LengthChebyshev(a: ReadonlyVec3): number;
|
|
229
|
+
/**
|
|
230
|
+
* The Euclidean distance `|a − b|`, right when the largest difference lies
|
|
231
|
+
* between about `1e−150` and `1e150`; beyond, the squares overflow or lose
|
|
232
|
+
* their digits as in {@link vec3Length}: take {@link vec3LengthScaled} of `a − b`
|
|
233
|
+
* (from {@link vec3Subtract}) instead.
|
|
234
|
+
*/
|
|
235
|
+
export declare function vec3Distance(a: ReadonlyVec3, b: ReadonlyVec3): number;
|
|
236
|
+
/**
|
|
237
|
+
* The squared distance `|a − b|²`, without the square root, right when the
|
|
238
|
+
* largest difference lies between about `1e−150` and `1e150`: beyond, it
|
|
239
|
+
* overflows to `Infinity` or loses its digits.
|
|
240
|
+
*/
|
|
241
|
+
export declare function vec3DistanceSquared(a: ReadonlyVec3, b: ReadonlyVec3): number;
|
|
242
|
+
/** The Manhattan distance `Σ |aᵢ − bᵢ|`: the distance along the axes. */
|
|
243
|
+
export declare function vec3DistanceManhattan(a: ReadonlyVec3, b: ReadonlyVec3): number;
|
|
244
|
+
/** The Chebyshev distance `max |aᵢ − bᵢ|`: the largest move along one axis. */
|
|
245
|
+
export declare function vec3DistanceChebyshev(a: ReadonlyVec3, b: ReadonlyVec3): number;
|
|
246
|
+
/**
|
|
247
|
+
* Writes `a / |a|` into `out`: the unit vector in the same direction, from one
|
|
248
|
+
* reciprocal of the length multiplied in. The zero vector stays zero, and a
|
|
249
|
+
* `NaN` component gives `NaN` throughout. Right when the largest component lies
|
|
250
|
+
* between about `1e−150` and `1e150`; beyond, the squared length overflows,
|
|
251
|
+
* underflows or loses its digits to the subnormal range, and the result is
|
|
252
|
+
* zeros or wrong: use {@link vec3NormalizeScaled}. `out` may be `a`.
|
|
253
|
+
*/
|
|
254
|
+
export declare function vec3Normalize(out: Vec3, a: ReadonlyVec3): Vec3;
|
|
255
|
+
/**
|
|
256
|
+
* Writes `a / |a|` into `out` at any magnitude, subnormal and near the largest
|
|
257
|
+
* binary64 included: the components are divided by the largest first, so the
|
|
258
|
+
* squares stay in range (see {@link vec3Normalize} for the plain form). The zero
|
|
259
|
+
* vector stays zero; `NaN` and infinite components give `NaN` throughout. About
|
|
260
|
+
* three times the cost. `out` may be `a`.
|
|
261
|
+
*/
|
|
262
|
+
export declare function vec3NormalizeScaled(out: Vec3, a: ReadonlyVec3): Vec3;
|
|
263
|
+
/**
|
|
264
|
+
* Writes `a` with its length limited to `[min, max]` into `out`, the direction
|
|
265
|
+
* kept. The zero vector stays zero whatever `min` is, a `min` above `max` gives
|
|
266
|
+
* `max`, and a `NaN` gives `NaN`. The length is that of {@link vec3Length}, so
|
|
267
|
+
* the result is right when the largest component lies between about `1e−150`
|
|
268
|
+
* and `1e150`. Beyond, a vector whose length overflows (components above about
|
|
269
|
+
* `1.3e154`) comes back as the zero vector instead of being limited to `max`,
|
|
270
|
+
* and one whose squares underflow (below about `1.5e−154`) comes back unchanged
|
|
271
|
+
* instead of being lengthened to `min`: limit {@link vec3LengthScaled} yourself
|
|
272
|
+
* and scale {@link vec3NormalizeScaled} by it. `out` may be `a`.
|
|
273
|
+
*/
|
|
274
|
+
export declare function vec3ClampLength(out: Vec3, a: ReadonlyVec3, min: number, max: number): Vec3;
|
|
275
|
+
/**
|
|
276
|
+
* Writes the projection of `a` onto the line along `onto`, `onto · (a·onto) /
|
|
277
|
+
* (onto·onto)`, into `out`. `onto` need not be a unit vector; a zero `onto`
|
|
278
|
+
* gives `NaN`. Right when the largest component of `onto` lies between about
|
|
279
|
+
* `1e−150` and `1e150`, where `onto·onto` stays in range: above about `1.3e154`
|
|
280
|
+
* it overflows and the projection is the zero vector, and below about
|
|
281
|
+
* `1.5e−154` it underflows and the result is not finite. Beyond, normalise
|
|
282
|
+
* `onto` with {@link vec3NormalizeScaled} first. `out` may be `a` or `onto`.
|
|
283
|
+
*/
|
|
284
|
+
export declare function vec3Project(out: Vec3, a: ReadonlyVec3, onto: ReadonlyVec3): Vec3;
|
|
285
|
+
/**
|
|
286
|
+
* Writes `a` minus its projection onto `onto` into `out`: the part of `a`
|
|
287
|
+
* perpendicular to `onto`. A zero `onto` gives `NaN`. Right when the largest
|
|
288
|
+
* component of `onto` lies between about `1e−150` and `1e150`, as for
|
|
289
|
+
* {@link vec3Project}: beyond, the result is `a` (the projection is zero) or not
|
|
290
|
+
* finite; normalise `onto` with {@link vec3NormalizeScaled} first. `out` may be
|
|
291
|
+
* `a` or `onto`.
|
|
292
|
+
*/
|
|
293
|
+
export declare function vec3Reject(out: Vec3, a: ReadonlyVec3, onto: ReadonlyVec3): Vec3;
|
|
294
|
+
/**
|
|
295
|
+
* Writes `a` mirrored across the plane whose normal is `normal`, `a −
|
|
296
|
+
* 2(a·normal)·normal`, into `out`. `normal` must be a unit vector: it is not
|
|
297
|
+
* normalised here. `out` may be `a` or `normal`.
|
|
298
|
+
*/
|
|
299
|
+
export declare function vec3Reflect(out: Vec3, a: ReadonlyVec3, normal: ReadonlyVec3): Vec3;
|
|
300
|
+
/**
|
|
301
|
+
* Orders vectors lexicographically: by x, then by y, then by z. Exact, so it
|
|
302
|
+
* returns `0` for exactly the pairs {@link vec3Equals} calls equal, and a total
|
|
303
|
+
* order whatever the components: `NaN` sorts after every number and equals
|
|
304
|
+
* itself (where `vec3Equals` says it equals nothing), and `−0` equals `+0`. Fit
|
|
305
|
+
* for a sort comparator or an ordered container.
|
|
306
|
+
*
|
|
307
|
+
* @returns `−1` when `a` comes first, `1` when `b` does, `0` when neither.
|
|
308
|
+
*/
|
|
309
|
+
export declare function vec3CompareLexicographic(a: ReadonlyVec3, b: ReadonlyVec3): ComparatorResult;
|
|
310
|
+
//# sourceMappingURL=vec3-componentwise.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vec3-componentwise.d.ts","sourceRoot":"","sources":["../src/vec3-componentwise.ts"],"names":[],"mappings":"AAEA,OAAO,EAEN,KAAK,gBAAgB,EAErB,KAAK,gBAAgB,EAGrB,KAAK,YAAY,EACjB,MAAM,cAAc,CAAC;AAGtB,OAAO,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAQpD;;;;GAIG;AACH,wBAAgB,UAAU,IAAI,IAAI,CAMjC;AAED;;;;;;;GAO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