- Object
-
- AbstractDecomposer
-
- Bayazit
-
- All Implemented Interfaces:
Decomposer
public class Bayazit extends AbstractDecomposer implements Decomposer
Implementation of the Bayazit convex decomposition algorithm for simple polygons.This algorithm is a O(nr) complexity algorithm where n is the number of input vertices and r is the number of output convex polygons. This algorithm can achieve optimal decompositions, however this is not guaranteed.
- Since:
- 2.2.0
- Version:
- 5.0.0
- Author:
- William Bittle
- See Also:
- Bayazit
-
-
Constructor Summary
Constructors Constructor Description Bayazit()
-
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.protected void
decomposePolygon(List<Vector2> polygon, List<Convex> polygons)
Internal recursive method to decompose the given polygon into convex sub-polygons.protected boolean
getIntersection(Vector2 a1, Vector2 a2, Vector2 b1, Vector2 b2, Vector2 p)
Returns true if the given lines intersect and returns the intersection point in the p parameter.protected boolean
isReflex(Vector2 p0, Vector2 p, Vector2 p1)
Returns true if the given vertex, b, is a reflex vertex.protected boolean
left(Vector2 a, Vector2 b, Vector2 p)
Returns true if the given point p is to the left of the line created by a-b.protected boolean
leftOn(Vector2 a, Vector2 b, Vector2 p)
Returns true if the given point p is to the left or on the line created by a-b.protected boolean
right(Vector2 a, Vector2 b, Vector2 p)
Returns true if the given point p is to the right of the line created by a-b.protected boolean
rightOn(Vector2 a, Vector2 b, Vector2 p)
Returns true if the given point p is to the right or on the line created by a-b.-
Methods inherited from class AbstractDecomposer
decompose
-
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface Decomposer
decompose
-
-
-
-
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
>
-
decomposePolygon
protected void decomposePolygon(List<Vector2> polygon, List<Convex> polygons)
Internal recursive method to decompose the given polygon into convex sub-polygons.- Parameters:
polygon
- the polygon to decomposepolygons
- the list to store the convex polygons resulting from the decomposition
-
isReflex
protected boolean isReflex(Vector2 p0, Vector2 p, Vector2 p1)
Returns true if the given vertex, b, is a reflex vertex.A reflex vertex is a vertex who's interior angle is greater than 180 degrees.
- Parameters:
p0
- the vertex to testp
- the previous vertexp1
- the next vertex- Returns:
- boolean
-
left
protected boolean left(Vector2 a, Vector2 b, Vector2 p)
Returns true if the given point p is to the left of the line created by a-b.- Parameters:
a
- the first point of the lineb
- the second point of the linep
- the point to test- Returns:
- boolean
-
leftOn
protected boolean leftOn(Vector2 a, Vector2 b, Vector2 p)
Returns true if the given point p is to the left or on the line created by a-b.- Parameters:
a
- the first point of the lineb
- the second point of the linep
- the point to test- Returns:
- boolean
-
right
protected boolean right(Vector2 a, Vector2 b, Vector2 p)
Returns true if the given point p is to the right of the line created by a-b.- Parameters:
a
- the first point of the lineb
- the second point of the linep
- the point to test- Returns:
- boolean
-
rightOn
protected boolean rightOn(Vector2 a, Vector2 b, Vector2 p)
Returns true if the given point p is to the right or on the line created by a-b.- Parameters:
a
- the first point of the lineb
- the second point of the linep
- the point to test- Returns:
- boolean
-
getIntersection
protected boolean getIntersection(Vector2 a1, Vector2 a2, Vector2 b1, Vector2 b2, Vector2 p)
Returns true if the given lines intersect and returns the intersection point in the p parameter.- Parameters:
a1
- the first point of the first linea2
- the second point of the first lineb1
- the first point of the second lineb2
- the second point of the second linep
- the destination object for the intersection point- Returns:
- boolean
-
-