@mui/x-charts-vendor 8.14.0 → 8.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/README.md +2 -7
  2. package/package.json +2 -6
  3. package/d3-delaunay.d.ts +0 -5
  4. package/d3-delaunay.js +0 -7
  5. package/delaunator.d.ts +0 -5
  6. package/delaunator.js +0 -7
  7. package/es/d3-delaunay.mjs +0 -6
  8. package/es/delaunator.mjs +0 -6
  9. package/es/robust-predicates.mjs +0 -6
  10. package/lib/d3-delaunay.js +0 -6
  11. package/lib/delaunator.js +0 -6
  12. package/lib/robust-predicates.js +0 -6
  13. package/lib-vendor/d3-delaunay/LICENSE +0 -14
  14. package/lib-vendor/d3-delaunay/dist/d3-delaunay.js +0 -1398
  15. package/lib-vendor/d3-delaunay/dist/d3-delaunay.min.js +0 -853
  16. package/lib-vendor/d3-delaunay/src/delaunay.js +0 -282
  17. package/lib-vendor/d3-delaunay/src/index.js +0 -20
  18. package/lib-vendor/d3-delaunay/src/path.js +0 -43
  19. package/lib-vendor/d3-delaunay/src/polygon.js +0 -24
  20. package/lib-vendor/d3-delaunay/src/voronoi.js +0 -390
  21. package/lib-vendor/delaunator/LICENSE +0 -15
  22. package/lib-vendor/delaunator/delaunator.js +0 -688
  23. package/lib-vendor/delaunator/delaunator.min.js +0 -316
  24. package/lib-vendor/delaunator/index.js +0 -440
  25. package/lib-vendor/robust-predicates/LICENSE +0 -24
  26. package/lib-vendor/robust-predicates/esm/incircle.js +0 -667
  27. package/lib-vendor/robust-predicates/esm/insphere.js +0 -693
  28. package/lib-vendor/robust-predicates/esm/orient2d.js +0 -174
  29. package/lib-vendor/robust-predicates/esm/orient3d.js +0 -422
  30. package/lib-vendor/robust-predicates/esm/util.js +0 -147
  31. package/lib-vendor/robust-predicates/index.js +0 -57
  32. package/lib-vendor/robust-predicates/umd/incircle.js +0 -798
  33. package/lib-vendor/robust-predicates/umd/incircle.min.js +0 -170
  34. package/lib-vendor/robust-predicates/umd/insphere.js +0 -828
  35. package/lib-vendor/robust-predicates/umd/insphere.min.js +0 -223
  36. package/lib-vendor/robust-predicates/umd/orient2d.js +0 -260
  37. package/lib-vendor/robust-predicates/umd/orient2d.min.js +0 -69
  38. package/lib-vendor/robust-predicates/umd/orient3d.js +0 -550
  39. package/lib-vendor/robust-predicates/umd/orient3d.min.js +0 -133
  40. package/lib-vendor/robust-predicates/umd/predicates.js +0 -2073
  41. package/lib-vendor/robust-predicates/umd/predicates.min.js +0 -468
  42. package/robust-predicates.d.ts +0 -5
  43. package/robust-predicates.js +0 -7
