Show / Hide Table of Contents

Class Voronator

Computes a voronoi diagram in a 2d plane, optionally clipped to a rectangle.

Inheritance
System.Object
Voronator
Namespace: Sylves
Assembly: Sylves.dll
Syntax
public class Voronator : Object

Constructors

Voronator(IList<Vector2>)

Declaration
public Voronator(IList<Vector2> points)
Parameters
Type Name Description
System.Collections.Generic.IList<Vector2> points

Voronator(IList<Vector2>, Vector2, Vector2)

Declaration
public Voronator(IList<Vector2> points, Vector2 clipMin, Vector2 clipMax)
Parameters
Type Name Description
System.Collections.Generic.IList<Vector2> points
Vector2 clipMin
Vector2 clipMax

Properties

Delaunator

Declaration
public Delaunator Delaunator { get; }
Property Value
Type Description
Delaunator

Inedges

Declaration
public int[] Inedges { get; }
Property Value
Type Description
System.Int32[]

TriangleVertices

Declaration
public List<Vector2> TriangleVertices { get; }
Property Value
Type Description
System.Collections.Generic.List<Vector2>

Methods

ClippedNeighbors(Int32)

Returns the Voronoi cells that border the given cell. This uses clipping.

Declaration
public IEnumerable<int> ClippedNeighbors(int i)
Parameters
Type Name Description
System.Int32 i
Returns
Type Description
System.Collections.Generic.IEnumerable<System.Int32>

Find(Vector2, Int32)

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.

System.Int32 i

Optional, the voronoi cell to start the search at. Useful if you know the returned cell will be nearby.

Returns
Type Description
System.Int32

GetCentroid(List<Vector2>)

Declaration
public static Vector2 GetCentroid(List<Vector2> points)
Parameters
Type Name Description
System.Collections.Generic.List<Vector2> points
Returns
Type Description
Vector2

GetClippedPolygon(Int32)

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
System.Int32 i
Returns
Type Description
System.Collections.Generic.List<Vector2>

GetPolygon(Int32)

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
System.Int32 i
Returns
Type Description
System.Collections.Generic.List<Vector2>

GetPolygon(Int32, 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
System.Int32 i

The voronoi cell

System.Collections.Generic.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
System.Boolean

True if successful

GetPolygonStatus(Int32)

Declaration
public Voronator.PolygonStatus GetPolygonStatus(int i)
Parameters
Type Name Description
System.Int32 i
Returns
Type Description
Voronator.PolygonStatus

GetRelaxedPoints()

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 inowards.

Declaration
public List<Vector2> GetRelaxedPoints()
Returns
Type Description
System.Collections.Generic.List<Vector2>

Neighbors(Int32)

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
System.Int32 i
Returns
Type Description
System.Collections.Generic.IEnumerable<System.Int32>
In This Article
Back to top Generated by DocFX