Package squidpony.squidmath
Class Voronoi
java.lang.Object
squidpony.squidmath.Voronoi
- All Implemented Interfaces:
Serializable
public class Voronoi extends Object implements Serializable
A Java implementation of both a 2D Delaunay triangulation algorithm and a Voronoi polygon data structure.
This is a port of Johannes Diemke's code, with
modifications
suggested by Amit Patel to consolidate the triangles with a barycentric dual mesh.
- Author:
- Johannes Diemke, Tommy Ettinger
- See Also:
- Serialized Form
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classVoronoi.Edgestatic classVoronoi.Polygonstatic classVoronoi.Triangle -
Constructor Summary
Constructors Constructor Description Voronoi()Constructs a triangulator instance but does not insert any points; you should add points togetPointSet()before runningtriangulate().Voronoi(OrderedSet<CoordDouble> pointSet)Constructs a new triangulator instance using the specified point set. -
Method Summary
Modifier and Type Method Description OrderedSet<CoordDouble>getPointSet()Returns the point set in form of a vector of 2D vectors.ArrayList<Voronoi.Triangle>getTriangles()Returns the triangles of the triangulation in form of a list of 2D triangles.ArrayList<Voronoi.Polygon>polygonize()voidreorder(int[] permutation)Shuffles the point set using a custom permutation sequence.voidshuffle(IRNG rng)Creates a random permutation of the specified point set.ArrayList<Voronoi.Triangle>triangulate()This method generates a Delaunay triangulation from the specified point set.
-
Constructor Details
-
Voronoi
public Voronoi()Constructs a triangulator instance but does not insert any points; you should add points togetPointSet()before runningtriangulate(). -
Voronoi
Constructs a new triangulator instance using the specified point set.- Parameters:
pointSet- The point set to be triangulated
-
-
Method Details
-
triangulate
This method generates a Delaunay triangulation from the specified point set. -
polygonize
-
shuffle
Creates a random permutation of the specified point set. Based on the implementation of the Delaunay algorithm, this can speed up the computation. -
reorder
Shuffles the point set using a custom permutation sequence.- Parameters:
permutation- The permutation used to shuffle the point set
-
getPointSet
Returns the point set in form of a vector of 2D vectors.- Returns:
- Returns the points set.
-
getTriangles
Returns the triangles of the triangulation in form of a list of 2D triangles.- Returns:
- Returns the triangles of the triangulation.
-