@@ -1,688 +0,0 @@
1
- "use strict";
2
-
3
- (function (global, factory) {
4
- typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Delaunator = factory());
5
- })(this, function () {
6
- 'use strict';
7
-
8
- const epsilon = 1.1102230246251565e-16;
9
- const splitter = 134217729;
10
- const resulterrbound = (3 + 8 * epsilon) * epsilon;
11
-
12
- // fast_expansion_sum_zeroelim routine from oritinal code
13
- function sum(elen, e, flen, f, h) {
14
- let Q, Qnew, hh, bvirt;
15
- let enow = e[0];
16
- let fnow = f[0];
17
- let eindex = 0;
18
- let findex = 0;
19
- if (fnow > enow === fnow > -enow) {
20
- Q = enow;
21
- enow = e[++eindex];
22
- } else {
23
- Q = fnow;
24
- fnow = f[++findex];
25
- }
26
- let hindex = 0;
27
- if (eindex < elen && findex < flen) {
28
- if (fnow > enow === fnow > -enow) {
29
- Qnew = enow + Q;
30
- hh = Q - (Qnew - enow);
31
- enow = e[++eindex];
32
- } else {
33
- Qnew = fnow + Q;
34
- hh = Q - (Qnew - fnow);
35
- fnow = f[++findex];
36
- }
37
- Q = Qnew;
38
- if (hh !== 0) {
39
- h[hindex++] = hh;
40
- }
41
- while (eindex < elen && findex < flen) {
42
- if (fnow > enow === fnow > -enow) {
43
- Qnew = Q + enow;
44
- bvirt = Qnew - Q;
45
- hh = Q - (Qnew - bvirt) + (enow - bvirt);
46
- enow = e[++eindex];
47
- } else {
48
- Qnew = Q + fnow;
49
- bvirt = Qnew - Q;
50
- hh = Q - (Qnew - bvirt) + (fnow - bvirt);
51
- fnow = f[++findex];
52
- }
53
- Q = Qnew;
54
- if (hh !== 0) {
55
- h[hindex++] = hh;
56
- }
57
- }
58
- }
59
- while (eindex < elen) {
60
- Qnew = Q + enow;
61
- bvirt = Qnew - Q;
62
- hh = Q - (Qnew - bvirt) + (enow - bvirt);
63
- enow = e[++eindex];
64
- Q = Qnew;
65
- if (hh !== 0) {
66
- h[hindex++] = hh;
67
- }
68
- }
69
- while (findex < flen) {
70
- Qnew = Q + fnow;
71
- bvirt = Qnew - Q;
72
- hh = Q - (Qnew - bvirt) + (fnow - bvirt);
73
- fnow = f[++findex];
74
- Q = Qnew;
75
- if (hh !== 0) {
76
- h[hindex++] = hh;
77
- }
78
- }
79
- if (Q !== 0 || hindex === 0) {
80
- h[hindex++] = Q;
81
- }
82
- return hindex;
83
- }
84
- function estimate(elen, e) {
85
- let Q = e[0];
86
- for (let i = 1; i < elen; i++) Q += e[i];
87
- return Q;
88
- }
89
- function vec(n) {
90
- return new Float64Array(n);
91
- }
92
- const ccwerrboundA = (3 + 16 * epsilon) * epsilon;
93
- const ccwerrboundB = (2 + 12 * epsilon) * epsilon;
94
- const ccwerrboundC = (9 + 64 * epsilon) * epsilon * epsilon;
95
- const B = vec(4);
96
- const C1 = vec(8);
97
- const C2 = vec(12);
98
- const D = vec(16);
99
- const u = vec(4);
100
- function orient2dadapt(ax, ay, bx, by, cx, cy, detsum) {
101
- let acxtail, acytail, bcxtail, bcytail;
102
- let bvirt, c, ahi, alo, bhi, blo, _i, _j, _0, s1, s0, t1, t0, u3;
103
- const acx = ax - cx;
104
- const bcx = bx - cx;
105
- const acy = ay - cy;
106
- const bcy = by - cy;
107
- s1 = acx * bcy;
108
- c = splitter * acx;
109
- ahi = c - (c - acx);
110
- alo = acx - ahi;
111
- c = splitter * bcy;
112
- bhi = c - (c - bcy);
113
- blo = bcy - bhi;
114
- s0 = alo * blo - (s1 - ahi * bhi - alo * bhi - ahi * blo);
115
- t1 = acy * bcx;
116
- c = splitter * acy;
117
- ahi = c - (c - acy);
118
- alo = acy - ahi;
119
- c = splitter * bcx;
120
- bhi = c - (c - bcx);
121
- blo = bcx - bhi;
122
- t0 = alo * blo - (t1 - ahi * bhi - alo * bhi - ahi * blo);
123
- _i = s0 - t0;
124
- bvirt = s0 - _i;
125
- B[0] = s0 - (_i + bvirt) + (bvirt - t0);
126
- _j = s1 + _i;
127
- bvirt = _j - s1;
128
- _0 = s1 - (_j - bvirt) + (_i - bvirt);
129
- _i = _0 - t1;
130
- bvirt = _0 - _i;
131
- B[1] = _0 - (_i + bvirt) + (bvirt - t1);
132
- u3 = _j + _i;
133
- bvirt = u3 - _j;
134
- B[2] = _j - (u3 - bvirt) + (_i - bvirt);
135
- B[3] = u3;
136
- let det = estimate(4, B);
137
- let errbound = ccwerrboundB * detsum;
138
- if (det >= errbound || -det >= errbound) {
139
- return det;
140
- }
141
- bvirt = ax - acx;
142
- acxtail = ax - (acx + bvirt) + (bvirt - cx);
143
- bvirt = bx - bcx;
144
- bcxtail = bx - (bcx + bvirt) + (bvirt - cx);
145
- bvirt = ay - acy;
146
- acytail = ay - (acy + bvirt) + (bvirt - cy);
147
- bvirt = by - bcy;
148
- bcytail = by - (bcy + bvirt) + (bvirt - cy);
149
- if (acxtail === 0 && acytail === 0 && bcxtail === 0 && bcytail === 0) {
150
- return det;
151
- }
152
- errbound = ccwerrboundC * detsum + resulterrbound * Math.abs(det);
153
- det += acx * bcytail + bcy * acxtail - (acy * bcxtail + bcx * acytail);
154
- if (det >= errbound || -det >= errbound) return det;
155
- s1 = acxtail * bcy;
156
- c = splitter * acxtail;
157
- ahi = c - (c - acxtail);
158
- alo = acxtail - ahi;
159
- c = splitter * bcy;
160
- bhi = c - (c - bcy);
161
- blo = bcy - bhi;
162
- s0 = alo * blo - (s1 - ahi * bhi - alo * bhi - ahi * blo);
163
- t1 = acytail * bcx;
164
- c = splitter * acytail;
165
- ahi = c - (c - acytail);
166
- alo = acytail - ahi;
167
- c = splitter * bcx;
168
- bhi = c - (c - bcx);
169
- blo = bcx - bhi;
170
- t0 = alo * blo - (t1 - ahi * bhi - alo * bhi - ahi * blo);
171
- _i = s0 - t0;
172
- bvirt = s0 - _i;
173
- u[0] = s0 - (_i + bvirt) + (bvirt - t0);
174
- _j = s1 + _i;
175
- bvirt = _j - s1;
176
- _0 = s1 - (_j - bvirt) + (_i - bvirt);
177
- _i = _0 - t1;
178
- bvirt = _0 - _i;
179
- u[1] = _0 - (_i + bvirt) + (bvirt - t1);
180
- u3 = _j + _i;
181
- bvirt = u3 - _j;
182
- u[2] = _j - (u3 - bvirt) + (_i - bvirt);
183
- u[3] = u3;
184
- const C1len = sum(4, B, 4, u, C1);
185
- s1 = acx * bcytail;
186
- c = splitter * acx;
187
- ahi = c - (c - acx);
188
- alo = acx - ahi;
189
- c = splitter * bcytail;
190
- bhi = c - (c - bcytail);
191
- blo = bcytail - bhi;
192
- s0 = alo * blo - (s1 - ahi * bhi - alo * bhi - ahi * blo);
193
- t1 = acy * bcxtail;
194
- c = splitter * acy;
195
- ahi = c - (c - acy);
196
- alo = acy - ahi;
197
- c = splitter * bcxtail;
198
- bhi = c - (c - bcxtail);
199
- blo = bcxtail - bhi;
200
- t0 = alo * blo - (t1 - ahi * bhi - alo * bhi - ahi * blo);
201
- _i = s0 - t0;
202
- bvirt = s0 - _i;
203
- u[0] = s0 - (_i + bvirt) + (bvirt - t0);
204
- _j = s1 + _i;
205
- bvirt = _j - s1;
206
- _0 = s1 - (_j - bvirt) + (_i - bvirt);
207
- _i = _0 - t1;
208
- bvirt = _0 - _i;
209
- u[1] = _0 - (_i + bvirt) + (bvirt - t1);
210
- u3 = _j + _i;
211
- bvirt = u3 - _j;
212
- u[2] = _j - (u3 - bvirt) + (_i - bvirt);
213
- u[3] = u3;
214
- const C2len = sum(C1len, C1, 4, u, C2);
215
- s1 = acxtail * bcytail;
216
- c = splitter * acxtail;
217
- ahi = c - (c - acxtail);
218
- alo = acxtail - ahi;
219
- c = splitter * bcytail;
220
- bhi = c - (c - bcytail);
221
- blo = bcytail - bhi;
222
- s0 = alo * blo - (s1 - ahi * bhi - alo * bhi - ahi * blo);
223
- t1 = acytail * bcxtail;
224
- c = splitter * acytail;
225
- ahi = c - (c - acytail);
226
- alo = acytail - ahi;
227
- c = splitter * bcxtail;
228
- bhi = c - (c - bcxtail);
229
- blo = bcxtail - bhi;
230
- t0 = alo * blo - (t1 - ahi * bhi - alo * bhi - ahi * blo);
231
- _i = s0 - t0;
232
- bvirt = s0 - _i;
233
- u[0] = s0 - (_i + bvirt) + (bvirt - t0);
234
- _j = s1 + _i;
235
- bvirt = _j - s1;
236
- _0 = s1 - (_j - bvirt) + (_i - bvirt);
237
- _i = _0 - t1;
238
- bvirt = _0 - _i;
239
- u[1] = _0 - (_i + bvirt) + (bvirt - t1);
240
- u3 = _j + _i;
241
- bvirt = u3 - _j;
242
- u[2] = _j - (u3 - bvirt) + (_i - bvirt);
243
- u[3] = u3;
244
- const Dlen = sum(C2len, C2, 4, u, D);
245
- return D[Dlen - 1];
246
- }
247
- function orient2d(ax, ay, bx, by, cx, cy) {
248
- const detleft = (ay - cy) * (bx - cx);
249
- const detright = (ax - cx) * (by - cy);
250
- const det = detleft - detright;
251
- const detsum = Math.abs(detleft + detright);
252
- if (Math.abs(det) >= ccwerrboundA * detsum) return det;
253
- return -orient2dadapt(ax, ay, bx, by, cx, cy, detsum);
254
- }
255
- const EPSILON = Math.pow(2, -52);
256
- const EDGE_STACK = new Uint32Array(512);
257
- class Delaunator {
258
- static from(points, getX = defaultGetX, getY = defaultGetY) {
259
- const n = points.length;
260
- const coords = new Float64Array(n * 2);
261
- for (let i = 0; i < n; i++) {
262
- const p = points[i];
263
- coords[2 * i] = getX(p);
264
- coords[2 * i + 1] = getY(p);
265
- }
266
- return new Delaunator(coords);
267
- }
268
- constructor(coords) {
269
- const n = coords.length >> 1;
270
- if (n > 0 && typeof coords[0] !== 'number') throw new Error('Expected coords to contain numbers.');
271
- this.coords = coords;
272
-
273
- // arrays that will store the triangulation graph
274
- const maxTriangles = Math.max(2 * n - 5, 0);
275
- this._triangles = new Uint32Array(maxTriangles * 3);
276
- this._halfedges = new Int32Array(maxTriangles * 3);
277
-
278
- // temporary arrays for tracking the edges of the advancing convex hull
279
- this._hashSize = Math.ceil(Math.sqrt(n));
280
- this._hullPrev = new Uint32Array(n); // edge to prev edge
281
- this._hullNext = new Uint32Array(n); // edge to next edge
282
- this._hullTri = new Uint32Array(n); // edge to adjacent triangle
283
- this._hullHash = new Int32Array(this._hashSize); // angular edge hash
284
-
285
- // temporary arrays for sorting points
286
- this._ids = new Uint32Array(n);
287
- this._dists = new Float64Array(n);
288
- this.update();
289
- }
290
- update() {
291
- const {
292
- coords,
293
- _hullPrev: hullPrev,
294
- _hullNext: hullNext,
295
- _hullTri: hullTri,
296
- _hullHash: hullHash
297
- } = this;
298
- const n = coords.length >> 1;
299
-
300
- // populate an array of point indices; calculate input data bbox
301
- let minX = Infinity;
302
- let minY = Infinity;
303
- let maxX = -Infinity;
304
- let maxY = -Infinity;
305
- for (let i = 0; i < n; i++) {
306
- const x = coords[2 * i];
307
- const y = coords[2 * i + 1];
308
- if (x < minX) minX = x;
309
- if (y < minY) minY = y;
310
- if (x > maxX) maxX = x;
311
- if (y > maxY) maxY = y;
312
- this._ids[i] = i;
313
- }
314
- const cx = (minX + maxX) / 2;
315
- const cy = (minY + maxY) / 2;
316
- let i0, i1, i2;
317
-
318
- // pick a seed point close to the center
319
- for (let i = 0, minDist = Infinity; i < n; i++) {
320
- const d = dist(cx, cy, coords[2 * i], coords[2 * i + 1]);
321
- if (d < minDist) {
322
- i0 = i;
323
- minDist = d;
324
- }
325
- }
326
- const i0x = coords[2 * i0];
327
- const i0y = coords[2 * i0 + 1];
328
-
329
- // find the point closest to the seed
330
- for (let i = 0, minDist = Infinity; i < n; i++) {
331
- if (i === i0) continue;
332
- const d = dist(i0x, i0y, coords[2 * i], coords[2 * i + 1]);
333
- if (d < minDist && d > 0) {
334
- i1 = i;
335
- minDist = d;
336
- }
337
- }
338
- let i1x = coords[2 * i1];
339
- let i1y = coords[2 * i1 + 1];
340
- let minRadius = Infinity;
341
-
342
- // find the third point which forms the smallest circumcircle with the first two
343
- for (let i = 0; i < n; i++) {
344
- if (i === i0 || i === i1) continue;
345
- const r = circumradius(i0x, i0y, i1x, i1y, coords[2 * i], coords[2 * i + 1]);
346
- if (r < minRadius) {
347
- i2 = i;
348
- minRadius = r;
349
- }
350
- }
351
- let i2x = coords[2 * i2];
352
- let i2y = coords[2 * i2 + 1];
353
- if (minRadius === Infinity) {
354
- // order collinear points by dx (or dy if all x are identical)
355
- // and return the list as a hull
356
- for (let i = 0; i < n; i++) {
357
- this._dists[i] = coords[2 * i] - coords[0] || coords[2 * i + 1] - coords[1];
358
- }
359
- quicksort(this._ids, this._dists, 0, n - 1);
360
- const hull = new Uint32Array(n);
361
- let j = 0;
362
- for (let i = 0, d0 = -Infinity; i < n; i++) {
363
- const id = this._ids[i];
364
- const d = this._dists[id];
365
- if (d > d0) {
366
- hull[j++] = id;
367
- d0 = d;
368
- }
369
- }
370
- this.hull = hull.subarray(0, j);
371
- this.triangles = new Uint32Array(0);
372
- this.halfedges = new Uint32Array(0);
373
- return;
374
- }
375
-
376
- // swap the order of the seed points for counter-clockwise orientation
377
- if (orient2d(i0x, i0y, i1x, i1y, i2x, i2y) < 0) {
378
- const i = i1;
379
- const x = i1x;
380
- const y = i1y;
381
- i1 = i2;
382
- i1x = i2x;
383
- i1y = i2y;
384
- i2 = i;
385
- i2x = x;
386
- i2y = y;
387
- }
388
- const center = circumcenter(i0x, i0y, i1x, i1y, i2x, i2y);
389
- this._cx = center.x;
390
- this._cy = center.y;
391
- for (let i = 0; i < n; i++) {
392
- this._dists[i] = dist(coords[2 * i], coords[2 * i + 1], center.x, center.y);
393
- }
394
-
395
- // sort the points by distance from the seed triangle circumcenter
396
- quicksort(this._ids, this._dists, 0, n - 1);
397
-
398
- // set up the seed triangle as the starting hull
399
- this._hullStart = i0;
400
- let hullSize = 3;
401
- hullNext[i0] = hullPrev[i2] = i1;
402
- hullNext[i1] = hullPrev[i0] = i2;
403
- hullNext[i2] = hullPrev[i1] = i0;
404
- hullTri[i0] = 0;
405
- hullTri[i1] = 1;
406
- hullTri[i2] = 2;
407
- hullHash.fill(-1);
408
- hullHash[this._hashKey(i0x, i0y)] = i0;
409
- hullHash[this._hashKey(i1x, i1y)] = i1;
410
- hullHash[this._hashKey(i2x, i2y)] = i2;
411
- this.trianglesLen = 0;
412
- this._addTriangle(i0, i1, i2, -1, -1, -1);
413
- for (let k = 0, xp, yp; k < this._ids.length; k++) {
414
- const i = this._ids[k];
415
- const x = coords[2 * i];
416
- const y = coords[2 * i + 1];
417
-
418
- // skip near-duplicate points
419
- if (k > 0 && Math.abs(x - xp) <= EPSILON && Math.abs(y - yp) <= EPSILON) continue;
420
- xp = x;
421
- yp = y;
422
-
423
- // skip seed triangle points
424
- if (i === i0 || i === i1 || i === i2) continue;
425
-
426
- // find a visible edge on the convex hull using edge hash
427
- let start = 0;
428
- for (let j = 0, key = this._hashKey(x, y); j < this._hashSize; j++) {
429
- start = hullHash[(key + j) % this._hashSize];
430
- if (start !== -1 && start !== hullNext[start]) break;
431
- }
432
- start = hullPrev[start];
433
- let e = start,
434
- q;
435
- while (q = hullNext[e], orient2d(x, y, coords[2 * e], coords[2 * e + 1], coords[2 * q], coords[2 * q + 1]) >= 0) {
436
- e = q;
437
- if (e === start) {
438
- e = -1;
439
- break;
440
- }
441
- }
442
- if (e === -1) continue; // likely a near-duplicate point; skip it
443
-
444
- // add the first triangle from the point
445
- let t = this._addTriangle(e, i, hullNext[e], -1, -1, hullTri[e]);
446
-
447
- // recursively flip triangles from the point until they satisfy the Delaunay condition
448
- hullTri[i] = this._legalize(t + 2);
449
- hullTri[e] = t; // keep track of boundary triangles on the hull
450
- hullSize++;
451
-
452
- // walk forward through the hull, adding more triangles and flipping recursively
453
- let n = hullNext[e];
454
- while (q = hullNext[n], orient2d(x, y, coords[2 * n], coords[2 * n + 1], coords[2 * q], coords[2 * q + 1]) < 0) {
455
- t = this._addTriangle(n, i, q, hullTri[i], -1, hullTri[n]);
456
- hullTri[i] = this._legalize(t + 2);
457
- hullNext[n] = n; // mark as removed
458
- hullSize--;
459
- n = q;
460
- }
461
-
462
- // walk backward from the other side, adding more triangles and flipping
463
- if (e === start) {
464
- while (q = hullPrev[e], orient2d(x, y, coords[2 * q], coords[2 * q + 1], coords[2 * e], coords[2 * e + 1]) < 0) {
465
- t = this._addTriangle(q, i, e, -1, hullTri[e], hullTri[q]);
466
- this._legalize(t + 2);
467
- hullTri[q] = t;
468
- hullNext[e] = e; // mark as removed
469
- hullSize--;
470
- e = q;
471
- }
472
- }
473
-
474
- // update the hull indices
475
- this._hullStart = hullPrev[i] = e;
476
- hullNext[e] = hullPrev[n] = i;
477
- hullNext[i] = n;
478
-
479
- // save the two new edges in the hash table
480
- hullHash[this._hashKey(x, y)] = i;
481
- hullHash[this._hashKey(coords[2 * e], coords[2 * e + 1])] = e;
482
- }
483
- this.hull = new Uint32Array(hullSize);
484
- for (let i = 0, e = this._hullStart; i < hullSize; i++) {
485
- this.hull[i] = e;
486
- e = hullNext[e];
487
- }
488
-
489
- // trim typed triangle mesh arrays
490
- this.triangles = this._triangles.subarray(0, this.trianglesLen);
491
- this.halfedges = this._halfedges.subarray(0, this.trianglesLen);
492
- }
493
- _hashKey(x, y) {
494
- return Math.floor(pseudoAngle(x - this._cx, y - this._cy) * this._hashSize) % this._hashSize;
495
- }
496
- _legalize(a) {
497
- const {
498
- _triangles: triangles,
499
- _halfedges: halfedges,
500
- coords
501
- } = this;
502
- let i = 0;
503
- let ar = 0;
504
-
505
- // recursion eliminated with a fixed-size stack
506
- while (true) {
507
- const b = halfedges[a];
508
-
509
- /* if the pair of triangles doesn't satisfy the Delaunay condition
510
- * (p1 is inside the circumcircle of [p0, pl, pr]), flip them,
511
- * then do the same check/flip recursively for the new pair of triangles
512
- *
513
- * pl pl
514
- * /||\ / \
515
- * al/ || \bl al/ \a
516
- * / || \ / \
517
- * / a||b \ flip /___ar___\
518
- * p0\ || /p1 => p0\---bl---/p1
519
- * \ || / \ /
520
- * ar\ || /br b\ /br
521
- * \||/ \ /
522
- * pr pr
523
- */
524
- const a0 = a - a % 3;
525
- ar = a0 + (a + 2) % 3;
526
- if (b === -1) {
527
- // convex hull edge
528
- if (i === 0) break;
529
- a = EDGE_STACK[--i];
530
- continue;
531
- }
532
- const b0 = b - b % 3;
533
- const al = a0 + (a + 1) % 3;
534
- const bl = b0 + (b + 2) % 3;
535
- const p0 = triangles[ar];
536
- const pr = triangles[a];
537
- const pl = triangles[al];
538
- const p1 = triangles[bl];
539
- const illegal = inCircle(coords[2 * p0], coords[2 * p0 + 1], coords[2 * pr], coords[2 * pr + 1], coords[2 * pl], coords[2 * pl + 1], coords[2 * p1], coords[2 * p1 + 1]);
540
- if (illegal) {
541
- triangles[a] = p1;
542
- triangles[b] = p0;
543
- const hbl = halfedges[bl];
544
-
545
- // edge swapped on the other side of the hull (rare); fix the halfedge reference
546
- if (hbl === -1) {
547
- let e = this._hullStart;
548
- do {
549
- if (this._hullTri[e] === bl) {
550
- this._hullTri[e] = a;
551
- break;
552
- }
553
- e = this._hullPrev[e];
554
- } while (e !== this._hullStart);
555
- }
556
- this._link(a, hbl);
557
- this._link(b, halfedges[ar]);
558
- this._link(ar, bl);
559
- const br = b0 + (b + 1) % 3;
560
-
561
- // don't worry about hitting the cap: it can only happen on extremely degenerate input
562
- if (i < EDGE_STACK.length) {
563
- EDGE_STACK[i++] = br;
564
- }
565
- } else {
566
- if (i === 0) break;
567
- a = EDGE_STACK[--i];
568
- }
569
- }
570
- return ar;
571
- }
572
- _link(a, b) {
573
- this._halfedges[a] = b;
574
- if (b !== -1) this._halfedges[b] = a;
575
- }
576
-
577
- // add a new triangle given vertex indices and adjacent half-edge ids
578
- _addTriangle(i0, i1, i2, a, b, c) {
579
- const t = this.trianglesLen;
580
- this._triangles[t] = i0;
581
- this._triangles[t + 1] = i1;
582
- this._triangles[t + 2] = i2;
583
- this._link(t, a);
584
- this._link(t + 1, b);
585
- this._link(t + 2, c);
586
- this.trianglesLen += 3;
587
- return t;
588
- }
589
- }
590
-
591
- // monotonically increases with real angle, but doesn't need expensive trigonometry
592
- function pseudoAngle(dx, dy) {
593
- const p = dx / (Math.abs(dx) + Math.abs(dy));
594
- return (dy > 0 ? 3 - p : 1 + p) / 4; // [0..1]
595
- }
596
- function dist(ax, ay, bx, by) {
597
- const dx = ax - bx;
598
- const dy = ay - by;
599
- return dx * dx + dy * dy;
600
- }
601
- function inCircle(ax, ay, bx, by, cx, cy, px, py) {
602
- const dx = ax - px;
603
- const dy = ay - py;
604
- const ex = bx - px;
605
- const ey = by - py;
606
- const fx = cx - px;
607
- const fy = cy - py;
608
- const ap = dx * dx + dy * dy;
609
- const bp = ex * ex + ey * ey;
610
- const cp = fx * fx + fy * fy;
611
- return dx * (ey * cp - bp * fy) - dy * (ex * cp - bp * fx) + ap * (ex * fy - ey * fx) < 0;
612
- }
613
- function circumradius(ax, ay, bx, by, cx, cy) {
614
- const dx = bx - ax;
615
- const dy = by - ay;
616
- const ex = cx - ax;
617
- const ey = cy - ay;
618
- const bl = dx * dx + dy * dy;
619
- const cl = ex * ex + ey * ey;
620
- const d = 0.5 / (dx * ey - dy * ex);
621
- const x = (ey * bl - dy * cl) * d;
622
- const y = (dx * cl - ex * bl) * d;
623
- return x * x + y * y;
624
- }
625
- function circumcenter(ax, ay, bx, by, cx, cy) {
626
- const dx = bx - ax;
627
- const dy = by - ay;
628
- const ex = cx - ax;
629
- const ey = cy - ay;
630
- const bl = dx * dx + dy * dy;
631
- const cl = ex * ex + ey * ey;
632
- const d = 0.5 / (dx * ey - dy * ex);
633
- const x = ax + (ey * bl - dy * cl) * d;
634
- const y = ay + (dx * cl - ex * bl) * d;
635
- return {
636
- x,
637
- y
638
- };
639
- }
640
- function quicksort(ids, dists, left, right) {
641
- if (right - left <= 20) {
642
- for (let i = left + 1; i <= right; i++) {
643
- const temp = ids[i];
644
- const tempDist = dists[temp];
645
- let j = i - 1;
646
- while (j >= left && dists[ids[j]] > tempDist) ids[j + 1] = ids[j--];
647
- ids[j + 1] = temp;
648
- }
649
- } else {
650
- const median = left + right >> 1;
651
- let i = left + 1;
652
- let j = right;
653
- swap(ids, median, i);
654
- if (dists[ids[left]] > dists[ids[right]]) swap(ids, left, right);
655
- if (dists[ids[i]] > dists[ids[right]]) swap(ids, i, right);
656
- if (dists[ids[left]] > dists[ids[i]]) swap(ids, left, i);
657
- const temp = ids[i];
658
- const tempDist = dists[temp];
659
- while (true) {
660
- do i++; while (dists[ids[i]] < tempDist);
661
- do j--; while (dists[ids[j]] > tempDist);
662
- if (j < i) break;
663
- swap(ids, i, j);
664
- }
665
- ids[left + 1] = ids[j];
666
- ids[j] = temp;
667
- if (right - i + 1 >= j - left) {
668
- quicksort(ids, dists, i, right);
669
- quicksort(ids, dists, left, j - 1);
670
- } else {
671
- quicksort(ids, dists, left, j - 1);
672
- quicksort(ids, dists, i, right);
673
- }
674
- }
675
- }
676
- function swap(arr, i, j) {
677
- const tmp = arr[i];
678
- arr[i] = arr[j];
679
- arr[j] = tmp;
680
- }
681
- function defaultGetX(p) {
682
- return p[0];
683
- }
684
- function defaultGetY(p) {
685
- return p[1];
686
- }
687
- return Delaunator;
688
- });