@mui/x-charts-vendor 8.14.0 → 8.15.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/README.md +2 -7
- package/package.json +3 -6
- package/d3-delaunay.d.ts +0 -5
- package/d3-delaunay.js +0 -7
- package/delaunator.d.ts +0 -5
- package/delaunator.js +0 -7
- package/es/d3-delaunay.mjs +0 -6
- package/es/delaunator.mjs +0 -6
- package/es/robust-predicates.mjs +0 -6
- package/lib/d3-delaunay.js +0 -6
- package/lib/delaunator.js +0 -6
- package/lib/robust-predicates.js +0 -6
- package/lib-vendor/d3-delaunay/LICENSE +0 -14
- package/lib-vendor/d3-delaunay/dist/d3-delaunay.js +0 -1398
- package/lib-vendor/d3-delaunay/dist/d3-delaunay.min.js +0 -853
- package/lib-vendor/d3-delaunay/src/delaunay.js +0 -282
- package/lib-vendor/d3-delaunay/src/index.js +0 -20
- package/lib-vendor/d3-delaunay/src/path.js +0 -43
- package/lib-vendor/d3-delaunay/src/polygon.js +0 -24
- package/lib-vendor/d3-delaunay/src/voronoi.js +0 -390
- package/lib-vendor/delaunator/LICENSE +0 -15
- package/lib-vendor/delaunator/delaunator.js +0 -688
- package/lib-vendor/delaunator/delaunator.min.js +0 -316
- package/lib-vendor/delaunator/index.js +0 -440
- package/lib-vendor/robust-predicates/LICENSE +0 -24
- package/lib-vendor/robust-predicates/esm/incircle.js +0 -667
- package/lib-vendor/robust-predicates/esm/insphere.js +0 -693
- package/lib-vendor/robust-predicates/esm/orient2d.js +0 -174
- package/lib-vendor/robust-predicates/esm/orient3d.js +0 -422
- package/lib-vendor/robust-predicates/esm/util.js +0 -147
- package/lib-vendor/robust-predicates/index.js +0 -57
- package/lib-vendor/robust-predicates/umd/incircle.js +0 -798
- package/lib-vendor/robust-predicates/umd/incircle.min.js +0 -170
- package/lib-vendor/robust-predicates/umd/insphere.js +0 -828
- package/lib-vendor/robust-predicates/umd/insphere.min.js +0 -223
- package/lib-vendor/robust-predicates/umd/orient2d.js +0 -260
- package/lib-vendor/robust-predicates/umd/orient2d.min.js +0 -69
- package/lib-vendor/robust-predicates/umd/orient3d.js +0 -550
- package/lib-vendor/robust-predicates/umd/orient3d.min.js +0 -133
- package/lib-vendor/robust-predicates/umd/predicates.js +0 -2073
- package/lib-vendor/robust-predicates/umd/predicates.min.js +0 -468
- package/robust-predicates.d.ts +0 -5
- package/robust-predicates.js +0 -7
|
@@ -1,390 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _path = _interopRequireDefault(require("./path.js"));
|
|
9
|
-
var _polygon = _interopRequireDefault(require("./polygon.js"));
|
|
10
|
-
class Voronoi {
|
|
11
|
-
constructor(delaunay, [xmin, ymin, xmax, ymax] = [0, 0, 960, 500]) {
|
|
12
|
-
if (!((xmax = +xmax) >= (xmin = +xmin)) || !((ymax = +ymax) >= (ymin = +ymin))) throw new Error("invalid bounds");
|
|
13
|
-
this.delaunay = delaunay;
|
|
14
|
-
this._circumcenters = new Float64Array(delaunay.points.length * 2);
|
|
15
|
-
this.vectors = new Float64Array(delaunay.points.length * 2);
|
|
16
|
-
this.xmax = xmax, this.xmin = xmin;
|
|
17
|
-
this.ymax = ymax, this.ymin = ymin;
|
|
18
|
-
this._init();
|
|
19
|
-
}
|
|
20
|
-
update() {
|
|
21
|
-
this.delaunay.update();
|
|
22
|
-
this._init();
|
|
23
|
-
return this;
|
|
24
|
-
}
|
|
25
|
-
_init() {
|
|
26
|
-
const {
|
|
27
|
-
delaunay: {
|
|
28
|
-
points,
|
|
29
|
-
hull,
|
|
30
|
-
triangles
|
|
31
|
-
},
|
|
32
|
-
vectors
|
|
33
|
-
} = this;
|
|
34
|
-
let bx, by; // lazily computed barycenter of the hull
|
|
35
|
-
|
|
36
|
-
// Compute circumcenters.
|
|
37
|
-
const circumcenters = this.circumcenters = this._circumcenters.subarray(0, triangles.length / 3 * 2);
|
|
38
|
-
for (let i = 0, j = 0, n = triangles.length, x, y; i < n; i += 3, j += 2) {
|
|
39
|
-
const t1 = triangles[i] * 2;
|
|
40
|
-
const t2 = triangles[i + 1] * 2;
|
|
41
|
-
const t3 = triangles[i + 2] * 2;
|
|
42
|
-
const x1 = points[t1];
|
|
43
|
-
const y1 = points[t1 + 1];
|
|
44
|
-
const x2 = points[t2];
|
|
45
|
-
const y2 = points[t2 + 1];
|
|
46
|
-
const x3 = points[t3];
|
|
47
|
-
const y3 = points[t3 + 1];
|
|
48
|
-
const dx = x2 - x1;
|
|
49
|
-
const dy = y2 - y1;
|
|
50
|
-
const ex = x3 - x1;
|
|
51
|
-
const ey = y3 - y1;
|
|
52
|
-
const ab = (dx * ey - dy * ex) * 2;
|
|
53
|
-
if (Math.abs(ab) < 1e-9) {
|
|
54
|
-
// For a degenerate triangle, the circumcenter is at the infinity, in a
|
|
55
|
-
// direction orthogonal to the halfedge and away from the “center” of
|
|
56
|
-
// the diagram <bx, by>, defined as the hull’s barycenter.
|
|
57
|
-
if (bx === undefined) {
|
|
58
|
-
bx = by = 0;
|
|
59
|
-
for (const i of hull) bx += points[i * 2], by += points[i * 2 + 1];
|
|
60
|
-
bx /= hull.length, by /= hull.length;
|
|
61
|
-
}
|
|
62
|
-
const a = 1e9 * Math.sign((bx - x1) * ey - (by - y1) * ex);
|
|
63
|
-
x = (x1 + x3) / 2 - a * ey;
|
|
64
|
-
y = (y1 + y3) / 2 + a * ex;
|
|
65
|
-
} else {
|
|
66
|
-
const d = 1 / ab;
|
|
67
|
-
const bl = dx * dx + dy * dy;
|
|
68
|
-
const cl = ex * ex + ey * ey;
|
|
69
|
-
x = x1 + (ey * bl - dy * cl) * d;
|
|
70
|
-
y = y1 + (dx * cl - ex * bl) * d;
|
|
71
|
-
}
|
|
72
|
-
circumcenters[j] = x;
|
|
73
|
-
circumcenters[j + 1] = y;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// Compute exterior cell rays.
|
|
77
|
-
let h = hull[hull.length - 1];
|
|
78
|
-
let p0,
|
|
79
|
-
p1 = h * 4;
|
|
80
|
-
let x0,
|
|
81
|
-
x1 = points[2 * h];
|
|
82
|
-
let y0,
|
|
83
|
-
y1 = points[2 * h + 1];
|
|
84
|
-
vectors.fill(0);
|
|
85
|
-
for (let i = 0; i < hull.length; ++i) {
|
|
86
|
-
h = hull[i];
|
|
87
|
-
p0 = p1, x0 = x1, y0 = y1;
|
|
88
|
-
p1 = h * 4, x1 = points[2 * h], y1 = points[2 * h + 1];
|
|
89
|
-
vectors[p0 + 2] = vectors[p1] = y0 - y1;
|
|
90
|
-
vectors[p0 + 3] = vectors[p1 + 1] = x1 - x0;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
render(context) {
|
|
94
|
-
const buffer = context == null ? context = new _path.default() : undefined;
|
|
95
|
-
const {
|
|
96
|
-
delaunay: {
|
|
97
|
-
halfedges,
|
|
98
|
-
inedges,
|
|
99
|
-
hull
|
|
100
|
-
},
|
|
101
|
-
circumcenters,
|
|
102
|
-
vectors
|
|
103
|
-
} = this;
|
|
104
|
-
if (hull.length <= 1) return null;
|
|
105
|
-
for (let i = 0, n = halfedges.length; i < n; ++i) {
|
|
106
|
-
const j = halfedges[i];
|
|
107
|
-
if (j < i) continue;
|
|
108
|
-
const ti = Math.floor(i / 3) * 2;
|
|
109
|
-
const tj = Math.floor(j / 3) * 2;
|
|
110
|
-
const xi = circumcenters[ti];
|
|
111
|
-
const yi = circumcenters[ti + 1];
|
|
112
|
-
const xj = circumcenters[tj];
|
|
113
|
-
const yj = circumcenters[tj + 1];
|
|
114
|
-
this._renderSegment(xi, yi, xj, yj, context);
|
|
115
|
-
}
|
|
116
|
-
let h0,
|
|
117
|
-
h1 = hull[hull.length - 1];
|
|
118
|
-
for (let i = 0; i < hull.length; ++i) {
|
|
119
|
-
h0 = h1, h1 = hull[i];
|
|
120
|
-
const t = Math.floor(inedges[h1] / 3) * 2;
|
|
121
|
-
const x = circumcenters[t];
|
|
122
|
-
const y = circumcenters[t + 1];
|
|
123
|
-
const v = h0 * 4;
|
|
124
|
-
const p = this._project(x, y, vectors[v + 2], vectors[v + 3]);
|
|
125
|
-
if (p) this._renderSegment(x, y, p[0], p[1], context);
|
|
126
|
-
}
|
|
127
|
-
return buffer && buffer.value();
|
|
128
|
-
}
|
|
129
|
-
renderBounds(context) {
|
|
130
|
-
const buffer = context == null ? context = new _path.default() : undefined;
|
|
131
|
-
context.rect(this.xmin, this.ymin, this.xmax - this.xmin, this.ymax - this.ymin);
|
|
132
|
-
return buffer && buffer.value();
|
|
133
|
-
}
|
|
134
|
-
renderCell(i, context) {
|
|
135
|
-
const buffer = context == null ? context = new _path.default() : undefined;
|
|
136
|
-
const points = this._clip(i);
|
|
137
|
-
if (points === null || !points.length) return;
|
|
138
|
-
context.moveTo(points[0], points[1]);
|
|
139
|
-
let n = points.length;
|
|
140
|
-
while (points[0] === points[n - 2] && points[1] === points[n - 1] && n > 1) n -= 2;
|
|
141
|
-
for (let i = 2; i < n; i += 2) {
|
|
142
|
-
if (points[i] !== points[i - 2] || points[i + 1] !== points[i - 1]) context.lineTo(points[i], points[i + 1]);
|
|
143
|
-
}
|
|
144
|
-
context.closePath();
|
|
145
|
-
return buffer && buffer.value();
|
|
146
|
-
}
|
|
147
|
-
*cellPolygons() {
|
|
148
|
-
const {
|
|
149
|
-
delaunay: {
|
|
150
|
-
points
|
|
151
|
-
}
|
|
152
|
-
} = this;
|
|
153
|
-
for (let i = 0, n = points.length / 2; i < n; ++i) {
|
|
154
|
-
const cell = this.cellPolygon(i);
|
|
155
|
-
if (cell) cell.index = i, yield cell;
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
cellPolygon(i) {
|
|
159
|
-
const polygon = new _polygon.default();
|
|
160
|
-
this.renderCell(i, polygon);
|
|
161
|
-
return polygon.value();
|
|
162
|
-
}
|
|
163
|
-
_renderSegment(x0, y0, x1, y1, context) {
|
|
164
|
-
let S;
|
|
165
|
-
const c0 = this._regioncode(x0, y0);
|
|
166
|
-
const c1 = this._regioncode(x1, y1);
|
|
167
|
-
if (c0 === 0 && c1 === 0) {
|
|
168
|
-
context.moveTo(x0, y0);
|
|
169
|
-
context.lineTo(x1, y1);
|
|
170
|
-
} else if (S = this._clipSegment(x0, y0, x1, y1, c0, c1)) {
|
|
171
|
-
context.moveTo(S[0], S[1]);
|
|
172
|
-
context.lineTo(S[2], S[3]);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
contains(i, x, y) {
|
|
176
|
-
if ((x = +x, x !== x) || (y = +y, y !== y)) return false;
|
|
177
|
-
return this.delaunay._step(i, x, y) === i;
|
|
178
|
-
}
|
|
179
|
-
*neighbors(i) {
|
|
180
|
-
const ci = this._clip(i);
|
|
181
|
-
if (ci) for (const j of this.delaunay.neighbors(i)) {
|
|
182
|
-
const cj = this._clip(j);
|
|
183
|
-
// find the common edge
|
|
184
|
-
if (cj) loop: for (let ai = 0, li = ci.length; ai < li; ai += 2) {
|
|
185
|
-
for (let aj = 0, lj = cj.length; aj < lj; aj += 2) {
|
|
186
|
-
if (ci[ai] === cj[aj] && ci[ai + 1] === cj[aj + 1] && ci[(ai + 2) % li] === cj[(aj + lj - 2) % lj] && ci[(ai + 3) % li] === cj[(aj + lj - 1) % lj]) {
|
|
187
|
-
yield j;
|
|
188
|
-
break loop;
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
_cell(i) {
|
|
195
|
-
const {
|
|
196
|
-
circumcenters,
|
|
197
|
-
delaunay: {
|
|
198
|
-
inedges,
|
|
199
|
-
halfedges,
|
|
200
|
-
triangles
|
|
201
|
-
}
|
|
202
|
-
} = this;
|
|
203
|
-
const e0 = inedges[i];
|
|
204
|
-
if (e0 === -1) return null; // coincident point
|
|
205
|
-
const points = [];
|
|
206
|
-
let e = e0;
|
|
207
|
-
do {
|
|
208
|
-
const t = Math.floor(e / 3);
|
|
209
|
-
points.push(circumcenters[t * 2], circumcenters[t * 2 + 1]);
|
|
210
|
-
e = e % 3 === 2 ? e - 2 : e + 1;
|
|
211
|
-
if (triangles[e] !== i) break; // bad triangulation
|
|
212
|
-
e = halfedges[e];
|
|
213
|
-
} while (e !== e0 && e !== -1);
|
|
214
|
-
return points;
|
|
215
|
-
}
|
|
216
|
-
_clip(i) {
|
|
217
|
-
// degenerate case (1 valid point: return the box)
|
|
218
|
-
if (i === 0 && this.delaunay.hull.length === 1) {
|
|
219
|
-
return [this.xmax, this.ymin, this.xmax, this.ymax, this.xmin, this.ymax, this.xmin, this.ymin];
|
|
220
|
-
}
|
|
221
|
-
const points = this._cell(i);
|
|
222
|
-
if (points === null) return null;
|
|
223
|
-
const {
|
|
224
|
-
vectors: V
|
|
225
|
-
} = this;
|
|
226
|
-
const v = i * 4;
|
|
227
|
-
return this._simplify(V[v] || V[v + 1] ? this._clipInfinite(i, points, V[v], V[v + 1], V[v + 2], V[v + 3]) : this._clipFinite(i, points));
|
|
228
|
-
}
|
|
229
|
-
_clipFinite(i, points) {
|
|
230
|
-
const n = points.length;
|
|
231
|
-
let P = null;
|
|
232
|
-
let x0,
|
|
233
|
-
y0,
|
|
234
|
-
x1 = points[n - 2],
|
|
235
|
-
y1 = points[n - 1];
|
|
236
|
-
let c0,
|
|
237
|
-
c1 = this._regioncode(x1, y1);
|
|
238
|
-
let e0,
|
|
239
|
-
e1 = 0;
|
|
240
|
-
for (let j = 0; j < n; j += 2) {
|
|
241
|
-
x0 = x1, y0 = y1, x1 = points[j], y1 = points[j + 1];
|
|
242
|
-
c0 = c1, c1 = this._regioncode(x1, y1);
|
|
243
|
-
if (c0 === 0 && c1 === 0) {
|
|
244
|
-
e0 = e1, e1 = 0;
|
|
245
|
-
if (P) P.push(x1, y1);else P = [x1, y1];
|
|
246
|
-
} else {
|
|
247
|
-
let S, sx0, sy0, sx1, sy1;
|
|
248
|
-
if (c0 === 0) {
|
|
249
|
-
if ((S = this._clipSegment(x0, y0, x1, y1, c0, c1)) === null) continue;
|
|
250
|
-
[sx0, sy0, sx1, sy1] = S;
|
|
251
|
-
} else {
|
|
252
|
-
if ((S = this._clipSegment(x1, y1, x0, y0, c1, c0)) === null) continue;
|
|
253
|
-
[sx1, sy1, sx0, sy0] = S;
|
|
254
|
-
e0 = e1, e1 = this._edgecode(sx0, sy0);
|
|
255
|
-
if (e0 && e1) this._edge(i, e0, e1, P, P.length);
|
|
256
|
-
if (P) P.push(sx0, sy0);else P = [sx0, sy0];
|
|
257
|
-
}
|
|
258
|
-
e0 = e1, e1 = this._edgecode(sx1, sy1);
|
|
259
|
-
if (e0 && e1) this._edge(i, e0, e1, P, P.length);
|
|
260
|
-
if (P) P.push(sx1, sy1);else P = [sx1, sy1];
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
if (P) {
|
|
264
|
-
e0 = e1, e1 = this._edgecode(P[0], P[1]);
|
|
265
|
-
if (e0 && e1) this._edge(i, e0, e1, P, P.length);
|
|
266
|
-
} else if (this.contains(i, (this.xmin + this.xmax) / 2, (this.ymin + this.ymax) / 2)) {
|
|
267
|
-
return [this.xmax, this.ymin, this.xmax, this.ymax, this.xmin, this.ymax, this.xmin, this.ymin];
|
|
268
|
-
}
|
|
269
|
-
return P;
|
|
270
|
-
}
|
|
271
|
-
_clipSegment(x0, y0, x1, y1, c0, c1) {
|
|
272
|
-
// for more robustness, always consider the segment in the same order
|
|
273
|
-
const flip = c0 < c1;
|
|
274
|
-
if (flip) [x0, y0, x1, y1, c0, c1] = [x1, y1, x0, y0, c1, c0];
|
|
275
|
-
while (true) {
|
|
276
|
-
if (c0 === 0 && c1 === 0) return flip ? [x1, y1, x0, y0] : [x0, y0, x1, y1];
|
|
277
|
-
if (c0 & c1) return null;
|
|
278
|
-
let x,
|
|
279
|
-
y,
|
|
280
|
-
c = c0 || c1;
|
|
281
|
-
if (c & 0b1000) x = x0 + (x1 - x0) * (this.ymax - y0) / (y1 - y0), y = this.ymax;else if (c & 0b0100) x = x0 + (x1 - x0) * (this.ymin - y0) / (y1 - y0), y = this.ymin;else if (c & 0b0010) y = y0 + (y1 - y0) * (this.xmax - x0) / (x1 - x0), x = this.xmax;else y = y0 + (y1 - y0) * (this.xmin - x0) / (x1 - x0), x = this.xmin;
|
|
282
|
-
if (c0) x0 = x, y0 = y, c0 = this._regioncode(x0, y0);else x1 = x, y1 = y, c1 = this._regioncode(x1, y1);
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
_clipInfinite(i, points, vx0, vy0, vxn, vyn) {
|
|
286
|
-
let P = Array.from(points),
|
|
287
|
-
p;
|
|
288
|
-
if (p = this._project(P[0], P[1], vx0, vy0)) P.unshift(p[0], p[1]);
|
|
289
|
-
if (p = this._project(P[P.length - 2], P[P.length - 1], vxn, vyn)) P.push(p[0], p[1]);
|
|
290
|
-
if (P = this._clipFinite(i, P)) {
|
|
291
|
-
for (let j = 0, n = P.length, c0, c1 = this._edgecode(P[n - 2], P[n - 1]); j < n; j += 2) {
|
|
292
|
-
c0 = c1, c1 = this._edgecode(P[j], P[j + 1]);
|
|
293
|
-
if (c0 && c1) j = this._edge(i, c0, c1, P, j), n = P.length;
|
|
294
|
-
}
|
|
295
|
-
} else if (this.contains(i, (this.xmin + this.xmax) / 2, (this.ymin + this.ymax) / 2)) {
|
|
296
|
-
P = [this.xmin, this.ymin, this.xmax, this.ymin, this.xmax, this.ymax, this.xmin, this.ymax];
|
|
297
|
-
}
|
|
298
|
-
return P;
|
|
299
|
-
}
|
|
300
|
-
_edge(i, e0, e1, P, j) {
|
|
301
|
-
while (e0 !== e1) {
|
|
302
|
-
let x, y;
|
|
303
|
-
switch (e0) {
|
|
304
|
-
case 0b0101:
|
|
305
|
-
e0 = 0b0100;
|
|
306
|
-
continue;
|
|
307
|
-
// top-left
|
|
308
|
-
case 0b0100:
|
|
309
|
-
e0 = 0b0110, x = this.xmax, y = this.ymin;
|
|
310
|
-
break;
|
|
311
|
-
// top
|
|
312
|
-
case 0b0110:
|
|
313
|
-
e0 = 0b0010;
|
|
314
|
-
continue;
|
|
315
|
-
// top-right
|
|
316
|
-
case 0b0010:
|
|
317
|
-
e0 = 0b1010, x = this.xmax, y = this.ymax;
|
|
318
|
-
break;
|
|
319
|
-
// right
|
|
320
|
-
case 0b1010:
|
|
321
|
-
e0 = 0b1000;
|
|
322
|
-
continue;
|
|
323
|
-
// bottom-right
|
|
324
|
-
case 0b1000:
|
|
325
|
-
e0 = 0b1001, x = this.xmin, y = this.ymax;
|
|
326
|
-
break;
|
|
327
|
-
// bottom
|
|
328
|
-
case 0b1001:
|
|
329
|
-
e0 = 0b0001;
|
|
330
|
-
continue;
|
|
331
|
-
// bottom-left
|
|
332
|
-
case 0b0001:
|
|
333
|
-
e0 = 0b0101, x = this.xmin, y = this.ymin;
|
|
334
|
-
break;
|
|
335
|
-
// left
|
|
336
|
-
}
|
|
337
|
-
// Note: this implicitly checks for out of bounds: if P[j] or P[j+1] are
|
|
338
|
-
// undefined, the conditional statement will be executed.
|
|
339
|
-
if ((P[j] !== x || P[j + 1] !== y) && this.contains(i, x, y)) {
|
|
340
|
-
P.splice(j, 0, x, y), j += 2;
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
return j;
|
|
344
|
-
}
|
|
345
|
-
_project(x0, y0, vx, vy) {
|
|
346
|
-
let t = Infinity,
|
|
347
|
-
c,
|
|
348
|
-
x,
|
|
349
|
-
y;
|
|
350
|
-
if (vy < 0) {
|
|
351
|
-
// top
|
|
352
|
-
if (y0 <= this.ymin) return null;
|
|
353
|
-
if ((c = (this.ymin - y0) / vy) < t) y = this.ymin, x = x0 + (t = c) * vx;
|
|
354
|
-
} else if (vy > 0) {
|
|
355
|
-
// bottom
|
|
356
|
-
if (y0 >= this.ymax) return null;
|
|
357
|
-
if ((c = (this.ymax - y0) / vy) < t) y = this.ymax, x = x0 + (t = c) * vx;
|
|
358
|
-
}
|
|
359
|
-
if (vx > 0) {
|
|
360
|
-
// right
|
|
361
|
-
if (x0 >= this.xmax) return null;
|
|
362
|
-
if ((c = (this.xmax - x0) / vx) < t) x = this.xmax, y = y0 + (t = c) * vy;
|
|
363
|
-
} else if (vx < 0) {
|
|
364
|
-
// left
|
|
365
|
-
if (x0 <= this.xmin) return null;
|
|
366
|
-
if ((c = (this.xmin - x0) / vx) < t) x = this.xmin, y = y0 + (t = c) * vy;
|
|
367
|
-
}
|
|
368
|
-
return [x, y];
|
|
369
|
-
}
|
|
370
|
-
_edgecode(x, y) {
|
|
371
|
-
return (x === this.xmin ? 0b0001 : x === this.xmax ? 0b0010 : 0b0000) | (y === this.ymin ? 0b0100 : y === this.ymax ? 0b1000 : 0b0000);
|
|
372
|
-
}
|
|
373
|
-
_regioncode(x, y) {
|
|
374
|
-
return (x < this.xmin ? 0b0001 : x > this.xmax ? 0b0010 : 0b0000) | (y < this.ymin ? 0b0100 : y > this.ymax ? 0b1000 : 0b0000);
|
|
375
|
-
}
|
|
376
|
-
_simplify(P) {
|
|
377
|
-
if (P && P.length > 4) {
|
|
378
|
-
for (let i = 0; i < P.length; i += 2) {
|
|
379
|
-
const j = (i + 2) % P.length,
|
|
380
|
-
k = (i + 4) % P.length;
|
|
381
|
-
if (P[i] === P[j] && P[j] === P[k] || P[i + 1] === P[j + 1] && P[j + 1] === P[k + 1]) {
|
|
382
|
-
P.splice(j, 2), i -= 2;
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
if (!P.length) P = null;
|
|
386
|
-
}
|
|
387
|
-
return P;
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
exports.default = Voronoi;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
ISC License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2021, Mapbox
|
|
4
|
-
|
|
5
|
-
Permission to use, copy, modify, and/or distribute this software for any purpose
|
|
6
|
-
with or without fee is hereby granted, provided that the above copyright notice
|
|
7
|
-
and this permission notice appear in all copies.
|
|
8
|
-
|
|
9
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
10
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
11
|
-
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
12
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
|
13
|
-
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
|
14
|
-
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
|
15
|
-
THIS SOFTWARE.
|