Class Voronator
Computes a voronoi diagram in a 2d plane,
optionally clipped to a rectangle.
Assembly: Sylves.dll
Syntax
Constructors
Voronator(IList<Vector2>)
Declaration
public Voronator(IList<Vector2> points)
Parameters
Voronator(IList<Vector2>, Vector2, Vector2)
Declaration
public Voronator(IList<Vector2> points, Vector2 clipMin, Vector2 clipMax)
Parameters
Properties
ClipMax
Declaration
public Vector2 ClipMax { get; }
Property Value
ClipMin
Declaration
public Vector2 ClipMin { get; }
Property Value
Delaunator
Declaration
public Delaunator Delaunator { get; }
Property Value
Inedges
Declaration
public int[] Inedges { get; }
Property Value
TriangleVertices
Declaration
public List<Vector2> TriangleVertices { get; }
Property Value
Methods
ClippedNeighbors(int)
Returns the Voronoi cells that border the given cell.
This uses clipping.
Declaration
public IEnumerable<int> ClippedNeighbors(int i)
Parameters
| Type |
Name |
Description |
| int |
i |
|
Returns
Find(Vector2, int)
Finds the voronoi cell that contains the given point, or equivalently,
finds the point that is nearest the given point.
This ignores clipping, so it always succeeds.
Declaration
public int Find(Vector2 u, int i = 0)
Parameters
| Type |
Name |
Description |
| Vector2 |
u |
The point to search for.
|
| int |
i |
Optional, the voronoi cell to start the search at. Useful if you know the returned cell will be nearby.
|
Returns
GetCentroid(List<Vector2>)
Declaration
public static Vector2 GetCentroid(List<Vector2> points)
Parameters
Returns
GetClippedPolygon(int)
Returns the vertices of the voronoi cell i after clipping to the clipping rectangle.
Returns null if the polygon is fully outside the clipping rectangle.
Declaration
public List<Vector2> GetClippedPolygon(int i)
Parameters
| Type |
Name |
Description |
| int |
i |
|
Returns
GetClippedRelaxedPoints()
Returns the centroid of each voronoi cell.
This is suitable for use with Lloyd relaxation.
Unbounded cells are clipped down, which tends to move them inwards.
Declaration
public List<Vector2> GetClippedRelaxedPoints()
Returns
GetPolygon(int)
Returns the vertices of the voronoi cell, without any clipping.
This means that unbounded cells will be missing the edges that extend to infinity,
and may have less than 3 vertices.
Declaration
public List<Vector2> GetPolygon(int i)
Parameters
| Type |
Name |
Description |
| int |
i |
|
Returns
GetPolygon(int, List<Vector2>, out Vector2, out Vector2)
Supplies the vertices of the voronoi cell, without any clipping.
This means that unbounded cells will be missing the edges that extend to infinity,
and may have less than 3 vertices.
Declaration
public bool GetPolygon(int i, List<Vector2> vertices, out Vector2 ray1, out Vector2 ray2)
Parameters
| Type |
Name |
Description |
| int |
i |
The voronoi cell
|
| List<Vector2> |
vertices |
Filled with the vertices of the polygon.
|
| Vector2 |
ray1 |
For unbounded cells, the direction of the ray extending from vertex 0. Otherwise, empty.
|
| Vector2 |
ray2 |
For unbounded cells, the direction of the ray extending from vertex 0. Otherwise, empty.
|
Returns
| Type |
Description |
| bool |
True if successful
|
GetPolygonStatus(int)
Declaration
public Voronator.PolygonStatus GetPolygonStatus(int i)
Parameters
| Type |
Name |
Description |
| int |
i |
|
Returns
GetRelaxedPoints()
Returns the centroid of each voronoi cell.
This is suitable for use with Lloyd relaxation.
Unbounded cells return their original point.
Declaration
public List<Vector2> GetRelaxedPoints()
Returns
Neighbors(int)
Returns the Voronoi cells that border the given cell.
This ignores clipping.
This may give surprising results in degenerate cases that more than 3 cells meet at a point.
Declaration
public IEnumerable<int> Neighbors(int i)
Parameters
| Type |
Name |
Description |
| int |
i |
|
Returns