()
| 25627 | return (this._delaunator.update(), this._init(), this); |
| 25628 | } |
| 25629 | _init() { |
| 25630 | const t = this._delaunator, |
| 25631 | e = this.points; |
| 25632 | if ( |
| 25633 | t.hull && |
| 25634 | t.hull.length > 2 && |
| 25635 | (function (t) { |
| 25636 | const { triangles: e, coords: n } = t; |
| 25637 | for (let t = 0; t < e.length; t += 3) { |
| 25638 | const r = 2 * e[t], |
| 25639 | i = 2 * e[t + 1], |
| 25640 | o = 2 * e[t + 2]; |
| 25641 | if ( |
| 25642 | (n[o] - n[r]) * (n[i + 1] - n[r + 1]) - |
| 25643 | (n[i] - n[r]) * (n[o + 1] - n[r + 1]) > |
| 25644 | 1e-10 |
| 25645 | ) |
| 25646 | return !1; |
| 25647 | } |
| 25648 | return !0; |
| 25649 | })(t) |
| 25650 | ) { |
| 25651 | this.collinear = Int32Array.from( |
| 25652 | { length: e.length / 2 }, |
| 25653 | (t, e) => e, |
| 25654 | ).sort((t, n) => e[2 * t] - e[2 * n] || e[2 * t + 1] - e[2 * n + 1]); |
| 25655 | const t = this.collinear[0], |
| 25656 | n = this.collinear[this.collinear.length - 1], |
| 25657 | r = [e[2 * t], e[2 * t + 1], e[2 * n], e[2 * n + 1]], |
| 25658 | i = 1e-8 * Math.hypot(r[3] - r[1], r[2] - r[0]); |
| 25659 | for (let t = 0, n = e.length / 2; t < n; ++t) { |
| 25660 | const n = rS(e[2 * t], e[2 * t + 1], i); |
| 25661 | ((e[2 * t] = n[0]), (e[2 * t + 1] = n[1])); |
| 25662 | } |
| 25663 | this._delaunator = new PF(e); |
| 25664 | } else delete this.collinear; |
| 25665 | const n = (this.halfedges = this._delaunator.halfedges), |
| 25666 | r = (this.hull = this._delaunator.hull), |
| 25667 | i = (this.triangles = this._delaunator.triangles), |
| 25668 | o = this.inedges.fill(-1), |
| 25669 | a = this._hullIndex.fill(-1); |
| 25670 | for (let t = 0, e = n.length; t < e; ++t) { |
| 25671 | const e = i[t % 3 == 2 ? t - 2 : t + 1]; |
| 25672 | (-1 !== n[t] && -1 !== o[e]) || (o[e] = t); |
| 25673 | } |
| 25674 | for (let t = 0, e = r.length; t < e; ++t) a[r[t]] = t; |
| 25675 | r.length <= 2 && |
| 25676 | r.length > 0 && |
| 25677 | ((this.triangles = new Int32Array(3).fill(-1)), |
| 25678 | (this.halfedges = new Int32Array(3).fill(-1)), |
| 25679 | (this.triangles[0] = r[0]), |
| 25680 | (o[r[0]] = 1), |
| 25681 | 2 === r.length && |
| 25682 | ((o[r[1]] = 0), |
| 25683 | (this.triangles[1] = r[1]), |
| 25684 | (this.triangles[2] = r[1]))); |
| 25685 | } |
| 25686 | voronoi(t) { |
no test coverage detected