[orx-triangulation] Add generated and verified documentation
This commit is contained in:
@@ -222,5 +222,11 @@ class Delaunay(val points: DoubleArray) {
|
||||
return c
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a Voronoi diagram based on the current Delaunay triangulation and the provided bounds.
|
||||
*
|
||||
* @param bounds A rectangle defining the boundaries within which the Voronoi diagram will be generated.
|
||||
* @return A Voronoi instance representing the resulting Voronoi diagram.
|
||||
*/
|
||||
fun voronoi(bounds: Rectangle): Voronoi = Voronoi(this, bounds)
|
||||
}
|
||||
|
||||
@@ -81,6 +81,15 @@ class DelaunayTriangulation(val points: List<Vector2>) {
|
||||
fun nearestPoint(query: Vector2): Vector2 = points[nearest(query)]
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes the Delaunay triangulation for the list of 2D points.
|
||||
*
|
||||
* The Delaunay triangulation is a triangulation of a set of points such that
|
||||
* no point is inside the circumcircle of any triangle. It maximizes the minimum
|
||||
* angle of all the angles in the triangles, avoiding skinny triangles.
|
||||
*
|
||||
* @return A DelaunayTriangulation object representing the triangulation of the given points.
|
||||
*/
|
||||
fun List<Vector2>.delaunayTriangulation(): DelaunayTriangulation {
|
||||
return DelaunayTriangulation(this)
|
||||
}
|
||||
|
||||
@@ -81,6 +81,12 @@ class VoronoiDiagram(val delaunayTriangulation: DelaunayTriangulation, val bound
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a Voronoi diagram based on the points in the list and the provided bounds.
|
||||
*
|
||||
* @param bounds The rectangular bounds within which the Voronoi diagram is generated. Defaults to the bounds of the point list.
|
||||
* @return A VoronoiDiagram object representing the calculated Voronoi diagram.
|
||||
*/
|
||||
fun List<Vector2>.voronoiDiagram(bounds: Rectangle = this.bounds): VoronoiDiagram {
|
||||
val d = this.delaunayTriangulation()
|
||||
return d.voronoiDiagram(bounds)
|
||||
|
||||
Reference in New Issue
Block a user