Class EuclideanUtils


  • public final class EuclideanUtils
    extends java.lang.Object
    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

      Fields 
      Modifier and Type Field Description
      static int TRIANGLE_VERTEX_COUNT
      Number of vertices in a triangle, i.e.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private EuclideanUtils()
      Utility class; no instantiation.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> java.util.List<T> convexPolygonToTriangleFan​(java.util.List<Vector3D> vertices, java.util.function.Function<java.util.List<Vector3D>,​T> fn)
      Convert a convex polygon defined by a list of vertices into a triangle fan.
      private static int findBestTriangleFanIndex​(java.util.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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • TRIANGLE_VERTEX_COUNT

        public static final int TRIANGLE_VERTEX_COUNT
        Number of vertices in a triangle, i.e. 3.
        See Also:
        Constant Field Values
    • Constructor Detail

      • EuclideanUtils

        private EuclideanUtils()
        Utility class; no instantiation.
    • Method Detail

      • convexPolygonToTriangleFan

        public static <T> java.util.List<T> convexPolygonToTriangleFan​(java.util.List<Vector3D> vertices,
                                                                       java.util.function.Function<java.util.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 polygon
        fn - 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:
        java.lang.IllegalArgumentException - if fewer than 3 vertices are given
      • findBestTriangleFanIndex

        private static int findBestTriangleFanIndex​(java.util.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. 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