Closed Telzhaak closed 2 years ago
Hi! The idea of that iterator is to walk over each edge (a,b) of a voronoi cell, where a and b are sequential vertices of the cell; since the cell is closed the last vertex and the first are connected by an edge (thus the chain).
I think part of the problem here is in the logic I used to extend vertices in the hull here:
The idea was to take the voronoi vertices for the cells on the hull and expand them far enough such that when the clipping logic runs, the edges are clipped and the cell is closed along the box's edge.
I am not certain, but it would be interesting to multiply this scale by a large number and run your example above to see if it helps. I think this may help the left up corner from your picture above.
I am just a bit unsure because I was expecting, without clipping enabled, that the vertex pointed above to be extended way past of the bounding box based on the extension logic above.
All I said above may help the top left corner, although the right bottom one clearly seems to be an issue in the clipping logic, and not on the extension.
Regarding the
https://github.com/andreesteve/voronoice/blob/9df72656ed73f7c5541d390e27d082af0c6361a2/src/cell_builder.rs#L96
you are correct,
increasing scale
to e.g. 2_000_000.0 fixed the issue in the top left.
The underlying problem was, that orthogonal
in
https://github.com/andreesteve/voronoice/blob/9df72656ed73f7c5541d390e27d082af0c6361a2/src/cell_builder.rs#L80
was not
normalized (length can be nearly 0), and thus the resulting edge was not extended to be at least twice the boundary-diagonal.
I added a fix for this one in #3, since its so minor
The other problem still resides though:
I just noticed that the points in this test case also cause the corners to be missing. Since this is a repro with only 3 points, sharing here so I can investigate later: https://github.com/andreesteve/voronoice/blob/ef4738b734faca203756cd4d550678df0f23079c/src/iterator.rs#L248
This should be fixed with the refactoring around the clipping logic I pushed to master. If you could give it a try on your input and let me know the results, I'd appreciate. If the issue still persists, let's reopen this one. Thanks.
As mentioned in #3, the corners of the Voronoi-Diagram sometimes get removed.
Comparing the same points and bounding boxes, with and without![Voronoice_Corners_due_to_clipping](https://user-images.githubusercontent.com/29286474/105580077-7e412280-5d8a-11eb-98a2-b70981063978.PNG)
Clipping
yielded the following results, Where I shifted the points after generating the Diagram, to show both outputs side by side:Something in https://github.com/andreesteve/voronoice/blob/9df72656ed73f7c5541d390e27d082af0c6361a2/src/cell_builder.rs#L125 is broken, but i have trouble understanding the iterator https://github.com/andreesteve/voronoice/blob/9df72656ed73f7c5541d390e27d082af0c6361a2/src/cell_builder.rs#L143-L147 so i wasn't able to fix it.