- Object
-
- EarClipping
-
- All Implemented Interfaces:
Decomposer
,Triangulator
public class EarClipping extends Object implements Decomposer, Triangulator
Implementation of the Ear Clipping convex decomposition algorithm for simple polygons.This algorithm operates only on simple polygons. A simple polygon is a polygon that has vertices that are connected by edges where:
- Edges can only intersect at vertices
- Vertices have at most two edge connections
This implementation does not handle polygons with holes, but accepts both counter-clockwise and clockwise polygons.
The polygon to decompose must be 4 or more vertices.
This algorithm creates a valid triangulation (N - 2) triangles, then employs the Hertel-Mehlhorn algorithm to reduce the number of convex pieces.
This algorithm is O(n2).
- Since:
- 2.2.0
- Version:
- 3.2.0
- Author:
- William Bittle
-
-
Constructor Summary
Constructors Constructor Description EarClipping()
-
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
>
-
-