Sha256: 047da61fc8722c6acf750c352913dba0a7dbb12673ae1dd66879e1c485bb2dbd
Contents?: true
Size: 844 Bytes
Versions: 4
Compression:
Stored size: 844 Bytes
Contents
import "geom"; import "voronoi"; // @deprecated; use d3.geom.voronoi links instead. d3.geom.delaunay = function(vertices) { var edges = vertices.map(function() { return []; }), triangles = []; // Use the Voronoi tessellation to determine Delaunay edges. d3_geom_voronoiTessellate(vertices, function(e) { edges[e.region.l.index].push(vertices[e.region.r.index]); }); // Reconnect the edges into counterclockwise triangles. edges.forEach(function(edge, i) { var v = vertices[i], cx = v[0], cy = v[1]; edge.forEach(function(v) { v.angle = Math.atan2(v[0] - cx, v[1] - cy); }); edge.sort(function(a, b) { return a.angle - b.angle; }); for (var j = 0, m = edge.length - 1; j < m; j++) { triangles.push([v, edge[j], edge[j + 1]]); } }); return triangles; };
Version data entries
4 entries across 4 versions & 2 rubygems