问题
I'm trying to implement Delaunay Triangulation. However, I seem to be having a problem with edges creating overlapping triangles:
I'm basing my implementation as described on this site. I'm just using a brute force loop to check whether or not an edge already exists in the set.
v = vertex to be added
edgeBuffer = [];
for each triangle
if v is in the triangle's circumscribed circle
for each edge in the triangle
check if it's already in edgeBuffer
if not, add it
remove triangle
I suspect that it's another part of my algorithm that's going wrong and causing this to happen, but I have implemented everything in a pretty straightforward manner. What is wrong with this code? Fiddle
回答1:
If the edge already exist in the edge buffer and its not the first triangle after the super triangle it needs to be removed from the edge buffer and not to skip the loop. The vertices of this edge are needed for the new computation. Just reinsert the vertices in your other buffer or remove the edge from edge buffer.
来源:https://stackoverflow.com/questions/29639924/duplicate-edges-not-being-removed-in-delaunay-triangle-construction