Class Triangulator


  • public class Triangulator
    extends java.lang.Object
    Triangulates a polygon into triangles - duh. Doesn't handle holes in polys
    • Constructor Summary

      Constructors 
      Constructor Description
      Triangulator()
      Create a new triangulator
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addPolyPoint​(float x, float y)
      Add a point describing the polygon to be triangulated
      int getTriangleCount()
      Get a count of the number of triangles produced
      float[] getTrianglePoint​(int tri, int i)
      Get a point on a specified generated triangle
      boolean triangulate()
      Cause the triangulator to split the polygon
      • Methods inherited from class java.lang.Object

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

      • Triangulator

        public Triangulator()
        Create a new triangulator
    • Method Detail

      • addPolyPoint

        public void addPolyPoint​(float x,
                                 float y)
        Add a point describing the polygon to be triangulated
        Parameters:
        x - The x coordinate of the point
        y - the y coordinate of the point
      • triangulate

        public boolean triangulate()
        Cause the triangulator to split the polygon
        Returns:
        True if we managed the task
      • getTriangleCount

        public int getTriangleCount()
        Get a count of the number of triangles produced
        Returns:
        The number of triangles produced
      • getTrianglePoint

        public float[] getTrianglePoint​(int tri,
                                        int i)
        Get a point on a specified generated triangle
        Parameters:
        tri - The index of the triangle to interegate
        i - The index of the point within the triangle to retrieve (0 - 2)
        Returns:
        The x,y coordinate pair for the point