MCPcopy Create free account
hub / github.com/alignoth/alignoth / _init

Method _init

resources/vega.min.js:25171–25230  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

25169 return (this.delaunay.update(), this._init(), this);
25170 }
25171 _init() {
25172 const {
25173 delaunay: { points: t, hull: e, triangles: n },
25174 vectors: r,
25175 } = this;
25176 let i, o;
25177 const a = (this.circumcenters = this._circumcenters.subarray(
25178 0,
25179 (n.length / 3) * 2,
25180 ));
25181 for (let r, s, u = 0, l = 0, c = n.length; u < c; u += 3, l += 2) {
25182 const c = 2 * n[u],
25183 f = 2 * n[u + 1],
25184 h = 2 * n[u + 2],
25185 d = t[c],
25186 p = t[c + 1],
25187 g = t[f],
25188 m = t[f + 1],
25189 y = t[h],
25190 v = t[h + 1],
25191 _ = g - d,
25192 x = m - p,
25193 b = y - d,
25194 w = v - p,
25195 k = 2 * (_ * w - x * b);
25196 if (Math.abs(k) < 1e-9) {
25197 if (void 0 === i) {
25198 i = o = 0;
25199 for (const n of e) ((i += t[2 * n]), (o += t[2 * n + 1]));
25200 ((i /= e.length), (o /= e.length));
25201 }
25202 const n = 1e9 * Math.sign((i - d) * w - (o - p) * b);
25203 ((r = (d + y) / 2 - n * w), (s = (p + v) / 2 + n * b));
25204 } else {
25205 const t = 1 / k,
25206 e = _ * _ + x * x,
25207 n = b * b + w * w;
25208 ((r = d + (w * e - x * n) * t), (s = p + (_ * n - b * e) * t));
25209 }
25210 ((a[l] = r), (a[l + 1] = s));
25211 }
25212 let s,
25213 u,
25214 l,
25215 c = e[e.length - 1],
25216 f = 4 * c,
25217 h = t[2 * c],
25218 d = t[2 * c + 1];
25219 r.fill(0);
25220 for (let n = 0; n < e.length; ++n)
25221 ((c = e[n]),
25222 (s = f),
25223 (u = h),
25224 (l = d),
25225 (f = 4 * c),
25226 (h = t[2 * c]),
25227 (d = t[2 * c + 1]),
25228 (r[s + 2] = r[f] = l - d),

Callers 2

constructorMethod · 0.45
updateMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected