This is quite a large change, but adds functionality (e.g. clipping to no rectangular regions) and fixes issue #7 (a test is included). Details are below. As the API has changed, feel free to recommend a different one - or a version bump.
Now when calling VoronoiDiagram::new or VoronoiDiagram::from_tuple, an additional 4 'helper' points are created outside of the region defined by min and max and are input into the triangulation and Voronoi generation process. This removes the need for handling special cases for edge points in the diagram.
VoronoiDiagram::cells is now private, and a function is included (with the same name) which only returns valid cells (i.e. ignores those related to the additional 4 helper points added above). This is obviously an API change.
This looks pretty good, the Sutherland Hodgman algorithm is something I wanted to implement for a while, but never got the time to do so. I really appreciate your contribution!
This is quite a large change, but adds functionality (e.g. clipping to no rectangular regions) and fixes issue #7 (a test is included). Details are below. As the API has changed, feel free to recommend a different one - or a version bump.
Now when calling
VoronoiDiagram::new
orVoronoiDiagram::from_tuple
, an additional 4 'helper' points are created outside of the region defined bymin
andmax
and are input into the triangulation and Voronoi generation process. This removes the need for handling special cases for edge points in the diagram.VoronoiDiagram::cells
is now private, and a function is included (with the same name) which only returns valid cells (i.e. ignores those related to the additional 4 helper points added above). This is obviously an API change.Clipping is performed using the Sutherland Hodgman algorithm (https://en.wikipedia.org/wiki/Sutherland%E2%80%93Hodgman_algorithm) and so works for any arbitrary shape.
A
Polygon
struct is included.VoronoiDiagram::cells()
now returns a slice ofPolygon
A new function is included to specify an arbitrary bounding polygon
VoronoiDiagram::with_bounding_polygon
A new example of outputting Voronoi diagrams to SVG is included