@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
|
@@ -0,0 +1,472 @@
|
|
|
1
|
+
// Generated from scripts/templates/vec-array-componentwise.liquid by scripts/generate-componentwise.ts. Do not edit.
|
|
2
|
+
import { assertInteger, PreciseSum, viewsMayOverlap } from "@ac-kit/core";
|
|
3
|
+
import { twoProductError } from "@ac-kit/math-scalar";
|
|
4
|
+
import { assertStridedRange_ } from "./_strided-range.js";
|
|
5
|
+
import { vec2Of } from "./vec2-componentwise.js";
|
|
6
|
+
/**
|
|
7
|
+
* Creates a buffer for `count` vec2 elements: a zero-filled `Float64Array` of
|
|
8
|
+
* `count × 2` numbers, element `i` at `[i·2, i·2 + 2)`. Allocates.
|
|
9
|
+
*
|
|
10
|
+
* @throws {RangeError} When `count` is not a non-negative safe integer or
|
|
11
|
+
* `count × 2` is not a valid typed array length.
|
|
12
|
+
*/
|
|
13
|
+
export function vec2ArrayCreate(count) {
|
|
14
|
+
assertInteger(count, "vec2ArrayCreate: count", 0);
|
|
15
|
+
return new Float64Array(count * 2);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Creates a buffer holding `values`, element `i` being `values[i]`. O(n),
|
|
19
|
+
* allocates.
|
|
20
|
+
*/
|
|
21
|
+
export function vec2ArrayFromValues(values) {
|
|
22
|
+
const array = new Float64Array(values.length * 2);
|
|
23
|
+
for (let index = 0; index < values.length; index++) {
|
|
24
|
+
const value = values[index];
|
|
25
|
+
const base = index * 2;
|
|
26
|
+
array[base] = value[0];
|
|
27
|
+
array[base + 1] = value[1];
|
|
28
|
+
}
|
|
29
|
+
return array;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Reads every element of `array` into a Vec2 made by {@link vec2Of}, so each one
|
|
33
|
+
* is a clean array of doubles (never `Array.from` or a spread, which would not
|
|
34
|
+
* start from the creator's template). A tail shorter than one element is
|
|
35
|
+
* ignored. O(n), allocates one value per element.
|
|
36
|
+
*/
|
|
37
|
+
export function vec2ArrayToValues(array) {
|
|
38
|
+
const values = [];
|
|
39
|
+
for (let index = 0; index + 2 <= array.length; index += 2) {
|
|
40
|
+
values.push(vec2Of(array[index], array[index + 1]));
|
|
41
|
+
}
|
|
42
|
+
return values;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Narrows a tight binary64 buffer into an interleaved binary32 one: element `i`
|
|
46
|
+
* of `input` goes to `out[outOffset + i·outStride …]`, offset and stride
|
|
47
|
+
* counted in numbers, the other numbers of each stride untouched (a vertex
|
|
48
|
+
* buffer's normals, colours, …). For the whole array with no stride use
|
|
49
|
+
* `Float32Array.prototype.set`. `out` and `input` share no memory. O(n).
|
|
50
|
+
*
|
|
51
|
+
* @returns `out`.
|
|
52
|
+
* @throws {RangeError} Unless `input.length` is a multiple of 2, `count`, the
|
|
53
|
+
* offset and the stride are non-negative integers (the stride at least 2 from
|
|
54
|
+
* two elements on), the last element fits in `out`, and `out` and `input`
|
|
55
|
+
* share no memory.
|
|
56
|
+
*/
|
|
57
|
+
export function vec2ArrayNarrowStrided(out, outOffset, outStride, input) {
|
|
58
|
+
const length = input.length;
|
|
59
|
+
if (length % 2 !== 0) {
|
|
60
|
+
throw new RangeError("vec2ArrayNarrowStrided: input must be a multiple of 2 long.");
|
|
61
|
+
}
|
|
62
|
+
assertStridedRange_("vec2ArrayNarrowStrided", "out", out.length, outOffset, outStride, length / 2, 2);
|
|
63
|
+
if (length > 0 && viewsMayOverlap(out, input)) {
|
|
64
|
+
throw new RangeError("vec2ArrayNarrowStrided: out and input must not share memory.");
|
|
65
|
+
}
|
|
66
|
+
for (let index = 0, target = outOffset; index < length; index += 2, target += outStride) {
|
|
67
|
+
out[target] = input[index];
|
|
68
|
+
out[target + 1] = input[index + 1];
|
|
69
|
+
}
|
|
70
|
+
return out;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Widens an interleaved binary32 buffer (a glTF accessor, a readback) into a
|
|
74
|
+
* tight binary64 one: element `i` of `out` is read from `input[inputOffset +
|
|
75
|
+
* i·inputStride …]`, offset and stride counted in numbers. The element count is
|
|
76
|
+
* `out.length / 2`. `out` and `input` share no memory. O(n).
|
|
77
|
+
*
|
|
78
|
+
* @returns `out`.
|
|
79
|
+
* @throws {RangeError} Unless `out.length` is a multiple of 2, the offset and
|
|
80
|
+
* the stride are non-negative integers (the stride at least 2 from two
|
|
81
|
+
* elements on), the last element lies inside `input`, and `out` and `input`
|
|
82
|
+
* share no memory.
|
|
83
|
+
*/
|
|
84
|
+
export function vec2ArrayWidenStrided(out, input, inputOffset, inputStride) {
|
|
85
|
+
const length = out.length;
|
|
86
|
+
if (length % 2 !== 0) {
|
|
87
|
+
throw new RangeError("vec2ArrayWidenStrided: out must be a multiple of 2 long.");
|
|
88
|
+
}
|
|
89
|
+
assertStridedRange_("vec2ArrayWidenStrided", "input", input.length, inputOffset, inputStride, length / 2, 2);
|
|
90
|
+
if (length > 0 && viewsMayOverlap(out, input)) {
|
|
91
|
+
throw new RangeError("vec2ArrayWidenStrided: out and input must not share memory.");
|
|
92
|
+
}
|
|
93
|
+
for (let index = 0, source = inputOffset; index < length; index += 2, source += inputStride) {
|
|
94
|
+
out[index] = input[source];
|
|
95
|
+
out[index + 1] = input[source + 1];
|
|
96
|
+
}
|
|
97
|
+
return out;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Splits a tight binary64 buffer into two binary32 parts in one pass: for each
|
|
101
|
+
* number `x`, `high = fround(x)` at `out[highOffset + i·outStride …]` and `low
|
|
102
|
+
* = fround(x − high)` at `out[lowOffset + i·outStride …]`, offsets and stride
|
|
103
|
+
* counted in numbers, the other numbers of each stride untouched. `high + low`
|
|
104
|
+
* keeps about 48 bits of `x` (the two-float "split" positions of a vertex
|
|
105
|
+
* buffer, recombined relative to a reference on the GPU). `x − high` is exact
|
|
106
|
+
* in binary64; past the binary32 range `high` is infinite. `out` and `input`
|
|
107
|
+
* share no memory. O(n), no allocation.
|
|
108
|
+
*
|
|
109
|
+
* @returns `out`.
|
|
110
|
+
* @throws {RangeError} Unless `input.length` is a multiple of 2, the offsets
|
|
111
|
+
* and the stride are non-negative integers (the stride at least 2 from two
|
|
112
|
+
* elements on), the two parts of every element lie apart from each other and
|
|
113
|
+
* from the parts of the other elements, the last element fits in `out`, and
|
|
114
|
+
* `out` and `input` share no memory.
|
|
115
|
+
*/
|
|
116
|
+
export function vec2ArraySplitStrided(out, highOffset, lowOffset, outStride, input) {
|
|
117
|
+
const length = input.length;
|
|
118
|
+
if (length % 2 !== 0) {
|
|
119
|
+
throw new RangeError("vec2ArraySplitStrided: input must be a multiple of 2 long.");
|
|
120
|
+
}
|
|
121
|
+
const count = length / 2;
|
|
122
|
+
assertStridedRange_("vec2ArraySplitStrided", "out", out.length, highOffset, outStride, count, 2);
|
|
123
|
+
assertStridedRange_("vec2ArraySplitStrided", "out", out.length, lowOffset, outStride, count, 2);
|
|
124
|
+
if (count > 0) {
|
|
125
|
+
const apart = count === 1
|
|
126
|
+
? Math.abs(lowOffset - highOffset)
|
|
127
|
+
: (((lowOffset - highOffset) % outStride) + outStride) % outStride;
|
|
128
|
+
if (apart < 2 || (count > 1 && outStride - apart < 2)) {
|
|
129
|
+
throw new RangeError("vec2ArraySplitStrided: the high and low parts must not overlap.");
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
if (length > 0 && viewsMayOverlap(out, input)) {
|
|
133
|
+
throw new RangeError("vec2ArraySplitStrided: out and input must not share memory.");
|
|
134
|
+
}
|
|
135
|
+
for (let index = 0, high = highOffset, low = lowOffset; index < length; index += 2, high += outStride, low += outStride) {
|
|
136
|
+
const xx = input[index];
|
|
137
|
+
const hx = Math.fround(xx);
|
|
138
|
+
out[high] = hx;
|
|
139
|
+
out[low] = xx - hx;
|
|
140
|
+
const xy = input[index + 1];
|
|
141
|
+
const hy = Math.fround(xy);
|
|
142
|
+
out[high + 1] = hy;
|
|
143
|
+
out[low + 1] = xy - hy;
|
|
144
|
+
}
|
|
145
|
+
return out;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Narrows `input − origin` to binary32 in one pass, the subtraction in
|
|
149
|
+
* binary64: large coordinates (a map in metres, a time axis in milliseconds)
|
|
150
|
+
* keep their precision relative to a nearby `origin`, where narrowing first
|
|
151
|
+
* loses it. `out` and `input` hold the same number of elements and share no
|
|
152
|
+
* memory (a `Float32Array` and a `Float64Array` over one buffer overlap in
|
|
153
|
+
* bytes, and the narrowing would read what it already wrote). O(n).
|
|
154
|
+
*
|
|
155
|
+
* @returns `out`.
|
|
156
|
+
* @throws {RangeError} Unless `out` and `input` have the same length, a
|
|
157
|
+
* multiple of 2, and share no memory.
|
|
158
|
+
*/
|
|
159
|
+
export function vec2ArrayNarrowRelative(out, input, origin) {
|
|
160
|
+
const length = input.length;
|
|
161
|
+
if (out.length !== length || length % 2 !== 0) {
|
|
162
|
+
throw new RangeError("vec2ArrayNarrowRelative: out and input must have the same length, a multiple of 2.");
|
|
163
|
+
}
|
|
164
|
+
if (length > 0 && viewsMayOverlap(out, input)) {
|
|
165
|
+
throw new RangeError("vec2ArrayNarrowRelative: out and input must not share memory.");
|
|
166
|
+
}
|
|
167
|
+
const ox = origin[0];
|
|
168
|
+
const oy = origin[1];
|
|
169
|
+
for (let index = 0; index < length; index += 2) {
|
|
170
|
+
out[index] = input[index] - ox;
|
|
171
|
+
out[index + 1] = input[index + 1] - oy;
|
|
172
|
+
}
|
|
173
|
+
return out;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* {@link vec2ArrayNarrowRelative} into an interleaved buffer: element `i` goes
|
|
177
|
+
* to `out[outOffset + i·outStride …]`, offset and stride counted in numbers.
|
|
178
|
+
* `out` and `input` share no memory. O(n).
|
|
179
|
+
*
|
|
180
|
+
* @returns `out`.
|
|
181
|
+
* @throws {RangeError} Unless `input.length` is a multiple of 2, `count`, the
|
|
182
|
+
* offset and the stride are non-negative integers (the stride at least 2 from
|
|
183
|
+
* two elements on), the last element fits in `out`, and `out` and `input`
|
|
184
|
+
* share no memory.
|
|
185
|
+
*/
|
|
186
|
+
export function vec2ArrayNarrowRelativeStrided(out, outOffset, outStride, input, origin) {
|
|
187
|
+
const length = input.length;
|
|
188
|
+
if (length % 2 !== 0) {
|
|
189
|
+
throw new RangeError("vec2ArrayNarrowRelativeStrided: input must be a multiple of 2 long.");
|
|
190
|
+
}
|
|
191
|
+
assertStridedRange_("vec2ArrayNarrowRelativeStrided", "out", out.length, outOffset, outStride, length / 2, 2);
|
|
192
|
+
if (length > 0 && viewsMayOverlap(out, input)) {
|
|
193
|
+
throw new RangeError("vec2ArrayNarrowRelativeStrided: out and input must not share memory.");
|
|
194
|
+
}
|
|
195
|
+
const ox = origin[0];
|
|
196
|
+
const oy = origin[1];
|
|
197
|
+
for (let index = 0, target = outOffset; index < length; index += 2, target += outStride) {
|
|
198
|
+
out[target] = input[index] - ox;
|
|
199
|
+
out[target + 1] = input[index + 1] - oy;
|
|
200
|
+
}
|
|
201
|
+
return out;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* The mean Euclidean distance of the elements of `values` to `center`: the
|
|
205
|
+
* spread of a gesture's touch points, for one. Plain arithmetic, so right where
|
|
206
|
+
* the largest difference lies between about `1e−150` and `1e150`. No element
|
|
207
|
+
* gives `NaN`. O(n).
|
|
208
|
+
*
|
|
209
|
+
* @throws {RangeError} Unless `values.length` is a multiple of 2.
|
|
210
|
+
*/
|
|
211
|
+
export function vec2ArrayMeanDistance(values, center) {
|
|
212
|
+
const length = values.length;
|
|
213
|
+
if (length % 2 !== 0) {
|
|
214
|
+
throw new RangeError("vec2ArrayMeanDistance: values must be a multiple of 2 long.");
|
|
215
|
+
}
|
|
216
|
+
const cx = center[0];
|
|
217
|
+
const cy = center[1];
|
|
218
|
+
let total = 0;
|
|
219
|
+
for (let index = 0; index < length; index += 2) {
|
|
220
|
+
const dx = values[index] - cx;
|
|
221
|
+
const dy = values[index + 1] - cy;
|
|
222
|
+
total += Math.sqrt(dx * dx + dy * dy);
|
|
223
|
+
}
|
|
224
|
+
return total / (length / 2);
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Writes `a + b`, element by element, into `out`. One fused pass over tight
|
|
228
|
+
* buffers; the element count is `a.length / 2`. `out` may be `a` or `b`, but
|
|
229
|
+
* not a partially overlapping view of either. O(n).
|
|
230
|
+
*
|
|
231
|
+
* @returns `out`.
|
|
232
|
+
* @throws {RangeError} Unless `out`, `a` and `b` have the same length, a
|
|
233
|
+
* multiple of 2.
|
|
234
|
+
*/
|
|
235
|
+
export function vec2ArrayAdd(out, a, b) {
|
|
236
|
+
const length = a.length;
|
|
237
|
+
if (out.length !== length || b.length !== length || length % 2 !== 0) {
|
|
238
|
+
throw new RangeError("vec2ArrayAdd: out, a and b must have the same length, a multiple of 2.");
|
|
239
|
+
}
|
|
240
|
+
for (let index = 0; index < length; index += 2) {
|
|
241
|
+
out[index] = a[index] + b[index];
|
|
242
|
+
out[index + 1] = a[index + 1] + b[index + 1];
|
|
243
|
+
}
|
|
244
|
+
return out;
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Writes `a − b`, element by element, into `out`. `out` may be `a` or `b`, but
|
|
248
|
+
* not a partially overlapping view. O(n).
|
|
249
|
+
*
|
|
250
|
+
* @returns `out`.
|
|
251
|
+
* @throws {RangeError} Unless `out`, `a` and `b` have the same length, a
|
|
252
|
+
* multiple of 2.
|
|
253
|
+
*/
|
|
254
|
+
export function vec2ArraySubtract(out, a, b) {
|
|
255
|
+
const length = a.length;
|
|
256
|
+
if (out.length !== length || b.length !== length || length % 2 !== 0) {
|
|
257
|
+
throw new RangeError("vec2ArraySubtract: out, a and b must have the same length, a multiple of 2.");
|
|
258
|
+
}
|
|
259
|
+
for (let index = 0; index < length; index += 2) {
|
|
260
|
+
out[index] = a[index] - b[index];
|
|
261
|
+
out[index + 1] = a[index + 1] - b[index + 1];
|
|
262
|
+
}
|
|
263
|
+
return out;
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Writes `a · scalar`, element by element, into `out`. `out` may be `a`, but
|
|
267
|
+
* not a partially overlapping view. O(n).
|
|
268
|
+
*
|
|
269
|
+
* @returns `out`.
|
|
270
|
+
* @throws {RangeError} Unless `out` and `a` have the same length, a multiple of 2.
|
|
271
|
+
*/
|
|
272
|
+
export function vec2ArrayMultiplyScalar(out, a, scalar) {
|
|
273
|
+
const length = a.length;
|
|
274
|
+
if (out.length !== length || length % 2 !== 0) {
|
|
275
|
+
throw new RangeError("vec2ArrayMultiplyScalar: out and a must have the same length, a multiple of 2.");
|
|
276
|
+
}
|
|
277
|
+
for (let index = 0; index < length; index += 2) {
|
|
278
|
+
out[index] = a[index] * scalar;
|
|
279
|
+
out[index + 1] = a[index + 1] * scalar;
|
|
280
|
+
}
|
|
281
|
+
return out;
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Writes `a + b · scale`, element by element, into `out`: two roundings per
|
|
285
|
+
* component, not a fused multiply-add. `out` may be `a` or `b`, but not a
|
|
286
|
+
* partially overlapping view. O(n).
|
|
287
|
+
*
|
|
288
|
+
* @returns `out`.
|
|
289
|
+
* @throws {RangeError} Unless `out`, `a` and `b` have the same length, a
|
|
290
|
+
* multiple of 2.
|
|
291
|
+
*/
|
|
292
|
+
export function vec2ArrayAddScaled(out, a, b, scale) {
|
|
293
|
+
const length = a.length;
|
|
294
|
+
if (out.length !== length || b.length !== length || length % 2 !== 0) {
|
|
295
|
+
throw new RangeError("vec2ArrayAddScaled: out, a and b must have the same length, a multiple of 2.");
|
|
296
|
+
}
|
|
297
|
+
for (let index = 0; index < length; index += 2) {
|
|
298
|
+
out[index] = a[index] + b[index] * scale;
|
|
299
|
+
out[index + 1] = a[index + 1] + b[index + 1] * scale;
|
|
300
|
+
}
|
|
301
|
+
return out;
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Writes `a + offset`, `offset` added to every element, into `out`. `out` may
|
|
305
|
+
* be `a`, but not a partially overlapping view. O(n).
|
|
306
|
+
*
|
|
307
|
+
* @returns `out`.
|
|
308
|
+
* @throws {RangeError} Unless `out` and `a` have the same length, a multiple of 2.
|
|
309
|
+
*/
|
|
310
|
+
export function vec2ArrayTranslate(out, a, offset) {
|
|
311
|
+
const length = a.length;
|
|
312
|
+
if (out.length !== length || length % 2 !== 0) {
|
|
313
|
+
throw new RangeError("vec2ArrayTranslate: out and a must have the same length, a multiple of 2.");
|
|
314
|
+
}
|
|
315
|
+
const ox = offset[0];
|
|
316
|
+
const oy = offset[1];
|
|
317
|
+
for (let index = 0; index < length; index += 2) {
|
|
318
|
+
out[index] = a[index] + ox;
|
|
319
|
+
out[index + 1] = a[index + 1] + oy;
|
|
320
|
+
}
|
|
321
|
+
return out;
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Writes `a + (b − a)·t`, element by element, into `out`, the expression of
|
|
325
|
+
* `@ac-kit/math-scalar`'s `lerp` written inline as {@link vec2Lerp} computes it
|
|
326
|
+
* (a kernel calls no per-component helper): a morph between two buffers, such
|
|
327
|
+
* as a chart transition. A `t` outside `[0, 1]` extrapolates. `out` may be `a`
|
|
328
|
+
* or `b`, but not a partially overlapping view. O(n).
|
|
329
|
+
*
|
|
330
|
+
* @returns `out`.
|
|
331
|
+
* @throws {RangeError} Unless `out`, `a` and `b` have the same length, a
|
|
332
|
+
* multiple of 2.
|
|
333
|
+
*/
|
|
334
|
+
export function vec2ArrayLerp(out, a, b, t) {
|
|
335
|
+
const length = a.length;
|
|
336
|
+
if (out.length !== length || b.length !== length || length % 2 !== 0) {
|
|
337
|
+
throw new RangeError("vec2ArrayLerp: out, a and b must have the same length, a multiple of 2.");
|
|
338
|
+
}
|
|
339
|
+
for (let index = 0; index < length; index += 2) {
|
|
340
|
+
const ax = a[index];
|
|
341
|
+
out[index] = ax + (b[index] - ax) * t;
|
|
342
|
+
const ay = a[index + 1];
|
|
343
|
+
out[index + 1] = ay + (b[index + 1] - ay) * t;
|
|
344
|
+
}
|
|
345
|
+
return out;
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* Writes every element of `a` scaled to unit length into `out`, as
|
|
349
|
+
* {@link vec2Normalize} does for one: a zero element stays zero, and a `NaN`
|
|
350
|
+
* component gives `NaN` throughout that element. Plain arithmetic, right where
|
|
351
|
+
* the largest component lies between about `1e−150` and `1e150`. `out` may be
|
|
352
|
+
* `a`, but not a partially overlapping view. O(n).
|
|
353
|
+
*
|
|
354
|
+
* @returns `out`.
|
|
355
|
+
* @throws {RangeError} Unless `out` and `a` have the same length, a multiple of 2.
|
|
356
|
+
*/
|
|
357
|
+
export function vec2ArrayNormalize(out, a) {
|
|
358
|
+
const length = a.length;
|
|
359
|
+
if (out.length !== length || length % 2 !== 0) {
|
|
360
|
+
throw new RangeError("vec2ArrayNormalize: out and a must have the same length, a multiple of 2.");
|
|
361
|
+
}
|
|
362
|
+
for (let index = 0; index < length; index += 2) {
|
|
363
|
+
const x = a[index];
|
|
364
|
+
const y = a[index + 1];
|
|
365
|
+
const lengthSquared = x * x + y * y;
|
|
366
|
+
const scale = lengthSquared === 0 ? 0 : 1 / Math.sqrt(lengthSquared);
|
|
367
|
+
out[index] = x * scale;
|
|
368
|
+
out[index + 1] = y * scale;
|
|
369
|
+
}
|
|
370
|
+
return out;
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* Writes the mean of the elements of `values` into `out`, in plain arithmetic.
|
|
374
|
+
* No element gives `NaN` in every component. O(n).
|
|
375
|
+
*
|
|
376
|
+
* @returns `out`.
|
|
377
|
+
* @throws {RangeError} Unless `values.length` is a multiple of 2.
|
|
378
|
+
*/
|
|
379
|
+
export function vec2ArrayMean(out, values) {
|
|
380
|
+
const length = values.length;
|
|
381
|
+
if (length % 2 !== 0) {
|
|
382
|
+
throw new RangeError("vec2ArrayMean: values must be a multiple of 2 long.");
|
|
383
|
+
}
|
|
384
|
+
let sumx = 0;
|
|
385
|
+
let sumy = 0;
|
|
386
|
+
for (let index = 0; index < length; index += 2) {
|
|
387
|
+
sumx += values[index];
|
|
388
|
+
sumy += values[index + 1];
|
|
389
|
+
}
|
|
390
|
+
const count = length / 2;
|
|
391
|
+
out[0] = count === 0 ? NaN : sumx / count;
|
|
392
|
+
out[1] = count === 0 ? NaN : sumy / count;
|
|
393
|
+
return out;
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* Writes `Σ wᵢ·vᵢ / Σ wᵢ` into `out`, one weight per element, in plain
|
|
397
|
+
* arithmetic. A zero total weight (no element included) gives `NaN` in every
|
|
398
|
+
* component. See {@link vec2ArrayWeightedMeanPrecise} for cancelling terms.
|
|
399
|
+
* O(n).
|
|
400
|
+
*
|
|
401
|
+
* @returns `out`.
|
|
402
|
+
* @throws {RangeError} Unless `values.length` is a multiple of 2 and
|
|
403
|
+
* `weights.length` is the number of elements.
|
|
404
|
+
*/
|
|
405
|
+
export function vec2ArrayWeightedMean(out, values, weights) {
|
|
406
|
+
const length = values.length;
|
|
407
|
+
if (length % 2 !== 0 || weights.length * 2 !== length) {
|
|
408
|
+
throw new RangeError("vec2ArrayWeightedMean: values must be a multiple of 2 long, with one weight per element.");
|
|
409
|
+
}
|
|
410
|
+
let sumx = 0;
|
|
411
|
+
let sumy = 0;
|
|
412
|
+
let totalWeight = 0;
|
|
413
|
+
for (let index = 0, element = 0; index < length; index += 2, element++) {
|
|
414
|
+
const weight = weights[element];
|
|
415
|
+
sumx += values[index] * weight;
|
|
416
|
+
sumy += values[index + 1] * weight;
|
|
417
|
+
totalWeight += weight;
|
|
418
|
+
}
|
|
419
|
+
out[0] = totalWeight === 0 ? NaN : sumx / totalWeight;
|
|
420
|
+
out[1] = totalWeight === 0 ? NaN : sumy / totalWeight;
|
|
421
|
+
return out;
|
|
422
|
+
}
|
|
423
|
+
/**
|
|
424
|
+
* {@link vec2ArrayWeightedMean} with the numerator and the total weight summed
|
|
425
|
+
* exactly: every product `wᵢ·vᵢ` and the rounding error it dropped (what
|
|
426
|
+
* `@ac-kit/math-scalar`'s `twoProductError` recovers) go into `@ac-kit/core`'s
|
|
427
|
+
* `PreciseSum`, which is exact however the terms cancel (`[1e16, 1, 1e100,
|
|
428
|
+
* −1e100, −1e16]` with unit weights sums to `1`) and settles intermediate
|
|
429
|
+
* overflow. The only roundings left are the final one of each sum and the
|
|
430
|
+
* division. Exact where each product `wᵢ·vᵢ` stays in the normal range, from
|
|
431
|
+
* about `1e−290` to `1e300`: a product that underflows to zero
|
|
432
|
+
* (`Number.MIN_VALUE` with weight `0.5`) or overflows to infinity
|
|
433
|
+
* (`Number.MAX_VALUE` with weight `2`) is lost or infinite before it is summed,
|
|
434
|
+
* as in the plain form. It allocates one `PreciseSum` per component and one for
|
|
435
|
+
* the weights per call, and costs several times the plain form. O(n).
|
|
436
|
+
*
|
|
437
|
+
* @returns `out`.
|
|
438
|
+
* @throws {RangeError} Unless `values.length` is a multiple of 2 and
|
|
439
|
+
* `weights.length` is the number of elements.
|
|
440
|
+
*/
|
|
441
|
+
export function vec2ArrayWeightedMeanPrecise(out, values, weights) {
|
|
442
|
+
const length = values.length;
|
|
443
|
+
if (length % 2 !== 0 || weights.length * 2 !== length) {
|
|
444
|
+
throw new RangeError("vec2ArrayWeightedMeanPrecise: values must be a multiple of 2 long, with one weight per element.");
|
|
445
|
+
}
|
|
446
|
+
const sumx = new PreciseSum();
|
|
447
|
+
const sumy = new PreciseSum();
|
|
448
|
+
const totalWeight = new PreciseSum();
|
|
449
|
+
for (let index = 0, element = 0; index < length; index += 2, element++) {
|
|
450
|
+
const weight = weights[element];
|
|
451
|
+
const valuex = values[index];
|
|
452
|
+
const productx = valuex * weight;
|
|
453
|
+
sumx.add(productx);
|
|
454
|
+
// No error to recover from a product that overflowed or is not a number.
|
|
455
|
+
if (Number.isFinite(productx)) {
|
|
456
|
+
sumx.add(twoProductError(valuex, weight, productx));
|
|
457
|
+
}
|
|
458
|
+
const valuey = values[index + 1];
|
|
459
|
+
const producty = valuey * weight;
|
|
460
|
+
sumy.add(producty);
|
|
461
|
+
// No error to recover from a product that overflowed or is not a number.
|
|
462
|
+
if (Number.isFinite(producty)) {
|
|
463
|
+
sumy.add(twoProductError(valuey, weight, producty));
|
|
464
|
+
}
|
|
465
|
+
totalWeight.add(weight);
|
|
466
|
+
}
|
|
467
|
+
const divisor = totalWeight.value;
|
|
468
|
+
out[0] = divisor === 0 ? NaN : sumx.value / divisor;
|
|
469
|
+
out[1] = divisor === 0 ? NaN : sumy.value / divisor;
|
|
470
|
+
return out;
|
|
471
|
+
}
|
|
472
|
+
//# sourceMappingURL=vec2-array-componentwise.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vec2-array-componentwise.js","sourceRoot":"","sources":["../src/vec2-array-componentwise.ts"],"names":[],"mappings":"AAAA,qHAAqH;AAErH,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAGjD;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAAC,KAAa;IAC5C,aAAa,CAAC,KAAK,EAAE,wBAAwB,EAAE,CAAC,CAAC,CAAC;IAClD,OAAO,IAAI,YAAY,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;AACpC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAClC,MAA+B;IAE/B,MAAM,KAAK,GAAG,IAAI,YAAY,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAClD,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC;QACpD,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAE,CAAC;QAC7B,MAAM,IAAI,GAAG,KAAK,GAAG,CAAC,CAAC;QACvB,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACvB,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IAC5B,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC;AAED;;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CAAE,CAAC;QAClC,MAAM,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAC;QACjC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QACnB,yEAAyE;QACzE,IAAI,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC/B,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;QACrD,CAAC;QACD,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACzB,CAAC;IACD,MAAM,OAAO,GAAG,WAAW,CAAC,KAAK,CAAC;IAClC,GAAG,CAAC,CAAC,CAAC,GAAG,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC;IACpD,GAAG,CAAC,CAAC,CAAC,GAAG,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC;IACpD,OAAO,GAAG,CAAC;AACZ,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { ReadonlyAffine2 } from "./affine2.js";
|
|
2
|
+
import type { ReadonlyMat3x3 } from "./mat3x3.js";
|
|
3
|
+
/**
|
|
4
|
+
* The index of the element of `points` nearest to `(x, y)` among those within
|
|
5
|
+
* `maxDistance`, or `−1` when there is none (an empty buffer, every point
|
|
6
|
+
* farther, a `NaN` distance). A tie goes to the lower index. Distances are
|
|
7
|
+
* compared squared, in plain arithmetic, so the result is right where the
|
|
8
|
+
* coordinate differences lie between about `1e−150` and `1e150`: beyond, the
|
|
9
|
+
* squares overflow (a point at `[1e200, 0]` is never found, whatever
|
|
10
|
+
* `maxDistance`) or lose their digits. A hit test of a chart or a canvas, one
|
|
11
|
+
* pass, no allocation. O(n).
|
|
12
|
+
*
|
|
13
|
+
* @param points A buffer of `Vec2` elements.
|
|
14
|
+
* @param maxDistance The largest distance that counts, `Infinity` by default.
|
|
15
|
+
* @returns The element index (not the offset into `points`).
|
|
16
|
+
* @throws {RangeError} Unless `points.length` is a multiple of 2.
|
|
17
|
+
*/
|
|
18
|
+
export declare function vec2ArrayFindNearestXy(points: Float64Array, x: number, y: number, maxDistance?: number): number;
|
|
19
|
+
/**
|
|
20
|
+
* Writes every point of `input` transformed by the affine transform into `out`,
|
|
21
|
+
* as {@link vec2TransformAffine2} does for one. `out` may be `input`, but not a
|
|
22
|
+
* partially overlapping view. O(n).
|
|
23
|
+
*
|
|
24
|
+
* @returns `out`.
|
|
25
|
+
* @throws {RangeError} Unless `out` and `input` have the same length, a
|
|
26
|
+
* multiple of 2.
|
|
27
|
+
*/
|
|
28
|
+
export declare function vec2ArrayTransformAffine2<T extends Float64Array>(out: T, input: Float64Array, transform: ReadonlyAffine2): T;
|
|
29
|
+
/**
|
|
30
|
+
* {@link vec2ArrayTransformAffine2} over interleaved data: point `i` is read at
|
|
31
|
+
* `input[inputOffset + i·inputStride …]` and written at `out[outOffset +
|
|
32
|
+
* i·outStride …]`, offsets and strides counted in numbers, for `count` points.
|
|
33
|
+
* `out` may be `input` only as the same elements (one array, offset and stride,
|
|
34
|
+
* so each is read before it is written) or as elements that share no memory:
|
|
35
|
+
* any other overlap is refused. O(n).
|
|
36
|
+
*
|
|
37
|
+
* @returns `out`.
|
|
38
|
+
* @throws {RangeError} Unless `count`, the offsets and the strides are
|
|
39
|
+
* non-negative integers, the strides are at least 2 from two points on, the
|
|
40
|
+
* points fit in both arrays, and `out` and `input` overlap in no other way.
|
|
41
|
+
*/
|
|
42
|
+
export declare function vec2ArrayTransformAffine2Strided<T extends Float64Array>(out: T, outOffset: number, outStride: number, input: Float64Array, inputOffset: number, inputStride: number, count: number, transform: ReadonlyAffine2): T;
|
|
43
|
+
/**
|
|
44
|
+
* Writes every point of `input` (as `[x, y, 1]`) transformed by `m` into `out`;
|
|
45
|
+
* the bottom row of `m` is ignored, as {@link vec2TransformMat3x3} does. `out`
|
|
46
|
+
* may be `input`, but not a partially overlapping view. O(n).
|
|
47
|
+
*
|
|
48
|
+
* @returns `out`.
|
|
49
|
+
* @throws {RangeError} Unless `out` and `input` have the same length, a
|
|
50
|
+
* multiple of 2.
|
|
51
|
+
*/
|
|
52
|
+
export declare function vec2ArrayTransformMat3x3<T extends Float64Array>(out: T, input: Float64Array, m: ReadonlyMat3x3): T;
|
|
53
|
+
//# sourceMappingURL=vec2-array.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vec2-array.d.ts","sourceRoot":"","sources":["../src/vec2-array.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,sBAAsB,CACrC,MAAM,EAAE,YAAY,EACpB,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,WAAW,SAAW,GACpB,MAAM,CAoBR;AAED;;;;;;;;GAQG;AACH,wBAAgB,yBAAyB,CAAC,CAAC,SAAS,YAAY,EAC/D,GAAG,EAAE,CAAC,EACN,KAAK,EAAE,YAAY,EACnB,SAAS,EAAE,eAAe,GACxB,CAAC,CAoBH;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,gCAAgC,CAAC,CAAC,SAAS,YAAY,EACtE,GAAG,EAAE,CAAC,EACN,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,YAAY,EACnB,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,eAAe,GACxB,CAAC,CA+CH;AAED;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,CAAC,CAAC,SAAS,YAAY,EAC9D,GAAG,EAAE,CAAC,EACN,KAAK,EAAE,YAAY,EACnB,CAAC,EAAE,cAAc,GACf,CAAC,CAoBH"}
|