Class VanGoghTriangulator3D

java.lang.Object
com.irurueta.geometry.Triangulator3D
com.irurueta.geometry.VanGoghTriangulator3D

public class VanGoghTriangulator3D extends Triangulator3D
This class defines a triangulator for 3D polygons. Triangulators divide polygons into triangles, which are the simplest geometric figure. This implementation uses Van Gogh or Ear Cutting algorithm for triangulation.
  • Field Details

    • DEFAULT_ORIENTATION_THRESHOLD

      public static final double DEFAULT_ORIENTATION_THRESHOLD
      Default orientation threshold which is 90º.
      See Also:
    • MIN_THRESHOLD

      public static final double MIN_THRESHOLD
      Minimum allowed threshold.
      See Also:
    • INHOM_COORDS

      public static final int INHOM_COORDS
      Number of 3D inhomogeneous coordinates.
      See Also:
  • Constructor Details

    • VanGoghTriangulator3D

      public VanGoghTriangulator3D()
  • Method Details

    • getMethod

      public TriangulatorMethod getMethod()
      Returns triangulator method. Each method implementation will divide polygons into triangles using different techniques.
      Specified by:
      getMethod in class Triangulator3D
      Returns:
      Triangulator method.
    • triangulate

      public List<Triangle3D> triangulate(Polygon3D polygon) throws TriangulatorException
      Triangulates provided polygon by dividing it into a set of triangles.
      Specified by:
      triangulate in class Triangulator3D
      Parameters:
      polygon - Polygon to be triangulated.
      Returns:
      List of triangles forming the polygon that has been triangulated.
      Throws:
      TriangulatorException - Raised if triangulation cannot be done. Usually this indicates numerical instability or polygon degeneracy.
    • triangulate

      public List<Triangle3D> triangulate(List<Point3D> vertices) throws TriangulatorException
      Triangulates a polygon formed by provided vertices.
      Specified by:
      triangulate in class Triangulator3D
      Parameters:
      vertices - List of points considered as vertices of a polygon.
      Returns:
      List of triangles forming the polygon that has been triangulated.
      Throws:
      TriangulatorException - Raised if triangulation cannot be done. Usually this indicates numerical instability or polygon degeneracy.
    • triangulate

      public List<Triangle3D> triangulate(List<Point3D> vertices, List<int[]> indices) throws TriangulatorException
      Triangulates a polygon formed by provided vertices.
      Specified by:
      triangulate in class Triangulator3D
      Parameters:
      vertices - List of points considered as vertices of a polygon.
      indices - List where indices of original vertices will be stored. This list can be used to refer to the original order of vertices. Notice that vertices indices might be repeated because vertices might appear in more than one triangle after triangulation. If this parameter is null, indices won't be stored in this list.
      Returns:
      List of triangles forming the polygon that has been triangulated.
      Throws:
      TriangulatorException - Raised if triangulation cannot be done. Usually this indicates numerical instability or polygon degeneracy.
    • isEar

      public static boolean isEar(Triangle3D triangle, List<Point3D> polygonVertices) throws CoincidentPointsException
      Determines if provided triangle can be considered as an ear of the remaining polygon formed by provided vertices. An ear is usually a triangle located at a corner of a polygon. A triangle is considered an ear if no other vertex of the polygon lies within the triangle and if the triangle is not convex (is concave).
      Parameters:
      triangle - A triangle.
      polygonVertices - A list of points forming the remaining polygon
      Returns:
      true if triangle is ear, false otherwise.
      Throws:
      CoincidentPointsException - Raised if orientation of polygons cannot be determined, usually because consecutive vertices in a polygon are coincident, there are numerical instabilities or polygon degeneracies.
    • isPolygonOrientationReversed

      public static boolean isPolygonOrientationReversed(List<Point3D> vertices1, List<Point3D> vertices2) throws CoincidentPointsException
      Given the list of vertices of two polygons, determines if polygons have reversed orientation, or in other words, it the angle between the orientation of both polygons is larger than DEFAULT_ORIENTATION_THRESHOLD (i.e. 90 degrees or pi / 2 radians).
      Parameters:
      vertices1 - Vertices of 1st polygon.
      vertices2 - Vertices of 2nd polygon.
      Returns:
      True if polygons have reversed orientation, false otherwise.
      Throws:
      CoincidentPointsException - Raised if orientation of polygons . cannot be determined, usually because consecutive vertices in a polygon are coincident, there are numerical instabilities or polygon degeneracies.
      See Also:
    • isPolygonOrientationReversed

      public static boolean isPolygonOrientationReversed(List<Point3D> vertices1, List<Point3D> vertices2, double threshold) throws CoincidentPointsException
      Given the list of vertices of two polygons, determines if polygons have reversed orientation, or in other words, it the angle between the orientation of both polygons is larger than provided threshold.
      Parameters:
      vertices1 - Vertices of 1st polygon.
      vertices2 - Vertices of 2nd polygon.
      threshold - Angle threshold expressed in radians to determine if polygons have reversed orientation.
      Returns:
      True if polygons have reversed orientation, false otherwise.
      Throws:
      IllegalArgumentException - Raised if provided threshold is negative.
      CoincidentPointsException - Raised if orientation of polygons cannot be determined, usually because consecutive vertices in a polygon are coincident, there are numerical instabilities or polygon degeneracies.
      See Also:
    • isOrientationReversed

      public static boolean isOrientationReversed(double angle)
      Given an angle, determines if orientation can be considered to be reversed.
      Parameters:
      angle - Angle in radians.
      Returns:
      True if absolute value of angle is larger than DEFAULT_ORIENTATION_THRESHOLD, false otherwise.
    • isOrientationReversed

      public static boolean isOrientationReversed(double angle, double threshold)
      Given an angle, determines if orientation can be considered to be reversed.
      Parameters:
      angle - Angle in radians.
      threshold - Threshold to determine if orientation is reversed
      Returns:
      True if absolute value of angle is larger than provided threshold, false otherwise.
    • internalTriangulate

      private static List<Triangle3D> internalTriangulate(List<Point3D> verticesCopy, List<int[]> indices, List<Point3D> originalVertices) throws TriangulatorException
      Internal method that computes the actual triangulation.
      Parameters:
      verticesCopy - List of points considered as verticesCopy of a polygon. This list will be modified after execution of this method
      indices - List where indices of original verticesCopy will be stored. This list can be used to refer to the original order of verticesCopy. Notice that verticesCopy indices might be repeated because verticesCopy might appear in more than one triangle after triangulation. If this parameter is null, indices won't be stored in this list.
      originalVertices - Reference to original list of vertices that won't be modified.
      Returns:
      List of triangles forming the polygon that has been triangulated.
      Throws:
      TriangulatorException - Raised if triangulation cannot be done. Usually this indicates numerical instability or polygon degeneracy.
    • computeIndices

      private static void computeIndices(List<Point3D> vertices, List<Triangle3D> triangles, List<int[]> indices)
      Computes indices of resulting triangles vertices respect to original polygon vertices. Indices are stored in provided indices list.
      Parameters:
      vertices - Vertices of polygon.
      triangles - Triangles obtained after triangulation.
      indices - Indices of original positions of resulting triangle's vertices.