Package toxi.geom

Class GridTesselator

java.lang.Object
toxi.geom.GridTesselator
All Implemented Interfaces:
PolygonTesselator
Direct Known Subclasses:
GlobalGridTesselator, LocalGridTesselator

public abstract class GridTesselator extends Object implements PolygonTesselator
This is an implementation of the PolygonTesselator interface and abstract parent class for tesselating 2D polygons using a grid of additional points created within the polygon. These inlier points are connected to the original polygon vertices using a DelaunayTriangulation. The quality and final amount of triangles used can be adjusted via the number of additional grid points. This class currently has two concrete implementations: GlobalGridTesselator and LocalGridTesselator .
  • Constructor Details

    • GridTesselator

      public GridTesselator(float res)
      Creates a new instance with the given grid resolution.
      Parameters:
      res - snap distance for grid points
    • GridTesselator

      public GridTesselator(float res, float rootSize)
      Creates a new instance with the given grid resolution.
      Parameters:
      res - snap distance for grid points
  • Method Details

    • getResolution

      public float getResolution()
    • setResolution

      public void setResolution(float res)
    • tesselatePolygon

      public List<Triangle2D> tesselatePolygon(Polygon2D poly)
      Tesselates/decomposes the given polygon into a list of 2D triangles using the currently set grid resolution.
      Specified by:
      tesselatePolygon in interface PolygonTesselator
      Parameters:
      poly - polygon to be tesselated
      Returns:
      list of triangles