Duplicate edges not being removed in Delaunay Tria

2019-06-13 18:37发布

I'm trying to implement Delaunay Triangulation. However, I seem to be having a problem with edges creating overlapping triangles:

enter image description here

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条回答
甜甜的少女心
2楼-- · 2019-06-13 19:18

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.

查看更多
登录 后发表回答