I’m making a Voronoi diagram using the Delaunay method, and I’ve managed to find the vertices for the Voronoi diagram, but I can’t figure out how to group them to the correct voronoi cell (the delaunay point they are closest to). The problem I’m having is that some Voronoi vertices are part of multiple cells. When I check which Delaunay point the vertex is closest to, I don’t know how to calculate which other Delaunay points it also belongs to. (well I kind of did it but it doesn’t always work, sometimes vertices that are not supposed to be part of a cell get added to it, and sometimes there’s not enough vertices to make the cell)
Here’s an image of it working properly:
But of course it doesn’t always work, and I end up getting some strange problems:
(there is also a slight problem with the ear clipping, but I’ll fix that later)
Pretty much what I did was, for every Voronoi edge (calculated by connecting adjacent Delaunay triangle centres) it looks for the closest Delaunay edge and then adds the Voronoi vertices to the cells of the two Delaunay points that make the edge. (then use ear clipping to create it)
I’ve tried other things like finding the closest Delaunay point to a Voronoi vertex. This was the closest I ever got, by comparing the closest point to all the other Delaunay points and seeing if the distance is equal, but even if the decimal is off by like .00000001 it will not count as equal. So I tried rounding it but then too many vertexes were equal. I also tried trimming the number down so instead of like 0.123456789 it would be 0.1234567 but this still doesn’t work for all cases (it was close though). It’s either too precise or not precise enough…
Sorry if this is doesn’t make sense, I wasn’t sure how to explain it