@ac-kit/math-geometry 0.3.0 → 0.5.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 +177 -0
- package/README.md +76 -5
- package/dist/_polygon3-cross.d.ts +23 -0
- package/dist/_polygon3-cross.d.ts.map +1 -0
- package/dist/_polygon3-cross.js +418 -0
- package/dist/_polygon3-cross.js.map +1 -0
- package/dist/_polyline-simplify.d.ts +11 -0
- package/dist/_polyline-simplify.d.ts.map +1 -0
- package/dist/_polyline-simplify.js +92 -0
- package/dist/_polyline-simplify.js.map +1 -0
- package/dist/_triangle3-cross.d.ts +66 -0
- package/dist/_triangle3-cross.d.ts.map +1 -0
- package/dist/_triangle3-cross.js +405 -0
- package/dist/_triangle3-cross.js.map +1 -0
- package/dist/convex-hull2.d.ts +26 -0
- package/dist/convex-hull2.d.ts.map +1 -0
- package/dist/convex-hull2.js +88 -0
- package/dist/convex-hull2.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/line2.d.ts +4 -0
- package/dist/line2.d.ts.map +1 -1
- package/dist/line2.js +26 -5
- package/dist/line2.js.map +1 -1
- package/dist/mesh/_index-kernels-u16.d.ts +46 -11
- package/dist/mesh/_index-kernels-u16.d.ts.map +1 -1
- package/dist/mesh/_index-kernels-u16.js +1442 -132
- package/dist/mesh/_index-kernels-u16.js.map +1 -1
- package/dist/mesh/_index-kernels-u32.d.ts +46 -11
- package/dist/mesh/_index-kernels-u32.d.ts.map +1 -1
- package/dist/mesh/_index-kernels-u32.js +1442 -132
- package/dist/mesh/_index-kernels-u32.js.map +1 -1
- package/dist/mesh/mesh3-kernels.d.ts +104 -20
- package/dist/mesh/mesh3-kernels.d.ts.map +1 -1
- package/dist/mesh/mesh3-kernels.js +123 -25
- package/dist/mesh/mesh3-kernels.js.map +1 -1
- package/dist/plane3.d.ts +4 -3
- package/dist/plane3.d.ts.map +1 -1
- package/dist/plane3.js +18 -35
- package/dist/plane3.js.map +1 -1
- package/dist/polygon2.d.ts +76 -4
- package/dist/polygon2.d.ts.map +1 -1
- package/dist/polygon2.js +366 -7
- package/dist/polygon2.js.map +1 -1
- package/dist/polygon3.d.ts +19 -3
- package/dist/polygon3.d.ts.map +1 -1
- package/dist/polygon3.js +40 -16
- package/dist/polygon3.js.map +1 -1
- package/dist/polyline2.d.ts +20 -0
- package/dist/polyline2.d.ts.map +1 -1
- package/dist/polyline2.js +25 -0
- package/dist/polyline2.js.map +1 -1
- package/dist/polyline3.d.ts +17 -0
- package/dist/polyline3.d.ts.map +1 -1
- package/dist/polyline3.js +22 -0
- package/dist/polyline3.js.map +1 -1
- package/dist/predicates2.d.ts +51 -0
- package/dist/predicates2.d.ts.map +1 -0
- package/dist/predicates2.js +172 -0
- package/dist/predicates2.js.map +1 -0
- package/dist/quadtree.d.ts +40 -23
- package/dist/quadtree.d.ts.map +1 -1
- package/dist/quadtree.js +196 -119
- package/dist/quadtree.js.map +1 -1
- package/dist/segment2.d.ts +6 -1
- package/dist/segment2.d.ts.map +1 -1
- package/dist/segment2.js +20 -4
- package/dist/segment2.js.map +1 -1
- package/dist/triangle3.d.ts +20 -1
- package/dist/triangle3.d.ts.map +1 -1
- package/dist/triangle3.js +38 -18
- package/dist/triangle3.js.map +1 -1
- package/package.json +8 -8
|
@@ -0,0 +1,405 @@
|
|
|
1
|
+
import { binaryExponentAt, scaleByPowerOfTwoInPlace } from "@ac-kit/core";
|
|
2
|
+
import { DotExactAccumulator, twoProductInRangeInPlace, twoSumInPlace, } from "@ac-kit/math-scalar";
|
|
3
|
+
/** The unit roundoff, 2^−53. */
|
|
4
|
+
export const UNIT_ROUNDOFF_ = 2 ** -53;
|
|
5
|
+
/**
|
|
6
|
+
* The bound of the doubled-precision path's error per component, in units of u²
|
|
7
|
+
* times the magnitude of its two products (u = 2^−53). The parts it adds are
|
|
8
|
+
* each below 2u of those products, and every one of the dozen roundings of the
|
|
9
|
+
* low parts is below u of what it rounds; the parts it drops (the products of
|
|
10
|
+
* two low parts) are below u². Twice what that adds up to.
|
|
11
|
+
*/
|
|
12
|
+
const LOW_PART_BOUND_ = 32 * UNIT_ROUNDOFF_ * UNIT_ROUNDOFF_;
|
|
13
|
+
/**
|
|
14
|
+
* An absolute bound, far above them, on what the doubled-precision path loses,
|
|
15
|
+
* in its scaled units, where a scaled edge component falls below 2^−1022 or a
|
|
16
|
+
* product below 2^−969, so that its error is no longer exact or underflows:
|
|
17
|
+
* every product there is below 4, so a component this small beside them goes to
|
|
18
|
+
* the exact path.
|
|
19
|
+
*/
|
|
20
|
+
export const UNDERFLOW_BOUND_ = 2 ** -1000;
|
|
21
|
+
/** An exponent below every one a component can have: "no component". */
|
|
22
|
+
export const NONE_ = -8192;
|
|
23
|
+
/**
|
|
24
|
+
* From this magnitude up, TwoProduct's error is exact
|
|
25
|
+
* (`twoProductInRangeInPlace`).
|
|
26
|
+
*/
|
|
27
|
+
const EXACT_PRODUCT_MIN_ = 2 ** -969;
|
|
28
|
+
/**
|
|
29
|
+
* The edge components the doubled-precision path takes unscaled: products of
|
|
30
|
+
* them lie below 2^402, and their bounds hold in absolute terms.
|
|
31
|
+
*/
|
|
32
|
+
export const PLAIN_EDGE_MIN_ = 2 ** -200;
|
|
33
|
+
export const PLAIN_EDGE_MAX_ = 2 ** 200;
|
|
34
|
+
/**
|
|
35
|
+
* The exponents of the largest component when the product is written unscaled
|
|
36
|
+
* (k = 0): `[2^−400, 2^402)`, the range the vertex-normal and area kernels sum
|
|
37
|
+
* and square as they come.
|
|
38
|
+
*/
|
|
39
|
+
const PLAIN_EXPONENT_MIN_ = -400;
|
|
40
|
+
const PLAIN_EXPONENT_MAX_ = 401;
|
|
41
|
+
export const PLAIN_MIN_ = 2 ** PLAIN_EXPONENT_MIN_;
|
|
42
|
+
export const PLAIN_MAX_ = 2 ** (PLAIN_EXPONENT_MAX_ + 1);
|
|
43
|
+
/** {@link plainCross_}'s bound per unit of its products, 3.001u. */
|
|
44
|
+
export const PLAIN_BOUND_ = 3.001 * UNIT_ROUNDOFF_;
|
|
45
|
+
/** {@link plainCross_}'s absolute bound on what products lose underflowing. */
|
|
46
|
+
export const PLAIN_UNDERFLOW_ = 2 ** -1070;
|
|
47
|
+
/**
|
|
48
|
+
* {@link plainCross_}'s accuracy: every bound within 2^−50 of the largest
|
|
49
|
+
* component, so that the unit normal stays within 2^−48 of the exact one.
|
|
50
|
+
*/
|
|
51
|
+
export const PLAIN_ACCURACY_ = 2 ** -50;
|
|
52
|
+
/**
|
|
53
|
+
* Edges `b − a` and `c − a` as TwoSum leaves them, per axis: the rounded
|
|
54
|
+
* difference then its exact error (0–1, 2–3 for x; 4–7 for y; 8–11 for z, `b`
|
|
55
|
+
* first), then scaled by the axis's power of two.
|
|
56
|
+
*/
|
|
57
|
+
const EDGES_ = new Float64Array(12);
|
|
58
|
+
/** Per axis, the power of two its scaled edges are to be multiplied by. */
|
|
59
|
+
const AXIS_EXPONENTS_ = new Int32Array(3);
|
|
60
|
+
/** Per edge component (`b` then `c`, per axis), 1 when it is exactly 0. */
|
|
61
|
+
const ZEROS_ = new Uint8Array(6);
|
|
62
|
+
/**
|
|
63
|
+
* Per component, its two products `p` and `q` as TwoProduct leaves them (the
|
|
64
|
+
* rounded product then its error), then their difference as TwoSum leaves it.
|
|
65
|
+
*/
|
|
66
|
+
const PRODUCTS_ = new Float64Array(6);
|
|
67
|
+
/** Per component, the bound {@link doubledCross_} settled it with. */
|
|
68
|
+
const BOUNDS_ = new Float64Array(3);
|
|
69
|
+
/** The components, each `COMPONENTS_[i] · 2^EXPONENTS_[i]`. */
|
|
70
|
+
const COMPONENTS_ = new Float64Array(3);
|
|
71
|
+
const EXPONENTS_ = new Int32Array(3);
|
|
72
|
+
/**
|
|
73
|
+
* The exact path's factors: per component, the six coordinate products whose
|
|
74
|
+
* sum it is.
|
|
75
|
+
*/
|
|
76
|
+
const LEFT_ = new Float64Array(6);
|
|
77
|
+
const RIGHT_ = new Float64Array(6);
|
|
78
|
+
/** An exact component, as significand and exponent. */
|
|
79
|
+
const SCALED_ = new Float64Array(2);
|
|
80
|
+
const EXACT_ = new DotExactAccumulator();
|
|
81
|
+
/**
|
|
82
|
+
* Writes the cross product `(b − a) × (c − a)` of the triangle whose corners
|
|
83
|
+
* `a`, `b` and `c` are `corners[0–2]`, `[3–5]` and `[6–8]` into `out` as `[x,
|
|
84
|
+
* y, z, k]`, the product being `(x, y, z) · 2^k`. Every component lies within
|
|
85
|
+
* 2^−49 of the largest component of the exact value, for any finite corners:
|
|
86
|
+
* `[0, 0, 0, 0]` exactly when the exact product is zero (a degenerate
|
|
87
|
+
* triangle), a component +0 where the exact one is 0, and one with the exact
|
|
88
|
+
* one's sign wherever that bound cannot reach 0. A component nonzero but within
|
|
89
|
+
* the bound may round to a zero of either sign (the k = 0 form flushes whatever
|
|
90
|
+
* lies below the smallest double, however large its ratio to the largest
|
|
91
|
+
* component). k is 0 when the largest component lies in `[2^−400, 2^402)`;
|
|
92
|
+
* otherwise the largest lies in `[1, 2)`. A corner that is not finite gives
|
|
93
|
+
* `NaN`s.
|
|
94
|
+
*
|
|
95
|
+
* Three paths, each taken only where the one before cannot settle every
|
|
96
|
+
* component. The plain cross product, with a rigorous bound (a triangle not far
|
|
97
|
+
* from right-angled at `a`, edges up to 2^200). Then doubled precision: the
|
|
98
|
+
* edges split exactly by TwoSum and scaled per axis by the power of two that
|
|
99
|
+
* brings the axis's longest to [1, 2) where an edge leaves [2^−200, 2^200] (the
|
|
100
|
+
* product is bilinear: component x takes the scales of y and z), each product
|
|
101
|
+
* of their high parts by TwoProduct, the rest summed, with a rigorous bound on
|
|
102
|
+
* what is lost. Last, where that bound leaves a sign or the last bits of the
|
|
103
|
+
* largest component in doubt (a triangle almost degenerate, a component almost
|
|
104
|
+
* 0 or below 2^−1000 of the products it is the difference of, or an edge whose
|
|
105
|
+
* difference overflows), each component summed exactly (Kulisch's long
|
|
106
|
+
* accumulator, over the six products of coordinates it expands to) and rounded
|
|
107
|
+
* once, at any exponent. Allocates nothing.
|
|
108
|
+
*/
|
|
109
|
+
export function triangle3Cross_(out, corners) {
|
|
110
|
+
for (let index = 0; index < 9; index++) {
|
|
111
|
+
const value = corners[index];
|
|
112
|
+
if (value - value !== 0) {
|
|
113
|
+
out[0] = Number.NaN;
|
|
114
|
+
out[1] = Number.NaN;
|
|
115
|
+
out[2] = Number.NaN;
|
|
116
|
+
out[3] = 0;
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
if (plainCross_(out, corners)) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
const edges = EDGES_;
|
|
124
|
+
let isWide = false;
|
|
125
|
+
let isPlain = true;
|
|
126
|
+
for (let axis = 0; axis < 3; axis++) {
|
|
127
|
+
const at = 4 * axis;
|
|
128
|
+
edges[at] = corners[3 + axis];
|
|
129
|
+
edges[at + 1] = -corners[axis];
|
|
130
|
+
twoSumInPlace(edges, at);
|
|
131
|
+
edges[at + 2] = corners[6 + axis];
|
|
132
|
+
edges[at + 3] = -corners[axis];
|
|
133
|
+
twoSumInPlace(edges, at + 2);
|
|
134
|
+
const longest = Math.max(Math.abs(edges[at]), Math.abs(edges[at + 2]));
|
|
135
|
+
// Zero before scaling, where a component far below the longest flushes.
|
|
136
|
+
ZEROS_[2 * axis] = edges[at] === 0 ? 1 : 0;
|
|
137
|
+
ZEROS_[2 * axis + 1] = edges[at + 2] === 0 ? 1 : 0;
|
|
138
|
+
// A difference that overflows leaves the doubled path to the exact one.
|
|
139
|
+
isWide ||= longest === Number.POSITIVE_INFINITY;
|
|
140
|
+
isPlain &&=
|
|
141
|
+
longest === 0 ||
|
|
142
|
+
(longest >= PLAIN_EDGE_MIN_ && longest <= PLAIN_EDGE_MAX_);
|
|
143
|
+
}
|
|
144
|
+
if (isPlain) {
|
|
145
|
+
AXIS_EXPONENTS_.fill(0);
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
// Each axis's longest edge component brought to [1, 2): exact for the
|
|
149
|
+
// components but where one falls below 2^−1022.
|
|
150
|
+
for (let axis = 0; axis < 3; axis++) {
|
|
151
|
+
const at = 4 * axis;
|
|
152
|
+
const ab = Math.abs(edges[at]);
|
|
153
|
+
// Read from the array: a double passed to a call the engine does not
|
|
154
|
+
// inline is boxed.
|
|
155
|
+
AXIS_EXPONENTS_[axis] =
|
|
156
|
+
ab >= Math.abs(edges[at + 2])
|
|
157
|
+
? ab > 0
|
|
158
|
+
? binaryExponentAt(edges, at)
|
|
159
|
+
: 0
|
|
160
|
+
: binaryExponentAt(edges, at + 2);
|
|
161
|
+
}
|
|
162
|
+
for (let part = 0; part < 12; part++) {
|
|
163
|
+
// `0 - e`, not `-e`: −0 is a double, which a call boxes.
|
|
164
|
+
scaleByPowerOfTwoInPlace(edges, part, 0 - AXIS_EXPONENTS_[part >> 2]);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
if (isWide || !doubledCross_(isPlain)) {
|
|
168
|
+
exactCross_(corners);
|
|
169
|
+
writeComponents_(out);
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
if (isPlain) {
|
|
173
|
+
const largest = Math.max(Math.abs(COMPONENTS_[0]), Math.abs(COMPONENTS_[1]), Math.abs(COMPONENTS_[2]));
|
|
174
|
+
if (largest >= PLAIN_MIN_ && largest < PLAIN_MAX_) {
|
|
175
|
+
out[0] = COMPONENTS_[0];
|
|
176
|
+
out[1] = COMPONENTS_[1];
|
|
177
|
+
out[2] = COMPONENTS_[2];
|
|
178
|
+
out[3] = 0;
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
writeComponents_(out);
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* The plain path of {@link triangle3Cross_}: the cross product in plain
|
|
186
|
+
* arithmetic, written into `out` with k = 0 when a rigorous bound settles every
|
|
187
|
+
* sign and puts every component within 2^−50 of the largest (and the largest in
|
|
188
|
+
* the unscaled range): a triangle whose angle at `a` is not far from a right
|
|
189
|
+
* one, with edges up to 2^200. Returns whether it did.
|
|
190
|
+
*
|
|
191
|
+
* Each edge rounds by u (u = 2^−53), each product by u more: a product is
|
|
192
|
+
* within 3.001u of its exact value, and a component within that of its two
|
|
193
|
+
* products plus u of itself (Higham, "Accuracy and Stability of Numerical
|
|
194
|
+
* Algorithms", §3.1), plus an absolute 2^−1070 for products that underflow.
|
|
195
|
+
*/
|
|
196
|
+
function plainCross_(out, corners) {
|
|
197
|
+
const abX = corners[3] - corners[0];
|
|
198
|
+
const abY = corners[4] - corners[1];
|
|
199
|
+
const abZ = corners[5] - corners[2];
|
|
200
|
+
const acX = corners[6] - corners[0];
|
|
201
|
+
const acY = corners[7] - corners[1];
|
|
202
|
+
const acZ = corners[8] - corners[2];
|
|
203
|
+
const longest = Math.max(Math.abs(abX), Math.abs(abY), Math.abs(abZ), Math.abs(acX), Math.abs(acY), Math.abs(acZ));
|
|
204
|
+
if (!(longest <= PLAIN_EDGE_MAX_)) {
|
|
205
|
+
return false;
|
|
206
|
+
}
|
|
207
|
+
const p0 = abY * acZ;
|
|
208
|
+
const q0 = abZ * acY;
|
|
209
|
+
const p1 = abZ * acX;
|
|
210
|
+
const q1 = abX * acZ;
|
|
211
|
+
const p2 = abX * acY;
|
|
212
|
+
const q2 = abY * acX;
|
|
213
|
+
const crossX = p0 - q0;
|
|
214
|
+
const crossY = p1 - q1;
|
|
215
|
+
const crossZ = p2 - q2;
|
|
216
|
+
const largest = Math.max(Math.abs(crossX), Math.abs(crossY), Math.abs(crossZ));
|
|
217
|
+
if (!(largest >= PLAIN_MIN_)) {
|
|
218
|
+
return false;
|
|
219
|
+
}
|
|
220
|
+
const limit = largest * PLAIN_ACCURACY_;
|
|
221
|
+
const boundX = PLAIN_BOUND_ * (Math.abs(p0) + Math.abs(q0)) + PLAIN_UNDERFLOW_;
|
|
222
|
+
const boundY = PLAIN_BOUND_ * (Math.abs(p1) + Math.abs(q1)) + PLAIN_UNDERFLOW_;
|
|
223
|
+
const boundZ = PLAIN_BOUND_ * (Math.abs(p2) + Math.abs(q2)) + PLAIN_UNDERFLOW_;
|
|
224
|
+
// Each component settled: exactly 0 (an edge component 0 in each product,
|
|
225
|
+
// exact), or its sign out of the bound's reach, and the bound within the
|
|
226
|
+
// accuracy limit.
|
|
227
|
+
if (((abY === 0 || acZ === 0) && (abZ === 0 || acY === 0)
|
|
228
|
+
? crossX === 0
|
|
229
|
+
: Math.abs(crossX) * (1 - 2 * UNIT_ROUNDOFF_) > boundX &&
|
|
230
|
+
boundX <= limit) &&
|
|
231
|
+
((abZ === 0 || acX === 0) && (abX === 0 || acZ === 0)
|
|
232
|
+
? crossY === 0
|
|
233
|
+
: Math.abs(crossY) * (1 - 2 * UNIT_ROUNDOFF_) > boundY &&
|
|
234
|
+
boundY <= limit) &&
|
|
235
|
+
((abX === 0 || acY === 0) && (abY === 0 || acX === 0)
|
|
236
|
+
? crossZ === 0
|
|
237
|
+
: Math.abs(crossZ) * (1 - 2 * UNIT_ROUNDOFF_) > boundZ && boundZ <= limit)) {
|
|
238
|
+
// A zero component is +0: `0 − 0`, or `−0 − −0`, which is +0 too.
|
|
239
|
+
out[0] = crossX + 0;
|
|
240
|
+
out[1] = crossY + 0;
|
|
241
|
+
out[2] = crossZ + 0;
|
|
242
|
+
out[3] = 0;
|
|
243
|
+
return true;
|
|
244
|
+
}
|
|
245
|
+
return false;
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* The doubled-precision path of {@link triangle3Cross_}, from `EDGES_` scaled
|
|
249
|
+
* per axis: writes each component into `COMPONENTS_` and its exponent into
|
|
250
|
+
* `EXPONENTS_` and returns whether its bound settles them. Every product of
|
|
251
|
+
* scaled edges is below 4, where its bound is stated.
|
|
252
|
+
*/
|
|
253
|
+
function doubledCross_(isPlain) {
|
|
254
|
+
const edges = EDGES_;
|
|
255
|
+
const products = PRODUCTS_;
|
|
256
|
+
let top = NONE_;
|
|
257
|
+
for (let component = 0; component < 3; component++) {
|
|
258
|
+
// Component x is ab_y · ac_z − ab_z · ac_y, and so on cyclically.
|
|
259
|
+
const firstAxis = (component + 1) % 3;
|
|
260
|
+
const secondAxis = (component + 2) % 3;
|
|
261
|
+
const first = 4 * firstAxis;
|
|
262
|
+
const second = 4 * secondAxis;
|
|
263
|
+
const abFirst = edges[first];
|
|
264
|
+
const abFirstLow = edges[first + 1];
|
|
265
|
+
const acFirst = edges[first + 2];
|
|
266
|
+
const acFirstLow = edges[first + 3];
|
|
267
|
+
const abSecond = edges[second];
|
|
268
|
+
const abSecondLow = edges[second + 1];
|
|
269
|
+
const acSecond = edges[second + 2];
|
|
270
|
+
const acSecondLow = edges[second + 3];
|
|
271
|
+
EXPONENTS_[component] =
|
|
272
|
+
AXIS_EXPONENTS_[firstAxis] + AXIS_EXPONENTS_[secondAxis];
|
|
273
|
+
if ((ZEROS_[2 * firstAxis] === 1 || ZEROS_[2 * secondAxis + 1] === 1) &&
|
|
274
|
+
(ZEROS_[2 * secondAxis] === 1 || ZEROS_[2 * firstAxis + 1] === 1)) {
|
|
275
|
+
// An edge component is exactly 0 in each product: so is the component.
|
|
276
|
+
COMPONENTS_[component] = 0;
|
|
277
|
+
BOUNDS_[component] = 0;
|
|
278
|
+
continue;
|
|
279
|
+
}
|
|
280
|
+
products[0] = abFirst;
|
|
281
|
+
products[1] = acSecond;
|
|
282
|
+
twoProductInRangeInPlace(products, 0);
|
|
283
|
+
products[2] = abSecond;
|
|
284
|
+
products[3] = acFirst;
|
|
285
|
+
twoProductInRangeInPlace(products, 2);
|
|
286
|
+
const magnitude = Math.abs(products[0]) + Math.abs(products[2]);
|
|
287
|
+
if (isPlain &&
|
|
288
|
+
products[0] === products[2] &&
|
|
289
|
+
products[1] === products[3] &&
|
|
290
|
+
abFirstLow === 0 &&
|
|
291
|
+
acFirstLow === 0 &&
|
|
292
|
+
abSecondLow === 0 &&
|
|
293
|
+
acSecondLow === 0 &&
|
|
294
|
+
Math.abs(products[0]) >= EXACT_PRODUCT_MIN_) {
|
|
295
|
+
// Exact edges and exact products that cancel: exactly 0.
|
|
296
|
+
COMPONENTS_[component] = 0;
|
|
297
|
+
BOUNDS_[component] = 0;
|
|
298
|
+
continue;
|
|
299
|
+
}
|
|
300
|
+
const lowParts = products[1] - products[3];
|
|
301
|
+
products[4] = products[0];
|
|
302
|
+
products[5] = -products[2];
|
|
303
|
+
twoSumInPlace(products, 4);
|
|
304
|
+
const cross = abFirst * acSecondLow +
|
|
305
|
+
abFirstLow * acSecond -
|
|
306
|
+
(abSecond * acFirstLow + abSecondLow * acFirst);
|
|
307
|
+
const value = products[4] + (products[5] + lowParts + cross);
|
|
308
|
+
const bound = LOW_PART_BOUND_ * magnitude + UNDERFLOW_BOUND_;
|
|
309
|
+
// The sign is settled when the bound, and the last rounding, cannot
|
|
310
|
+
// reach 0.
|
|
311
|
+
if (!(Math.abs(value) * (1 - 4 * UNIT_ROUNDOFF_) > bound)) {
|
|
312
|
+
return false;
|
|
313
|
+
}
|
|
314
|
+
COMPONENTS_[component] = value;
|
|
315
|
+
BOUNDS_[component] = bound;
|
|
316
|
+
if (!isPlain) {
|
|
317
|
+
top = Math.max(top, binaryExponentAt(COMPONENTS_, component) + EXPONENTS_[component]);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
if (isPlain) {
|
|
321
|
+
// Unscaled: every bound below 2^−54 of the largest component, and the
|
|
322
|
+
// rounding of the sum below 2^−53 of the component itself.
|
|
323
|
+
const largest = Math.max(Math.abs(COMPONENTS_[0]), Math.abs(COMPONENTS_[1]), Math.abs(COMPONENTS_[2]));
|
|
324
|
+
const limit = largest * 2 ** -54;
|
|
325
|
+
return ((COMPONENTS_[0] === 0 || BOUNDS_[0] <= limit) &&
|
|
326
|
+
(COMPONENTS_[1] === 0 || BOUNDS_[1] <= limit) &&
|
|
327
|
+
(COMPONENTS_[2] === 0 || BOUNDS_[2] <= limit));
|
|
328
|
+
}
|
|
329
|
+
// The same against the exponents.
|
|
330
|
+
for (let component = 0; component < 3; component++) {
|
|
331
|
+
if (COMPONENTS_[component] !== 0 &&
|
|
332
|
+
binaryExponentAt(BOUNDS_, component) + EXPONENTS_[component] > top - 54) {
|
|
333
|
+
return false;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
return true;
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* The exact path of {@link triangle3Cross_}: each component as the exact sum of
|
|
340
|
+
* the six products of coordinates it expands to (`x = a_y (b_z − c_z) + b_y
|
|
341
|
+
* (c_z − a_z) + c_y (a_z − b_z)`, cyclically), rounded once to 53 bits at any
|
|
342
|
+
* exponent, then brought to the exponent of the largest.
|
|
343
|
+
*/
|
|
344
|
+
function exactCross_(corners) {
|
|
345
|
+
const left = LEFT_;
|
|
346
|
+
const right = RIGHT_;
|
|
347
|
+
const scaled = SCALED_;
|
|
348
|
+
for (let component = 0; component < 3; component++) {
|
|
349
|
+
const first = (component + 1) % 3;
|
|
350
|
+
const second = (component + 2) % 3;
|
|
351
|
+
const aFirst = corners[first];
|
|
352
|
+
const bFirst = corners[3 + first];
|
|
353
|
+
const cFirst = corners[6 + first];
|
|
354
|
+
const aSecond = corners[second];
|
|
355
|
+
const bSecond = corners[3 + second];
|
|
356
|
+
const cSecond = corners[6 + second];
|
|
357
|
+
left[0] = aFirst;
|
|
358
|
+
right[0] = bSecond;
|
|
359
|
+
left[1] = -aFirst;
|
|
360
|
+
right[1] = cSecond;
|
|
361
|
+
left[2] = bFirst;
|
|
362
|
+
right[2] = cSecond;
|
|
363
|
+
left[3] = -bFirst;
|
|
364
|
+
right[3] = aSecond;
|
|
365
|
+
left[4] = cFirst;
|
|
366
|
+
right[4] = aSecond;
|
|
367
|
+
left[5] = -cFirst;
|
|
368
|
+
right[5] = bSecond;
|
|
369
|
+
EXACT_.reset();
|
|
370
|
+
EXACT_.addProducts(left, right);
|
|
371
|
+
EXACT_.writeScaled(scaled, 0);
|
|
372
|
+
COMPONENTS_[component] = scaled[0];
|
|
373
|
+
EXPONENTS_[component] = scaled[1];
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* Writes the product `components[i] · 2^exponents[i]` into `out` as `[x, y, z,
|
|
378
|
+
* k]`: k = 0, the components unscaled, when the largest lies in `[2^−400,
|
|
379
|
+
* 2^402)`; otherwise the components scaled so that the largest lies in `[1,
|
|
380
|
+
* 2)`, and k the power of two that undoes it. Zeros for a zero product.
|
|
381
|
+
*/
|
|
382
|
+
export function writeScaledComponents_(out, components, exponents) {
|
|
383
|
+
let top = NONE_;
|
|
384
|
+
for (let component = 0; component < 3; component++) {
|
|
385
|
+
const value = components[component];
|
|
386
|
+
if (value !== 0) {
|
|
387
|
+
top = Math.max(top, binaryExponentAt(components, component) + exponents[component]);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
const base = top === NONE_ || (top >= PLAIN_EXPONENT_MIN_ && top <= PLAIN_EXPONENT_MAX_)
|
|
391
|
+
? 0
|
|
392
|
+
: top;
|
|
393
|
+
out[3] = base;
|
|
394
|
+
for (let component = 0; component < 3; component++) {
|
|
395
|
+
out[component] = components[component];
|
|
396
|
+
const shift = exponents[component] - base;
|
|
397
|
+
if (shift !== 0 && out[component] !== 0) {
|
|
398
|
+
scaleByPowerOfTwoInPlace(out, component, shift);
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
function writeComponents_(out) {
|
|
403
|
+
writeScaledComponents_(out, COMPONENTS_, EXPONENTS_);
|
|
404
|
+
}
|
|
405
|
+
//# sourceMappingURL=_triangle3-cross.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_triangle3-cross.js","sourceRoot":"","sources":["../src/_triangle3-cross.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAC1E,OAAO,EACN,mBAAmB,EACnB,wBAAwB,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C;QACpD,GAAG,CAAC,SAAS,CAAC,GAAG,UAAU,CAAC,SAAS,CAAE,CAAC;QACxC,MAAM,KAAK,GAAG,SAAS,CAAC,SAAS,CAAE,GAAG,IAAI,CAAC;QAC3C,IAAI,KAAK,KAAK,CAAC,IAAI,GAAG,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;YACzC,wBAAwB,CAAC,GAAG,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;QACjD,CAAC;IACF,CAAC;AACF,CAAC;AAED,SAAS,gBAAgB,CAAC,GAAiB;IAC1C,sBAAsB,CAAC,GAAG,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC;AACtD,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The convex hull of a set of points, as the indices of its vertices in
|
|
3
|
+
* counter-clockwise order (y up), starting from the lexicographically smallest
|
|
4
|
+
* point (least x, then least y) — Andrew's monotone chain, O(n log n).
|
|
5
|
+
*
|
|
6
|
+
* Points are pairs in `coordinates`, `[x₀, y₀, x₁, y₁, …]`; index `i` is the
|
|
7
|
+
* point at `coordinates[2i]`. Every turn is decided by {@link orient2}, so the
|
|
8
|
+
* hull is exact: no vertex is dropped or kept on a rounded sign, and points
|
|
9
|
+
* exactly on an edge are left out (the hull has no collinear vertices).
|
|
10
|
+
* Duplicates count once, the first in sort order. Degenerate sets give short
|
|
11
|
+
* hulls: no point gives none, equal points one, collinear points their two
|
|
12
|
+
* extremes. Allocates the index order and the result.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* convexHull2(new Float64Array([0, 0, 2, 0, 1, 1, 2, 2, 0, 2, 1, 0]));
|
|
17
|
+
* // Uint32Array [0, 1, 3, 4] — (1, 1) is inside, (1, 0) on an edge
|
|
18
|
+
* ```;
|
|
19
|
+
*
|
|
20
|
+
* @param coordinates The points, as interleaved `x, y` pairs.
|
|
21
|
+
* @returns The hull's vertex indices, counter-clockwise.
|
|
22
|
+
* @throws {RangeError} When `coordinates` has an odd length, or a coordinate is
|
|
23
|
+
* `NaN` or infinite.
|
|
24
|
+
*/
|
|
25
|
+
export declare function convexHull2(coordinates: ArrayLike<number>): Uint32Array;
|
|
26
|
+
//# sourceMappingURL=convex-hull2.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convex-hull2.d.ts","sourceRoot":"","sources":["../src/convex-hull2.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,WAAW,CAAC,WAAW,EAAE,SAAS,CAAC,MAAM,CAAC,GAAG,WAAW,CAyEvE"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { orient2 } from "./predicates2.js";
|
|
2
|
+
/**
|
|
3
|
+
* The convex hull of a set of points, as the indices of its vertices in
|
|
4
|
+
* counter-clockwise order (y up), starting from the lexicographically smallest
|
|
5
|
+
* point (least x, then least y) — Andrew's monotone chain, O(n log n).
|
|
6
|
+
*
|
|
7
|
+
* Points are pairs in `coordinates`, `[x₀, y₀, x₁, y₁, …]`; index `i` is the
|
|
8
|
+
* point at `coordinates[2i]`. Every turn is decided by {@link orient2}, so the
|
|
9
|
+
* hull is exact: no vertex is dropped or kept on a rounded sign, and points
|
|
10
|
+
* exactly on an edge are left out (the hull has no collinear vertices).
|
|
11
|
+
* Duplicates count once, the first in sort order. Degenerate sets give short
|
|
12
|
+
* hulls: no point gives none, equal points one, collinear points their two
|
|
13
|
+
* extremes. Allocates the index order and the result.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* convexHull2(new Float64Array([0, 0, 2, 0, 1, 1, 2, 2, 0, 2, 1, 0]));
|
|
18
|
+
* // Uint32Array [0, 1, 3, 4] — (1, 1) is inside, (1, 0) on an edge
|
|
19
|
+
* ```;
|
|
20
|
+
*
|
|
21
|
+
* @param coordinates The points, as interleaved `x, y` pairs.
|
|
22
|
+
* @returns The hull's vertex indices, counter-clockwise.
|
|
23
|
+
* @throws {RangeError} When `coordinates` has an odd length, or a coordinate is
|
|
24
|
+
* `NaN` or infinite.
|
|
25
|
+
*/
|
|
26
|
+
export function convexHull2(coordinates) {
|
|
27
|
+
if (coordinates.length % 2 !== 0) {
|
|
28
|
+
throw new RangeError(`convexHull2: ${coordinates.length} coordinates do not make whole points`);
|
|
29
|
+
}
|
|
30
|
+
const count = coordinates.length / 2;
|
|
31
|
+
for (let index = 0; index < coordinates.length; index++) {
|
|
32
|
+
const coordinate = coordinates[index];
|
|
33
|
+
if (coordinate - coordinate !== 0) {
|
|
34
|
+
throw new RangeError(`convexHull2: coordinate ${index} is ${coordinate}, not finite`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const order = new Uint32Array(count);
|
|
38
|
+
for (let index = 0; index < count; index++) {
|
|
39
|
+
order[index] = index;
|
|
40
|
+
}
|
|
41
|
+
order.sort((a, b) => coordinates[2 * a] - coordinates[2 * b] ||
|
|
42
|
+
coordinates[2 * a + 1] - coordinates[2 * b + 1] ||
|
|
43
|
+
a - b);
|
|
44
|
+
// Drop exact duplicates, keeping the first of each run.
|
|
45
|
+
let unique = 0;
|
|
46
|
+
for (let index = 0; index < count; index++) {
|
|
47
|
+
const point = order[index];
|
|
48
|
+
if (unique > 0) {
|
|
49
|
+
const previous = order[unique - 1];
|
|
50
|
+
if (coordinates[2 * point] === coordinates[2 * previous] &&
|
|
51
|
+
coordinates[2 * point + 1] === coordinates[2 * previous + 1]) {
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
order[unique++] = point;
|
|
56
|
+
}
|
|
57
|
+
if (unique <= 2) {
|
|
58
|
+
return order.slice(0, unique);
|
|
59
|
+
}
|
|
60
|
+
// Lower chain left to right, then upper chain right to left, into one
|
|
61
|
+
// stack of at most 2n entries.
|
|
62
|
+
const hull = new Uint32Array(2 * unique);
|
|
63
|
+
let size = 0;
|
|
64
|
+
for (let index = 0; index < unique; index++) {
|
|
65
|
+
const point = order[index];
|
|
66
|
+
while (size >= 2 &&
|
|
67
|
+
!turnsLeft_(coordinates, hull[size - 2], hull[size - 1], point)) {
|
|
68
|
+
size--;
|
|
69
|
+
}
|
|
70
|
+
hull[size++] = point;
|
|
71
|
+
}
|
|
72
|
+
const lowerSize = size + 1;
|
|
73
|
+
for (let index = unique - 2; index >= 0; index--) {
|
|
74
|
+
const point = order[index];
|
|
75
|
+
while (size >= lowerSize &&
|
|
76
|
+
!turnsLeft_(coordinates, hull[size - 2], hull[size - 1], point)) {
|
|
77
|
+
size--;
|
|
78
|
+
}
|
|
79
|
+
hull[size++] = point;
|
|
80
|
+
}
|
|
81
|
+
// The last point pushed is the first one again.
|
|
82
|
+
return hull.slice(0, size - 1);
|
|
83
|
+
}
|
|
84
|
+
/** Whether `a → b → c` turns strictly counter-clockwise. */
|
|
85
|
+
function turnsLeft_(coordinates, a, b, c) {
|
|
86
|
+
return (orient2(coordinates[2 * a], coordinates[2 * a + 1], coordinates[2 * b], coordinates[2 * b + 1], coordinates[2 * c], coordinates[2 * c + 1]) > 0);
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=convex-hull2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convex-hull2.js","sourceRoot":"","sources":["../src/convex-hull2.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,UAAU,WAAW,CAAC,WAA8B;IACzD,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;QAClC,MAAM,IAAI,UAAU,CACnB,gBAAgB,WAAW,CAAC,MAAM,uCAAuC,CACzE,CAAC;IACH,CAAC;IACD,MAAM,KAAK,GAAG,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC;IACrC,KAAK,IAAI,KAAK,GAAG,CAA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AAC;QACR,CAAC;QACD,IAAI,CAAC,IAAI,EAAE,CAAC,GAAG,KAAK,CAAC;IACtB,CAAC;IACD,gDAAgD;IAChD,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,CAAC,CAAC;AAChC,CAAC;AAED,4DAA4D;AAC5D,SAAS,UAAU,CAClB,WAA8B,EAC9B,CAAS,EACT,CAAS,EACT,CAAS;IAET,OAAO,CACN,OAAO,CACN,WAAW,CAAC,CAAC,GAAG,CAAC,CAAE,EACnB,WAAW,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAE,EACvB,WAAW,CAAC,CAAC,GAAG,CAAC,CAAE,EACnB,WAAW,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAE,EACvB,WAAW,CAAC,CAAC,GAAG,CAAC,CAAE,EACnB,WAAW,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAE,CACvB,GAAG,CAAC,CACL,CAAC;AACH,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export * from "./circle2-array-boundary.js";
|
|
|
16
16
|
export * from "./circle2-array.js";
|
|
17
17
|
export * from "./circle2-record.js";
|
|
18
18
|
export * from "./circle2.js";
|
|
19
|
+
export * from "./convex-hull2.js";
|
|
19
20
|
export * from "./coordinates/index.js";
|
|
20
21
|
export * from "./frustum3-record.js";
|
|
21
22
|
export * from "./frustum3.js";
|
|
@@ -31,6 +32,7 @@ export * from "./polygon2.js";
|
|
|
31
32
|
export * from "./polygon3.js";
|
|
32
33
|
export * from "./polyline2.js";
|
|
33
34
|
export * from "./polyline3.js";
|
|
35
|
+
export * from "./predicates2.js";
|
|
34
36
|
export * from "./quadtree.js";
|
|
35
37
|
export * from "./ray2-record.js";
|
|
36
38
|
export * from "./ray2.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":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;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,WAAW,CAAC;AAC1B,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,sBAAsB,CAAC;AACrC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,uBAAuB,CAAC;AACtC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,gBAAgB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -16,6 +16,7 @@ export * from "./circle2-array-boundary.js";
|
|
|
16
16
|
export * from "./circle2-array.js";
|
|
17
17
|
export * from "./circle2-record.js";
|
|
18
18
|
export * from "./circle2.js";
|
|
19
|
+
export * from "./convex-hull2.js";
|
|
19
20
|
export * from "./coordinates/index.js";
|
|
20
21
|
export * from "./frustum3-record.js";
|
|
21
22
|
export * from "./frustum3.js";
|
|
@@ -31,6 +32,7 @@ export * from "./polygon2.js";
|
|
|
31
32
|
export * from "./polygon3.js";
|
|
32
33
|
export * from "./polyline2.js";
|
|
33
34
|
export * from "./polyline3.js";
|
|
35
|
+
export * from "./predicates2.js";
|
|
34
36
|
export * from "./quadtree.js";
|
|
35
37
|
export * from "./ray2-record.js";
|
|
36
38
|
export * from "./ray2.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,iBAAiB,CAAC;AAChC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,WAAW,CAAC;AAC1B,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,cAA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;AAC5C,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,uBAAuB,CAAC;AACtC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,gBAAgB,CAAC"}
|
package/dist/line2.d.ts
CHANGED
|
@@ -25,6 +25,10 @@ export declare function line2ContainsPoint(line: ReadonlyLine2, point: ReadonlyV
|
|
|
25
25
|
*
|
|
26
26
|
* @param tolerance Dimensionless bound on the sine of the angle between the
|
|
27
27
|
* directions; defaults to `geometryConfig.defaultAngularTolerance`.
|
|
28
|
+
*
|
|
29
|
+
* Allocates nothing when the cross products of the directions and of the
|
|
30
|
+
* offset between the lines stay within `diffOfProductsInPlace`'s range
|
|
31
|
+
* (`2⁻⁹⁶⁹` to `2¹⁰²²` in magnitude, or zero): every coordinate-sized pair.
|
|
28
32
|
*/
|
|
29
33
|
export declare function line2IntersectLine2(out: Vec2, a: ReadonlyLine2, b: ReadonlyLine2, tolerance?: number): boolean;
|
|
30
34
|
//# sourceMappingURL=line2.d.ts.map
|
package/dist/line2.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"line2.d.ts","sourceRoot":"","sources":["../src/line2.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAI9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEvD;;;GAGG;AACH,wBAAgB,iBAAiB,CAChC,GAAG,EAAE,IAAI,EACT,IAAI,EAAE,aAAa,EACnB,KAAK,EAAE,YAAY,GACjB,IAAI,CAUN;AAED,6CAA6C;AAC7C,wBAAgB,oBAAoB,CACnC,IAAI,EAAE,aAAa,EACnB,KAAK,EAAE,YAAY,GACjB,MAAM,CAWR;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CACjC,IAAI,EAAE,aAAa,EACnB,KAAK,EAAE,YAAY,EACnB,SAAS,GAAE,MAA8C,GACvD,OAAO,CAET;AAED
|
|
1
|
+
{"version":3,"file":"line2.d.ts","sourceRoot":"","sources":["../src/line2.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAI9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEvD;;;GAGG;AACH,wBAAgB,iBAAiB,CAChC,GAAG,EAAE,IAAI,EACT,IAAI,EAAE,aAAa,EACnB,KAAK,EAAE,YAAY,GACjB,IAAI,CAUN;AAED,6CAA6C;AAC7C,wBAAgB,oBAAoB,CACnC,IAAI,EAAE,aAAa,EACnB,KAAK,EAAE,YAAY,GACjB,MAAM,CAWR;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CACjC,IAAI,EAAE,aAAa,EACnB,KAAK,EAAE,YAAY,EACnB,SAAS,GAAE,MAA8C,GACvD,OAAO,CAET;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,mBAAmB,CAClC,GAAG,EAAE,IAAI,EACT,CAAC,EAAE,aAAa,EAChB,CAAC,EAAE,aAAa,EAChB,SAAS,GAAE,MAA+C,GACxD,OAAO,CAyCT"}
|