Skip to content

Instantly share code, notes, and snippets.

@ttran17
ttran17 / gist:e42968619f79c1b8d1a81ba2feacdc76
Last active January 14, 2020 18:52
Generator for Voronoi cell neighbors for d3-delaunay
// Modification of delaunay.neighbors to find Voronoi cell neighbors
// This generator should be attached to delaunay.voronoi
*neighbors(i) {
const {delaunay: {inedges, hull, _hullIndex, halfedges, triangles, collinear = undefined}} = this;
// degenerate case with several collinear points
if (collinear) {
const l = collinear.indexOf(i);
if (l > 0) yield collinear[l - 1];