- Object
-
- SweepLine
-
- All Implemented Interfaces:
Decomposer
,Triangulator
public class SweepLine extends Object implements Decomposer, Triangulator
Implementation of the Sweep convex decomposition algorithm for simple polygons.This algorithm first decomposes the polygon into y-monotone polygons, then decomposes the y-monotone polygons into triangles, finally using the Hertel-Mehlhorn algorithm to recombine the triangles into convex pieces.
This algorithm is O(n log n) complexity in the y-monotone decomposition phase and O(n) in the triangulation phase yielding a total complexity of O(n log n).
After triangulation, the Hertel-Mehlhorn algorithm is used to reduce the number of convex pieces. This is performed in O(n) time.
This algorithm total complexity is O(n log n).
- Since:
- 2.2.0
- Version:
- 3.4.0
- Author:
- William Bittle
-
-
Constructor Summary
Constructors Constructor Description SweepLine()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description List<Convex>
decompose(Vector2... points)
Performs the decomposition on the given polygon returning a list ofConvex
shapes.List<Triangle>
triangulate(Vector2... points)
Performs the triangulation on the given polygon returning a list ofTriangle
s.
-
-
-
Method Detail
-
decompose
public List<Convex> decompose(Vector2... points)
Description copied from interface:Decomposer
Performs the decomposition on the given polygon returning a list ofConvex
shapes.- Specified by:
decompose
in interfaceDecomposer
- Parameters:
points
- the polygon vertices- Returns:
- List<
Convex
>
-
triangulate
public List<Triangle> triangulate(Vector2... points)
Description copied from interface:Triangulator
Performs the triangulation on the given polygon returning a list ofTriangle
s.- Specified by:
triangulate
in interfaceTriangulator
- Parameters:
points
- the polygon vertices- Returns:
- List<
Triangle
>
-
-