Class EuclideanUtils
java.lang.Object
org.apache.commons.geometry.euclidean.internal.EuclideanUtils
Class containing utilities and algorithms intended to be internal to the library.
Absolutely no guarantees are made regarding the stability of this API.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
Number of vertices in a triangle, i.e. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> List
<T> Convert a convex polygon defined by a list of vertices into a triangle fan.private static int
findBestTriangleFanIndex
(List<Vector3D> vertices) Find the index of the best vertex to use as the base for a triangle fan split of the convex polygon defined by the given vertices.
-
Field Details
-
TRIANGLE_VERTEX_COUNT
public static final int TRIANGLE_VERTEX_COUNTNumber of vertices in a triangle, i.e.3
.- See Also:
-
-
Constructor Details
-
EuclideanUtils
private EuclideanUtils()Utility class; no instantiation.
-
-
Method Details
-
convexPolygonToTriangleFan
public static <T> List<T> convexPolygonToTriangleFan(List<Vector3D> vertices, Function<List<Vector3D>, T> fn) Convert a convex polygon defined by a list of vertices into a triangle fan. The vertex forming the largest interior angle in the polygon is selected as the base of the triangle fan. Callers are responsible for ensuring that the given list of vertices define a geometrically valid convex polygon; no validation (except for a check on the minimum number of vertices) is performed.- Type Parameters:
T
- triangle result type- Parameters:
vertices
- vertices defining a convex polygonfn
- function accepting the vertices of each triangle as a list and returning the object used to represent that triangle in the result; each argument to this function is guaranteed to contain 3 vertices- Returns:
- a list containing the return results of the function when passed the vertices for each triangle in order
- Throws:
IllegalArgumentException
- if fewer than 3 vertices are given
-
findBestTriangleFanIndex
Find the index of the best vertex to use as the base for a triangle fan split of the convex polygon defined by the given vertices. The best vertex is the one that forms the largest interior angle in the polygon since a split at that point will help prevent the creation of very thin triangles.- Parameters:
vertices
- vertices defining the convex polygon; must not be empty; no validation is performed to ensure that the vertices actually define a convex polygon- Returns:
- the index of the best vertex to use as the base for a triangle fan split of the convex polygon
-