Package toxi.geom

Class ConvexPolygonClipper

java.lang.Object
toxi.geom.ConvexPolygonClipper
All Implemented Interfaces:
PolygonClipper2D

public class ConvexPolygonClipper extends Object implements PolygonClipper2D
A more generic version of the Sutherland-Hodgeman algorithm to limit 2D polygons to convex clipping regions. Uses the clipping region's centroid and Line2D.classifyPoint(ReadonlyVec2D) to identify if an edge needs to be clipped or not. More information: http://en.wikipedia.org/wiki/Sutherland-Hodgman_algorithm
Since:
0021
See Also:
  • Constructor Details

    • ConvexPolygonClipper

      public ConvexPolygonClipper(Polygon2D bounds)
  • Method Details

    • clipPolygon

      public Polygon2D clipPolygon(Polygon2D poly)
      Description copied from interface: PolygonClipper2D
      Creates a clipped version of the polygon to the boundary shape set.
      Specified by:
      clipPolygon in interface PolygonClipper2D
      Parameters:
      poly - polygon to be clipped
      Returns:
      clipped poly
    • getBounds

      public Polygon2D getBounds()
    • setBounds

      public void setBounds(Polygon2D bounds)