[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)
|
||||
|
||||
@@ -5,6 +5,25 @@ import org.openrndr.extra.triangulation.delaunayTriangulation
|
||||
import org.openrndr.math.Vector2
|
||||
import org.openrndr.shape.Circle
|
||||
|
||||
/**
|
||||
* Entry point of the application.
|
||||
*
|
||||
* This method sets up a graphical application using the OPENRNDR framework
|
||||
* to visually demonstrate Delaunay triangulation on a set of points scattered
|
||||
* along a circle with Poisson disk sampling.
|
||||
*
|
||||
* The application features the following:
|
||||
* - A central circle with a defined radius.
|
||||
* - Points generated within the circle using a scatter algorithm that
|
||||
* maintains specific spacing and avoids clustering.
|
||||
* - Delaunay triangulation computed from the combined point set.
|
||||
* - Rendering of triangles that are part of the Delaunay triangulation.
|
||||
* - Visual styling with dynamic color shading for better clarity of layers
|
||||
* and triangle order.
|
||||
*
|
||||
* This method demonstrates concepts of computational geometry and procedural
|
||||
* rendering with a focus on interactive visual applications.
|
||||
*/
|
||||
fun main() {
|
||||
application {
|
||||
configure {
|
||||
|
||||
@@ -6,6 +6,17 @@ import org.openrndr.math.Vector2
|
||||
import org.openrndr.shape.Circle
|
||||
import org.openrndr.shape.Rectangle
|
||||
|
||||
/**
|
||||
* This program generates a Voronoi diagram within a defined circular area and visualizes it.
|
||||
*
|
||||
* The program performs the following:
|
||||
* - Defines a circular area and a rectangular bounding frame within the canvas.
|
||||
* - Uses Poisson Disk Sampling to generate points within the circular area.
|
||||
* - Computes the Delaunay triangulation for the generated points, including equidistant points on the circle boundary.
|
||||
* - Derives the Voronoi diagram using the Delaunay triangulation and the bounding frame.
|
||||
* - Extracts the cell polygons of the Voronoi diagram.
|
||||
* - Renders the Voronoi cell polygons on the canvas, with a pink stroke on a black background.
|
||||
*/
|
||||
fun main() {
|
||||
application {
|
||||
configure {
|
||||
|
||||
Reference in New Issue
Block a user