@ac-kit/math-linear 0.2.1 → 0.4.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 +337 -0
- package/README.md +232 -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 +214 -0
- package/dist/_invert.d.ts.map +1 -0
- package/dist/_invert.js +884 -0
- package/dist/_invert.js.map +1 -0
- package/dist/_slerp.d.ts +29 -0
- package/dist/_slerp.d.ts.map +1 -1
- package/dist/_slerp.js +103 -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 +156 -0
- package/dist/affine2.d.ts.map +1 -0
- package/dist/affine2.js +437 -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 +205 -0
- package/dist/affine3.d.ts.map +1 -0
- package/dist/affine3.js +792 -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 +79 -25
- package/dist/mat2x2.d.ts.map +1 -1
- package/dist/mat2x2.js +192 -93
- 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 +153 -48
- package/dist/mat3x3.d.ts.map +1 -1
- package/dist/mat3x3.js +470 -192
- 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 +221 -67
- package/dist/mat4x4.d.ts.map +1 -1
- package/dist/mat4x4.js +972 -334
- package/dist/mat4x4.js.map +1 -1
- package/dist/projection.d.ts +113 -0
- package/dist/projection.d.ts.map +1 -0
- package/dist/projection.js +418 -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 +106 -22
- package/dist/quaternion.d.ts.map +1 -1
- package/dist/quaternion.js +253 -182
- 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 +207 -0
- package/dist/vec2-array-componentwise.d.ts.map +1 -0
- package/dist/vec2-array-componentwise.js +472 -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 +207 -0
- package/dist/vec3-array-componentwise.d.ts.map +1 -0
- package/dist/vec3-array-componentwise.js +510 -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 +391 -272
- package/dist/vec3.js.map +1 -1
- package/dist/vec4-array-componentwise.d.ts +198 -0
- package/dist/vec4-array-componentwise.d.ts.map +1 -0
- package/dist/vec4-array-componentwise.js +521 -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 +59 -53
- package/dist/vec4.d.ts.map +1 -1
- package/dist/vec4.js +74 -249
- 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 +19 -9
package/dist/affine2.js
ADDED
|
@@ -0,0 +1,437 @@
|
|
|
1
|
+
import { numberAtOrNaN } from "@ac-kit/core";
|
|
2
|
+
import { INVERSE_LIMIT_, ROUNDING_TOLERANCE_, UNDERFLOW_TOLERANCE_, UNDERFLOW_UNIT_, UNIT_ROUNDOFF_, writeInverseTranslation_, } from "./_invert.js";
|
|
3
|
+
import { mat2x2Create } from "./mat2x2-componentwise.js";
|
|
4
|
+
import { mat2x2Invert } from "./mat2x2.js";
|
|
5
|
+
import { mat3x3Create } from "./mat3x3-componentwise.js";
|
|
6
|
+
import { mat3x3Invert } from "./mat3x3.js";
|
|
7
|
+
/**
|
|
8
|
+
* Every creator copies this array, which holds non-integer doubles and is never
|
|
9
|
+
* exposed: nothing a caller does can change the element kind it copies.
|
|
10
|
+
*/
|
|
11
|
+
const TEMPLATE_ = [0.5, 0.5, 0.5, 0.5, 0.5, 0.5];
|
|
12
|
+
/**
|
|
13
|
+
* Creates the identity transform `[1, 0, 0, 1, 0, 0]`.
|
|
14
|
+
*
|
|
15
|
+
* Allocates; keep it out of hot loops.
|
|
16
|
+
*/
|
|
17
|
+
export function affine2Create() {
|
|
18
|
+
const out = TEMPLATE_.slice();
|
|
19
|
+
out[0] = 1;
|
|
20
|
+
out[1] = 0;
|
|
21
|
+
out[2] = 0;
|
|
22
|
+
out[3] = 1;
|
|
23
|
+
out[4] = 0;
|
|
24
|
+
out[5] = 0;
|
|
25
|
+
return out;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Creates the transform with the entries in storage order, the columns of the
|
|
29
|
+
* matrix one after the other: `a, b, c, d, e, f`.
|
|
30
|
+
*
|
|
31
|
+
* Allocates; keep it out of hot loops.
|
|
32
|
+
*/
|
|
33
|
+
export function affine2Of(m00, m10, m01, m11, m02, m12) {
|
|
34
|
+
const out = TEMPLATE_.slice();
|
|
35
|
+
out[0] = m00;
|
|
36
|
+
out[1] = m10;
|
|
37
|
+
out[2] = m01;
|
|
38
|
+
out[3] = m11;
|
|
39
|
+
out[4] = m02;
|
|
40
|
+
out[5] = m12;
|
|
41
|
+
return out;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Creates a copy of `a`. Like every creator it starts from a clean array.
|
|
45
|
+
*
|
|
46
|
+
* Allocates; keep it out of hot loops.
|
|
47
|
+
*/
|
|
48
|
+
export function affine2Clone(a) {
|
|
49
|
+
const out = TEMPLATE_.slice();
|
|
50
|
+
out[0] = a[0];
|
|
51
|
+
out[1] = a[1];
|
|
52
|
+
out[2] = a[2];
|
|
53
|
+
out[3] = a[3];
|
|
54
|
+
out[4] = a[4];
|
|
55
|
+
out[5] = a[5];
|
|
56
|
+
return out;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* The checked way in from untyped data (JSON, messages, arrays of unknown
|
|
60
|
+
* origin): `source[offset … offset + 6)` copied into `out`, each element that
|
|
61
|
+
* is not a number written as `NaN`, an index past the end of `source` too, so
|
|
62
|
+
* `out` never holds a non-number. A cold path. O(1).
|
|
63
|
+
*
|
|
64
|
+
* `source` may be `out` itself: the six elements are read before the first
|
|
65
|
+
* write.
|
|
66
|
+
*
|
|
67
|
+
* @param out The transform to fill.
|
|
68
|
+
* @param source The array to read, of any length and any content.
|
|
69
|
+
* @param offset The index of the first entry in `source`.
|
|
70
|
+
* @returns `out`.
|
|
71
|
+
*/
|
|
72
|
+
export function affine2FromArray(out, source, offset = 0) {
|
|
73
|
+
const m00 = numberAtOrNaN(source, offset);
|
|
74
|
+
const m10 = numberAtOrNaN(source, offset + 1);
|
|
75
|
+
const m01 = numberAtOrNaN(source, offset + 2);
|
|
76
|
+
const m11 = numberAtOrNaN(source, offset + 3);
|
|
77
|
+
const m02 = numberAtOrNaN(source, offset + 4);
|
|
78
|
+
const m12 = numberAtOrNaN(source, offset + 5);
|
|
79
|
+
out[0] = m00;
|
|
80
|
+
out[1] = m10;
|
|
81
|
+
out[2] = m01;
|
|
82
|
+
out[3] = m11;
|
|
83
|
+
out[4] = m02;
|
|
84
|
+
out[5] = m12;
|
|
85
|
+
return out;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Whether every entry is a finite number: the check to run after parsing
|
|
89
|
+
* untrusted data or before an upload, as operations never check. An entry that
|
|
90
|
+
* is not a number at all counts as not finite.
|
|
91
|
+
*/
|
|
92
|
+
export function affine2IsFinite(a) {
|
|
93
|
+
return (Number.isFinite(a[0]) &&
|
|
94
|
+
Number.isFinite(a[1]) &&
|
|
95
|
+
Number.isFinite(a[2]) &&
|
|
96
|
+
Number.isFinite(a[3]) &&
|
|
97
|
+
Number.isFinite(a[4]) &&
|
|
98
|
+
Number.isFinite(a[5]));
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Writes the composition `a · b` into `out`: `b` is applied first, then `a`.
|
|
102
|
+
* Not commutative. Plain arithmetic, straight-line. `out` may be `a` or `b`.
|
|
103
|
+
*/
|
|
104
|
+
export function affine2Multiply(out, a, b) {
|
|
105
|
+
const a0 = a[0];
|
|
106
|
+
const a1 = a[1];
|
|
107
|
+
const a2 = a[2];
|
|
108
|
+
const a3 = a[3];
|
|
109
|
+
const a4 = a[4];
|
|
110
|
+
const a5 = a[5];
|
|
111
|
+
const b0 = b[0];
|
|
112
|
+
const b1 = b[1];
|
|
113
|
+
const b2 = b[2];
|
|
114
|
+
const b3 = b[3];
|
|
115
|
+
const b4 = b[4];
|
|
116
|
+
const b5 = b[5];
|
|
117
|
+
out[0] = a0 * b0 + a2 * b1;
|
|
118
|
+
out[1] = a1 * b0 + a3 * b1;
|
|
119
|
+
out[2] = a0 * b2 + a2 * b3;
|
|
120
|
+
out[3] = a1 * b2 + a3 * b3;
|
|
121
|
+
out[4] = a0 * b4 + a2 * b5 + a4;
|
|
122
|
+
out[5] = a1 * b4 + a3 * b5 + a5;
|
|
123
|
+
return out;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* The determinant of the linear part, `a · d − b · c`: the signed area scale of
|
|
127
|
+
* the transform, negative for a reflection.
|
|
128
|
+
*/
|
|
129
|
+
export function affine2Determinant(a) {
|
|
130
|
+
return a[0] * a[3] - a[2] * a[1];
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Scratch for {@link affine2Invert}'s second attempt: the linear part, and its
|
|
134
|
+
* inverse. One call at a time, no callback inside it.
|
|
135
|
+
*/
|
|
136
|
+
const LINEAR_PART_ = mat2x2Create();
|
|
137
|
+
const LINEAR_INVERSE_ = mat2x2Create();
|
|
138
|
+
const HOMOGENEOUS_ = mat3x3Create();
|
|
139
|
+
const HOMOGENEOUS_INVERSE_ = mat3x3Create();
|
|
140
|
+
/**
|
|
141
|
+
* Whether the inverse of the homogeneous matrix of `a` rounds to finite
|
|
142
|
+
* numbers, by {@link mat3x3Invert}: the verdict on the translation that
|
|
143
|
+
* `writeInverseTranslation_` takes when its own bound cannot give one.
|
|
144
|
+
*/
|
|
145
|
+
function isHomogeneousInvertible_(a) {
|
|
146
|
+
HOMOGENEOUS_[0] = a[0];
|
|
147
|
+
HOMOGENEOUS_[1] = a[1];
|
|
148
|
+
HOMOGENEOUS_[2] = 0;
|
|
149
|
+
HOMOGENEOUS_[3] = a[2];
|
|
150
|
+
HOMOGENEOUS_[4] = a[3];
|
|
151
|
+
HOMOGENEOUS_[5] = 0;
|
|
152
|
+
HOMOGENEOUS_[6] = a[4];
|
|
153
|
+
HOMOGENEOUS_[7] = a[5];
|
|
154
|
+
HOMOGENEOUS_[8] = 1;
|
|
155
|
+
return mat3x3Invert(HOMOGENEOUS_INVERSE_, HOMOGENEOUS_);
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Writes the inverse transform of `a` into `out` and returns `true`. When the
|
|
159
|
+
* determinant is zero or not finite, or the inverse does not fit in binary64,
|
|
160
|
+
* the transform has no usable inverse: `out` is filled with `NaN` and the
|
|
161
|
+
* result is `false`: `true` always comes with a finite `out`, never a stale or
|
|
162
|
+
* partial transform, and nothing throws. A transform whose linear part has very
|
|
163
|
+
* large or very small entries, whose determinant or cofactors overflow or
|
|
164
|
+
* underflow, is inverted all the same (a uniform scale of `1e-200` gives
|
|
165
|
+
* `1e200`; scales of `2^600` and `2^599` with a translation of
|
|
166
|
+
* `Number.MAX_VALUE` invert too), by inverting the linear part as
|
|
167
|
+
* {@link mat2x2Invert} does and taking the translation from that unscaled
|
|
168
|
+
* inverse. Plain arithmetic (the adjugate over the determinant). Each
|
|
169
|
+
* translation component is `−B · t` for the returned linear part `B` and the
|
|
170
|
+
* translation `t`: in plain arithmetic when a forward error bound keeps it
|
|
171
|
+
* within `2^-41` of itself, and otherwise correctly rounded (`dotExactInto`),
|
|
172
|
+
* however its terms cancel (`[[1, −(1 + 2^-52)], [0, 1]]` with a translation of
|
|
173
|
+
* `(−(1 + 2^-51), 1 + 2^-52)` gives `−2^-104`, not `0`). Whether it overflows
|
|
174
|
+
* is decided on the exact `−A⁻¹ · t`, never on the rounded `B`: a component
|
|
175
|
+
* that a rigorous bound cannot keep from the overflow threshold is settled in
|
|
176
|
+
* exact arithmetic, and is then `−A⁻¹ · t` rounded once (a scale of `161/256`
|
|
177
|
+
* with a translation of `161 · 2^1016` is refused, its exact `−2^1024`
|
|
178
|
+
* overflowing where `−B · t` rounds to `−Number.MAX_VALUE`). `out` may be `a`.
|
|
179
|
+
*/
|
|
180
|
+
export function affine2Invert(out, a) {
|
|
181
|
+
if (invert_(out, a, false)) {
|
|
182
|
+
return true;
|
|
183
|
+
}
|
|
184
|
+
LINEAR_PART_[0] = a[0];
|
|
185
|
+
LINEAR_PART_[1] = a[1];
|
|
186
|
+
LINEAR_PART_[2] = a[2];
|
|
187
|
+
LINEAR_PART_[3] = a[3];
|
|
188
|
+
if (mat2x2Invert(LINEAR_INVERSE_, LINEAR_PART_) &&
|
|
189
|
+
writeInverseTranslation_(out, 4, LINEAR_INVERSE_, 2, a, isHomogeneousInvertible_)) {
|
|
190
|
+
out[0] = LINEAR_INVERSE_[0];
|
|
191
|
+
out[1] = LINEAR_INVERSE_[1];
|
|
192
|
+
out[2] = LINEAR_INVERSE_[2];
|
|
193
|
+
out[3] = LINEAR_INVERSE_[3];
|
|
194
|
+
return true;
|
|
195
|
+
}
|
|
196
|
+
out[0] = Number.NaN;
|
|
197
|
+
out[1] = Number.NaN;
|
|
198
|
+
out[2] = Number.NaN;
|
|
199
|
+
out[3] = Number.NaN;
|
|
200
|
+
out[4] = Number.NaN;
|
|
201
|
+
out[5] = Number.NaN;
|
|
202
|
+
return false;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* The inverse by the adjugate over the determinant, written to `out` only when
|
|
206
|
+
* every entry is finite. The reciprocal of the determinant multiplies the
|
|
207
|
+
* adjugate; when it overflows (a subnormal determinant) the adjugate is divided
|
|
208
|
+
* by the determinant instead, if `divide`, and not otherwise.
|
|
209
|
+
*/
|
|
210
|
+
function invert_(out, a, divide) {
|
|
211
|
+
const a0 = a[0];
|
|
212
|
+
const a1 = a[1];
|
|
213
|
+
const a2 = a[2];
|
|
214
|
+
const a3 = a[3];
|
|
215
|
+
const a4 = a[4];
|
|
216
|
+
const a5 = a[5];
|
|
217
|
+
const determinant = a0 * a3 - a2 * a1;
|
|
218
|
+
if (determinant === 0 || !Number.isFinite(determinant)) {
|
|
219
|
+
return false;
|
|
220
|
+
}
|
|
221
|
+
// As in `mat2x2Invert`: a determinant not within 2^-41 of itself leaves the
|
|
222
|
+
// linear part to `mat2x2Invert`'s accurate one.
|
|
223
|
+
if (!(3 * UNIT_ROUNDOFF_ * (Math.abs(a0 * a3) + Math.abs(a2 * a1)) <=
|
|
224
|
+
ROUNDING_TOLERANCE_ * Math.abs(determinant) &&
|
|
225
|
+
UNDERFLOW_UNIT_ <= UNDERFLOW_TOLERANCE_ * Math.abs(determinant))) {
|
|
226
|
+
return false;
|
|
227
|
+
}
|
|
228
|
+
const scale = 1 / determinant;
|
|
229
|
+
const reciprocal = Number.isFinite(scale);
|
|
230
|
+
if (!reciprocal && !divide) {
|
|
231
|
+
return false;
|
|
232
|
+
}
|
|
233
|
+
const o0 = reciprocal ? a3 * scale : a3 / determinant;
|
|
234
|
+
const o1 = reciprocal ? -a1 * scale : -a1 / determinant;
|
|
235
|
+
const o2 = reciprocal ? -a2 * scale : -a2 / determinant;
|
|
236
|
+
const o3 = reciprocal ? a0 * scale : a0 / determinant;
|
|
237
|
+
// The translation, `−B · t` for the B returned, a sum of two products
|
|
238
|
+
// within γ₂ · Σ|products| plus an underflow per product of its exact value
|
|
239
|
+
// (Higham, §3.1), accepted within 2^-41 of itself, as the determinant is;
|
|
240
|
+
// one the bound cannot keep is left to the correctly rounded kernel. A
|
|
241
|
+
// component whose every product has a zero factor is exactly zero.
|
|
242
|
+
const p0 = o0 * a4;
|
|
243
|
+
const p1 = o2 * a5;
|
|
244
|
+
const p2 = o1 * a4;
|
|
245
|
+
const p3 = o3 * a5;
|
|
246
|
+
const o4 = -(p0 + p1);
|
|
247
|
+
const o5 = -(p2 + p3);
|
|
248
|
+
const m4 = Math.abs(o4);
|
|
249
|
+
const m5 = Math.abs(o5);
|
|
250
|
+
if (!((3 * UNIT_ROUNDOFF_ * (Math.abs(p0) + Math.abs(p1)) <=
|
|
251
|
+
ROUNDING_TOLERANCE_ * m4 &&
|
|
252
|
+
2 * UNDERFLOW_UNIT_ <= UNDERFLOW_TOLERANCE_ * m4) ||
|
|
253
|
+
((o0 === 0 || a4 === 0) && (o2 === 0 || a5 === 0))) ||
|
|
254
|
+
!((3 * UNIT_ROUNDOFF_ * (Math.abs(p2) + Math.abs(p3)) <=
|
|
255
|
+
ROUNDING_TOLERANCE_ * m5 &&
|
|
256
|
+
2 * UNDERFLOW_UNIT_ <= UNDERFLOW_TOLERANCE_ * m5) ||
|
|
257
|
+
((o1 === 0 || a4 === 0) && (o3 === 0 || a5 === 0)))) {
|
|
258
|
+
return false;
|
|
259
|
+
}
|
|
260
|
+
// Within INVERSE_LIMIT_, the exact entries, within about 2^-40 of the
|
|
261
|
+
// largest of these, round to finite numbers. The exact −A⁻¹ · t differs
|
|
262
|
+
// from the −B · t computed by its rounding, within 2^-41 of each
|
|
263
|
+
// component, and by (B − A⁻¹) · t: each entry of B, an entry of the
|
|
264
|
+
// adjugate (exact) times the reciprocal of the determinant, is within
|
|
265
|
+
// 2^-41 + 2u of itself, so that term is within about 2^-41 of the sum of
|
|
266
|
+
// the products' magnitudes, which the bound above keeps within 2^12 / 3
|
|
267
|
+
// of the component: 2^-30.5 of it, which the 2^-30 margin of the limit
|
|
268
|
+
// takes. Past it, or not finite, the second attempt decides.
|
|
269
|
+
if (!(Math.max(Math.abs(o0), Math.abs(o1), Math.abs(o2), Math.abs(o3), m4, m5) <= INVERSE_LIMIT_)) {
|
|
270
|
+
return false;
|
|
271
|
+
}
|
|
272
|
+
out[0] = o0;
|
|
273
|
+
out[1] = o1;
|
|
274
|
+
out[2] = o2;
|
|
275
|
+
out[3] = o3;
|
|
276
|
+
out[4] = o4;
|
|
277
|
+
out[5] = o5;
|
|
278
|
+
return true;
|
|
279
|
+
}
|
|
280
|
+
/** Writes the translation by `translation` into `out`. */
|
|
281
|
+
export function affine2FromTranslation(out, translation) {
|
|
282
|
+
out[0] = 1;
|
|
283
|
+
out[1] = 0;
|
|
284
|
+
out[2] = 0;
|
|
285
|
+
out[3] = 1;
|
|
286
|
+
out[4] = translation[0];
|
|
287
|
+
out[5] = translation[1];
|
|
288
|
+
return out;
|
|
289
|
+
}
|
|
290
|
+
/** Writes the scale `diag(scale)` into `out`. */
|
|
291
|
+
export function affine2FromScale(out, scale) {
|
|
292
|
+
out[0] = scale[0];
|
|
293
|
+
out[1] = 0;
|
|
294
|
+
out[2] = 0;
|
|
295
|
+
out[3] = scale[1];
|
|
296
|
+
out[4] = 0;
|
|
297
|
+
out[5] = 0;
|
|
298
|
+
return out;
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Writes the rotation by `angle` radians, counter-clockwise with `y` up (so
|
|
302
|
+
* clockwise on a screen with `y` down), about the origin into `out`: `[cos,
|
|
303
|
+
* sin, −sin, cos, 0, 0]`.
|
|
304
|
+
*/
|
|
305
|
+
export function affine2FromRotation(out, angle) {
|
|
306
|
+
const cos = Math.cos(angle);
|
|
307
|
+
const sin = Math.sin(angle);
|
|
308
|
+
out[0] = cos;
|
|
309
|
+
out[1] = sin;
|
|
310
|
+
out[2] = -sin;
|
|
311
|
+
out[3] = cos;
|
|
312
|
+
out[4] = 0;
|
|
313
|
+
out[5] = 0;
|
|
314
|
+
return out;
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Writes `T(center) · S(scale) · T(−center)` into `out`: the scale that leaves
|
|
318
|
+
* the point `center` where it is, the zoom about the pointer.
|
|
319
|
+
*/
|
|
320
|
+
export function affine2FromScaleAbout(out, scale, center) {
|
|
321
|
+
const sx = scale[0];
|
|
322
|
+
const sy = scale[1];
|
|
323
|
+
const cx = center[0];
|
|
324
|
+
const cy = center[1];
|
|
325
|
+
out[0] = sx;
|
|
326
|
+
out[1] = 0;
|
|
327
|
+
out[2] = 0;
|
|
328
|
+
out[3] = sy;
|
|
329
|
+
out[4] = cx - sx * cx;
|
|
330
|
+
out[5] = cy - sy * cy;
|
|
331
|
+
return out;
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* Writes `T(center) · R(angle) · T(−center)` into `out`: the rotation by
|
|
335
|
+
* `angle` radians that leaves the point `center` where it is.
|
|
336
|
+
*/
|
|
337
|
+
export function affine2FromRotationAbout(out, angle, center) {
|
|
338
|
+
const cx = center[0];
|
|
339
|
+
const cy = center[1];
|
|
340
|
+
const cos = Math.cos(angle);
|
|
341
|
+
const sin = Math.sin(angle);
|
|
342
|
+
out[0] = cos;
|
|
343
|
+
out[1] = sin;
|
|
344
|
+
out[2] = -sin;
|
|
345
|
+
out[3] = cos;
|
|
346
|
+
out[4] = cx - (cos * cx - sin * cy);
|
|
347
|
+
out[5] = cy - (sin * cx + cos * cy);
|
|
348
|
+
return out;
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* Writes the 2D affine of a 3 × 3 matrix into `out`, dropping its bottom row,
|
|
352
|
+
* which an {@link Affine2} does not store (`0, 0, 1` for an affine matrix).
|
|
353
|
+
*/
|
|
354
|
+
export function affine2FromMat3x3(out, m) {
|
|
355
|
+
out[0] = m[0];
|
|
356
|
+
out[1] = m[1];
|
|
357
|
+
out[2] = m[3];
|
|
358
|
+
out[3] = m[4];
|
|
359
|
+
out[4] = m[6];
|
|
360
|
+
out[5] = m[7];
|
|
361
|
+
return out;
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* Writes `a · T(translation)` into `out`: the translation applied first, in the
|
|
365
|
+
* local space of `a`, as Canvas's `translate`. `out` may be `a`.
|
|
366
|
+
*/
|
|
367
|
+
export function affine2Translate(out, a, translation) {
|
|
368
|
+
const a0 = a[0];
|
|
369
|
+
const a1 = a[1];
|
|
370
|
+
const a2 = a[2];
|
|
371
|
+
const a3 = a[3];
|
|
372
|
+
const x = translation[0];
|
|
373
|
+
const y = translation[1];
|
|
374
|
+
const e = a0 * x + a2 * y + a[4];
|
|
375
|
+
const f = a1 * x + a3 * y + a[5];
|
|
376
|
+
out[0] = a0;
|
|
377
|
+
out[1] = a1;
|
|
378
|
+
out[2] = a2;
|
|
379
|
+
out[3] = a3;
|
|
380
|
+
out[4] = e;
|
|
381
|
+
out[5] = f;
|
|
382
|
+
return out;
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* Writes `a · R(angle)` into `out`: the rotation by `angle` radians applied
|
|
386
|
+
* first, in the local space of `a`, as Canvas's `rotate`. `out` may be `a`.
|
|
387
|
+
*/
|
|
388
|
+
export function affine2Rotate(out, a, angle) {
|
|
389
|
+
const a0 = a[0];
|
|
390
|
+
const a1 = a[1];
|
|
391
|
+
const a2 = a[2];
|
|
392
|
+
const a3 = a[3];
|
|
393
|
+
const cos = Math.cos(angle);
|
|
394
|
+
const sin = Math.sin(angle);
|
|
395
|
+
out[0] = a0 * cos + a2 * sin;
|
|
396
|
+
out[1] = a1 * cos + a3 * sin;
|
|
397
|
+
out[2] = a2 * cos - a0 * sin;
|
|
398
|
+
out[3] = a3 * cos - a1 * sin;
|
|
399
|
+
out[4] = a[4];
|
|
400
|
+
out[5] = a[5];
|
|
401
|
+
return out;
|
|
402
|
+
}
|
|
403
|
+
/**
|
|
404
|
+
* Writes `a · S(scale)` into `out`: the scale applied first, in the local space
|
|
405
|
+
* of `a`, as Canvas's `scale`. `out` may be `a`.
|
|
406
|
+
*/
|
|
407
|
+
export function affine2Scale(out, a, scale) {
|
|
408
|
+
const sx = scale[0];
|
|
409
|
+
const sy = scale[1];
|
|
410
|
+
out[0] = a[0] * sx;
|
|
411
|
+
out[1] = a[1] * sx;
|
|
412
|
+
out[2] = a[2] * sy;
|
|
413
|
+
out[3] = a[3] * sy;
|
|
414
|
+
out[4] = a[4];
|
|
415
|
+
out[5] = a[5];
|
|
416
|
+
return out;
|
|
417
|
+
}
|
|
418
|
+
/**
|
|
419
|
+
* Writes into `out` the transform that maps the rectangle `[left, right] ×
|
|
420
|
+
* [bottom, top]` to clip space `[−1, 1]²`, `y` up: `left` to −1 and `right` to
|
|
421
|
+
* 1, `bottom` to −1 and `top` to 1. For a pixel canvas with its origin at the
|
|
422
|
+
* top left, `y` down, call it as `(0, width, height, 0)`. An empty rectangle
|
|
423
|
+
* (`left = right` or `bottom = top`) gives non-finite entries and nothing
|
|
424
|
+
* throws, so a canvas of size zero during a resize is harmless.
|
|
425
|
+
*/
|
|
426
|
+
export function affine2Orthographic(out, left, right, bottom, top) {
|
|
427
|
+
const width = right - left;
|
|
428
|
+
const height = top - bottom;
|
|
429
|
+
out[0] = 2 / width;
|
|
430
|
+
out[1] = 0;
|
|
431
|
+
out[2] = 0;
|
|
432
|
+
out[3] = 2 / height;
|
|
433
|
+
out[4] = -(right + left) / width;
|
|
434
|
+
out[5] = -(top + bottom) / height;
|
|
435
|
+
return out;
|
|
436
|
+
}
|
|
437
|
+
//# sourceMappingURL=affine2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"affine2.js","sourceRoot":"","sources":["../src/affine2.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAG7C,OAAO,EACN,cAA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,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;IACnB,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;IACnB,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACd,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACd,OAAO,GAAG,CAAC;AACZ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,mBAAmB,CAClC,GAAY,EACZ,IAAY,EACZ,KAAa,EACb,MAAc,EACd,GAAW;IAEX,MAAM,KAAK,GAAG,KAAK,GAAG,IAAI,CAAC;IAC3B,MAAM,MAAM,GAAG,GAAG,GAAG,MAAM,CAAC;IAC5B,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IACnB,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACX,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACX,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC;IACpB,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,KAAK,CAAC;IACjC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,GAAG,MAAM,CAAC,GAAG,MAAM,CAAC;IAClC,OAAO,GAAG,CAAC;AACZ,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { ReadonlyAffine3, Affine3 } from "./affine3.js";
|
|
2
|
+
/**
|
|
3
|
+
* Creates a buffer for `count` affine3 elements: a zero-filled `Float64Array`
|
|
4
|
+
* of `count × 12` numbers, element `i` at `[i·12, i·12 + 12)`, a zero element
|
|
5
|
+
* being the all-zero transform (use {@link affine3Store} with the identity to
|
|
6
|
+
* fill it with identities). Allocates.
|
|
7
|
+
*
|
|
8
|
+
* @throws {RangeError} When `count` is not a non-negative safe integer or
|
|
9
|
+
* `count × 12` is not a valid typed array length.
|
|
10
|
+
*/
|
|
11
|
+
export declare function affine3ArrayCreate(count: number): Float64Array<ArrayBuffer>;
|
|
12
|
+
/**
|
|
13
|
+
* Writes element `index` of `array`, the numbers at `[index·12, index·12 +
|
|
14
|
+
* 12)`, into `out`. Each component is written as `+array[i]`, so an index past
|
|
15
|
+
* the end of `array` gives `NaN`, never `undefined`: the transform stays clean
|
|
16
|
+
* whatever the caller does. Checking the index is the job of the checked
|
|
17
|
+
* layer.
|
|
18
|
+
*
|
|
19
|
+
* The transform is copied: it is never a view of `array`. O(1).
|
|
20
|
+
*/
|
|
21
|
+
export declare function affine3Load(out: Affine3, array: Float64Array, index: number): Affine3;
|
|
22
|
+
/**
|
|
23
|
+
* Writes `value` into `array` as element `index`, at `[index·12, index·12 +
|
|
24
|
+
* 12)`. An element past the end of `array` writes nothing, as a typed array
|
|
25
|
+
* drops an out-of-range write. O(1).
|
|
26
|
+
*/
|
|
27
|
+
export declare function affine3Store(array: Float64Array, index: number, value: ReadonlyAffine3): void;
|
|
28
|
+
/**
|
|
29
|
+
* Like {@link affine3Load} for interleaved data: element `index` starts at
|
|
30
|
+
* `offset + index·stride`, both counted in numbers, and its 12 components
|
|
31
|
+
* follow one another. An index past the end gives `NaN` components. O(1).
|
|
32
|
+
*/
|
|
33
|
+
export declare function affine3LoadStrided(out: Affine3, array: Float64Array, offset: number, stride: number, index: number): Affine3;
|
|
34
|
+
/**
|
|
35
|
+
* Like {@link affine3Store} 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 affine3StoreStrided(array: Float64Array, offset: number, stride: number, index: number, value: ReadonlyAffine3): void;
|
|
40
|
+
/**
|
|
41
|
+
* Narrows `value` to binary32 and writes its 12 components into `array` from
|
|
42
|
+
* element `offset` on, unrolled: the way to stage a vertex, instance or uniform
|
|
43
|
+
* value for the GPU, where `array.set` costs several times as much for one
|
|
44
|
+
* value. A component past the end of `array` writes nothing. O(1).
|
|
45
|
+
*/
|
|
46
|
+
export declare function affine3StoreFloat32(array: Float32Array, offset: number, value: ReadonlyAffine3): void;
|
|
47
|
+
/**
|
|
48
|
+
* Whether every number of `array` is finite: the check for a buffer of affine3
|
|
49
|
+
* elements read from untrusted data or about to be uploaded. The length is not
|
|
50
|
+
* required to be a multiple of 12 (see `assertFiniteBuffer` for that). O(n).
|
|
51
|
+
*/
|
|
52
|
+
export declare function affine3ArrayIsFinite(array: Float64Array): boolean;
|
|
53
|
+
//# sourceMappingURL=affine3-array.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"affine3-array.d.ts","sourceRoot":"","sources":["../src/affine3-array.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE7D;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,CAAC,WAAW,CAAC,CAG3E;AAED;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAC1B,GAAG,EAAE,OAAO,EACZ,KAAK,EAAE,YAAY,EACnB,KAAK,EAAE,MAAM,GACX,OAAO,CAgBT;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAC3B,KAAK,EAAE,YAAY,EACnB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,eAAe,GACpB,IAAI,CAcN;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CACjC,GAAG,EAAE,OAAO,EACZ,KAAK,EAAE,YAAY,EACnB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,GACX,OAAO,CAgBT;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAClC,KAAK,EAAE,YAAY,EACnB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,eAAe,GACpB,IAAI,CAcN;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAClC,KAAK,EAAE,YAAY,EACnB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,eAAe,GACpB,IAAI,CAaN;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAOjE"}
|
|
@@ -0,0 +1,137 @@
|
|
|
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` affine3 elements: a zero-filled `Float64Array`
|
|
5
|
+
* of `count × 12` numbers, element `i` at `[i·12, i·12 + 12)`, a zero element
|
|
6
|
+
* being the all-zero transform (use {@link affine3Store} with the identity to
|
|
7
|
+
* fill it with identities). Allocates.
|
|
8
|
+
*
|
|
9
|
+
* @throws {RangeError} When `count` is not a non-negative safe integer or
|
|
10
|
+
* `count × 12` is not a valid typed array length.
|
|
11
|
+
*/
|
|
12
|
+
export function affine3ArrayCreate(count) {
|
|
13
|
+
assertInteger(count, "affine3ArrayCreate: count", 0);
|
|
14
|
+
return new Float64Array(count * 12);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Writes element `index` of `array`, the numbers at `[index·12, index·12 +
|
|
18
|
+
* 12)`, into `out`. Each component is written as `+array[i]`, so an index past
|
|
19
|
+
* the end of `array` gives `NaN`, never `undefined`: the transform stays clean
|
|
20
|
+
* whatever the caller does. Checking the index is the job of the checked
|
|
21
|
+
* layer.
|
|
22
|
+
*
|
|
23
|
+
* The transform is copied: it is never a view of `array`. O(1).
|
|
24
|
+
*/
|
|
25
|
+
export function affine3Load(out, array, index) {
|
|
26
|
+
const base = index * 12;
|
|
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
|
+
out[4] = +array[base + 4];
|
|
33
|
+
out[5] = +array[base + 5];
|
|
34
|
+
out[6] = +array[base + 6];
|
|
35
|
+
out[7] = +array[base + 7];
|
|
36
|
+
out[8] = +array[base + 8];
|
|
37
|
+
out[9] = +array[base + 9];
|
|
38
|
+
out[10] = +array[base + 10];
|
|
39
|
+
out[11] = +array[base + 11];
|
|
40
|
+
return out;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Writes `value` into `array` as element `index`, at `[index·12, index·12 +
|
|
44
|
+
* 12)`. An element past the end of `array` writes nothing, as a typed array
|
|
45
|
+
* drops an out-of-range write. O(1).
|
|
46
|
+
*/
|
|
47
|
+
export function affine3Store(array, index, value) {
|
|
48
|
+
const base = index * 12;
|
|
49
|
+
array[base] = value[0];
|
|
50
|
+
array[base + 1] = value[1];
|
|
51
|
+
array[base + 2] = value[2];
|
|
52
|
+
array[base + 3] = value[3];
|
|
53
|
+
array[base + 4] = value[4];
|
|
54
|
+
array[base + 5] = value[5];
|
|
55
|
+
array[base + 6] = value[6];
|
|
56
|
+
array[base + 7] = value[7];
|
|
57
|
+
array[base + 8] = value[8];
|
|
58
|
+
array[base + 9] = value[9];
|
|
59
|
+
array[base + 10] = value[10];
|
|
60
|
+
array[base + 11] = value[11];
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Like {@link affine3Load} for interleaved data: element `index` starts at
|
|
64
|
+
* `offset + index·stride`, both counted in numbers, and its 12 components
|
|
65
|
+
* follow one another. An index past the end gives `NaN` components. O(1).
|
|
66
|
+
*/
|
|
67
|
+
export function affine3LoadStrided(out, array, offset, stride, index) {
|
|
68
|
+
const base = offset + index * stride;
|
|
69
|
+
// The `!` is for the compiler: past the end `+undefined` is `NaN`.
|
|
70
|
+
out[0] = +array[base];
|
|
71
|
+
out[1] = +array[base + 1];
|
|
72
|
+
out[2] = +array[base + 2];
|
|
73
|
+
out[3] = +array[base + 3];
|
|
74
|
+
out[4] = +array[base + 4];
|
|
75
|
+
out[5] = +array[base + 5];
|
|
76
|
+
out[6] = +array[base + 6];
|
|
77
|
+
out[7] = +array[base + 7];
|
|
78
|
+
out[8] = +array[base + 8];
|
|
79
|
+
out[9] = +array[base + 9];
|
|
80
|
+
out[10] = +array[base + 10];
|
|
81
|
+
out[11] = +array[base + 11];
|
|
82
|
+
return out;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Like {@link affine3Store} for interleaved data: element `index` starts at
|
|
86
|
+
* `offset + index·stride`, both counted in numbers. A component past the end of
|
|
87
|
+
* `array` writes nothing. O(1).
|
|
88
|
+
*/
|
|
89
|
+
export function affine3StoreStrided(array, offset, stride, index, value) {
|
|
90
|
+
const base = offset + index * stride;
|
|
91
|
+
array[base] = value[0];
|
|
92
|
+
array[base + 1] = value[1];
|
|
93
|
+
array[base + 2] = value[2];
|
|
94
|
+
array[base + 3] = value[3];
|
|
95
|
+
array[base + 4] = value[4];
|
|
96
|
+
array[base + 5] = value[5];
|
|
97
|
+
array[base + 6] = value[6];
|
|
98
|
+
array[base + 7] = value[7];
|
|
99
|
+
array[base + 8] = value[8];
|
|
100
|
+
array[base + 9] = value[9];
|
|
101
|
+
array[base + 10] = value[10];
|
|
102
|
+
array[base + 11] = value[11];
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Narrows `value` to binary32 and writes its 12 components into `array` from
|
|
106
|
+
* element `offset` on, unrolled: the way to stage a vertex, instance or uniform
|
|
107
|
+
* value for the GPU, where `array.set` costs several times as much for one
|
|
108
|
+
* value. A component past the end of `array` writes nothing. O(1).
|
|
109
|
+
*/
|
|
110
|
+
export function affine3StoreFloat32(array, offset, value) {
|
|
111
|
+
array[offset] = value[0];
|
|
112
|
+
array[offset + 1] = value[1];
|
|
113
|
+
array[offset + 2] = value[2];
|
|
114
|
+
array[offset + 3] = value[3];
|
|
115
|
+
array[offset + 4] = value[4];
|
|
116
|
+
array[offset + 5] = value[5];
|
|
117
|
+
array[offset + 6] = value[6];
|
|
118
|
+
array[offset + 7] = value[7];
|
|
119
|
+
array[offset + 8] = value[8];
|
|
120
|
+
array[offset + 9] = value[9];
|
|
121
|
+
array[offset + 10] = value[10];
|
|
122
|
+
array[offset + 11] = value[11];
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Whether every number of `array` is finite: the check for a buffer of affine3
|
|
126
|
+
* elements read from untrusted data or about to be uploaded. The length is not
|
|
127
|
+
* required to be a multiple of 12 (see `assertFiniteBuffer` for that). O(n).
|
|
128
|
+
*/
|
|
129
|
+
export function affine3ArrayIsFinite(array) {
|
|
130
|
+
for (let index = 0; index < array.length; index++) {
|
|
131
|
+
if (!Number.isFinite(array[index])) {
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return true;
|
|
136
|
+
}
|
|
137
|
+
//# sourceMappingURL=affine3-array.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"affine3-array.js","sourceRoot":"","sources":["../src/affine3-array.ts"],"names":[],"mappings":"AAAA,yGAAyG;AAEzG,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAI7C;;;;;;;;GAQG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAa;IAC/C,aAAa,CAAC,KAAK,EAAE,2BAA2B,EAAE,CAAC,CAAC,CAAC;IACrD,OAAO,IAAI,YAAY,CAAC,KAAK,GAAG,EAAE,CAAC,CAAC;AACrC,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,WAAW,CAC1B,GAAY,EACZ,KAAmB,EACnB,KAAa;IAEb,MAAM,IAAI,GAAG,KAAK,GAAG,EAAE,CAAC;IACxB,mEAAmE;IACnE,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAE,CAAC;IACvB,GAAG,CAAC,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