Class Triangulator2D

java.lang.Object
com.irurueta.geometry.Triangulator2D
Direct Known Subclasses:
VanGoghTriangulator2D

public abstract class Triangulator2D extends Object
This class defines a triangulator for 2D polygons. Triangulators divide polygons into triangles, which are the simplest geometric figure. Criteria for triangulation depends on each triangulator implementation.
  • Field Details

    • MIN_VERTICES

      public static final int MIN_VERTICES
      Constant defining minimum vertices allowed in a polygon.
      See Also:
    • DEFAULT_TRIANGULATOR_METHOD

      public static final TriangulatorMethod DEFAULT_TRIANGULATOR_METHOD
      Constant defining default triangulator method.
  • Constructor Details

    • Triangulator2D

      protected Triangulator2D()
      Empty constructor.
  • Method Details

    • getMethod

      public abstract TriangulatorMethod getMethod()
      Returns triangulator method. Each method implementation will divide polygons into triangles using different techniques.
      Returns:
      Triangulator method.
    • triangulate

      public abstract List<Triangle2D> triangulate(Polygon2D polygon) throws TriangulatorException
      Triangulates provided polygon by dividing it into a set of triangles.
      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 abstract List<Triangle2D> triangulate(List<Point2D> vertices) throws TriangulatorException
      Triangulates a polygon formed by provided vertices.
      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 abstract List<Triangle2D> triangulate(List<Point2D> vertices, List<int[]> indices) throws TriangulatorException
      Triangulates a polygon formed by provided vertices.
      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.
    • create

      public static Triangulator2D create()
      Instantiates a triangulator for 2D polygons using default method.
      Returns:
      A triangulator for 2D polygons.
    • create

      public static Triangulator2D create(TriangulatorMethod method)
      Instantiates a triangulator for 2D polygons using provided method.
      Parameters:
      method - A triangulator method.
      Returns:
      A triangulator for 2D polygons.