Module imagingbook.common
Class TriangulationGuibas
java.lang.Object
imagingbook.common.geometry.delaunay.guibas.TriangulationGuibas
- All Implemented Interfaces:
DelaunayTriangulation
This is an implementation of the triangulation algorithm described in [1].
[1] L. J. Guibas, D. E. Knuth, and M. Sharir" "Randomized incremental construction of Delaunay and Voronoi diagrams", Algorithmica, 7, pp. 381--413 (1992).
-
Constructor Summary
ConstructorsConstructorDescriptionTriangulationGuibas
(Collection<? extends Pnt2d> points) Constructor.TriangulationGuibas
(Collection<? extends Pnt2d> points, boolean shuffle) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionfindContainingTriangle
(Pnt2d point) Returns the triangle that contains the specified point or null if no such triangle exists.findNearestEdge
(Pnt2d point) Returns the triangle edge nearest to the specified point.findNeighbour
(Triangle2D tri1, Edge2D edge) Returns the neighboring triangle of the specified triangle sharing the same edge as specified.findOneTriangleSharing
(Edge2D edge) Returns one of the possible triangles sharing the specified edge.Returns a list of 2D vertices contained in this triangulation.Returns a list ofTriangle
instances contained in this triangulation.void
removeTrianglesUsing
(Pnt2d point) Removes all triangles that contain the specified corner point.int
size()
Returns the number of triangles in this triangulation.
-
Constructor Details
-
TriangulationGuibas
Constructor.- Parameters:
points
- the point set to be triangulatedshuffle
- settrue
to randomly shuffle the input points
-
TriangulationGuibas
Constructor. Supplied points are inserted without shuffling, i.e., in their original order.- Parameters:
points
- the point set to be triangulated
-
-
Method Details
-
size
Description copied from interface:DelaunayTriangulation
Returns the number of triangles in this triangulation.- Specified by:
size
in interfaceDelaunayTriangulation
- Returns:
- the number of triangles
-
getTriangles
Description copied from interface:DelaunayTriangulation
Returns a list ofTriangle
instances contained in this triangulation. The list does not contain the initial outer triangle.- Specified by:
getTriangles
in interfaceDelaunayTriangulation
- Returns:
- a list of triangles
-
getPoints
Description copied from interface:DelaunayTriangulation
Returns a list of 2D vertices contained in this triangulation. The list does not contain the vertices of the initial (outer) triangle.- Specified by:
getPoints
in interfaceDelaunayTriangulation
- Returns:
- a list of points
-
findContainingTriangle
Returns the triangle that contains the specified point or null if no such triangle exists.- Parameters:
point
- the query point- Returns:
- the containing triangle or
null
if none was found
-
findNeighbour
Returns the neighboring triangle of the specified triangle sharing the same edge as specified. If no neighbor sharing the same edge existsnull
is returned. NOTE: Searching over ALL triangles seems to be unnecessarily expensive!- Parameters:
tri1
- the triangleedge
- the edge- Returns:
- the triangle's neighboring triangle sharing the same edge or
null
if no such triangle exists
-
findOneTriangleSharing
Returns one of the possible triangles sharing the specified edge. Based on the ordering of the triangles in this triangle soup the returned triangle may differ. To find the other triangle that shares this edge use thefindNeighbour(Triangle2D triangle, Edge2D edge)
method.- Parameters:
edge
- the edge- Returns:
- the triangle that shares the specified edge or
null
if none exists
-
findNearestEdge
Returns the triangle edge nearest to the specified point.- Parameters:
point
- the query point- Returns:
- the triangle edge nearest to the specified point
-
removeTrianglesUsing
Removes all triangles that contain the specified corner point.- Parameters:
point
- the corner point
-