As this shows, you can use it to filter a delaunay triangulation and get a perfect limit.
Can anybody explain the magik algorithm?
As this shows, you can use it to filter a delaunay triangulation and get a perfect limit.
Can anybody explain the magik algorithm?
There isn't really much magic beyond classic Delaunay triangulation algorithm, which is implemented as function d3.geom.delaunay()
within D3.
In the example you linked to, alpha shapes are implemented as modified Delaunay triangulation, in such a way so that any triangle that has at least one side larger than alpha
(in the example it has value 50
) is removed from triangulation.
That's why the result looks like this: (original vertexes, Delaunay triangulation, and Alpha shape)
d3.geom.delaunay()
returns array of triangles, so this code:
mesh = d3.geom.delaunay(offset(vertices,600,0)).filter(function(t) {
return dsq(t[0],t[1]) < asq && dsq(t[0],t[2]) < asq && dsq(t[1],t[2]) < asq;
});
together with fact that asq
is alpha
squared, and dsq()
is function that computes squared distance between two points in the plane, causes removing any triangle with at least one side larger than alpha
, which in turn produces the third image in the picture above.
Hope this helps.
Alpha shapes is when you remove any edges exceeding alpha from the delaunay triangulation. You can either use lines or disks to show alpha visually but the goal is to find a concave hull. Read here to find the concave hull:Calculate bounding polygon of alpha shape from the Delaunay triangulation.