PolygonF

A class that wraps a PointF[] representing a Polygon. The class members include:

  • RectangleF Bounds
  • float MinimumX
  • float MaximumX
  • float Minimum Y
  • float Maximum Y
  • int NumberOfPoints
  • bool IsInBounds(PointF pt)
  • bool Contains(PointF pt)
  • PointF CenterPointOfBounds
  • PointF CenterPoint // Not yet implemented
  • decimal Area

IsInBounds returns true if the PointF is within the Rectangular Bounds of the Polygon. Contains returns true if the PointF is actually within the Polygon’s borders.

The class includes both the PolygonF and Polygon classes. Polygon is identical to PolygonF except that it works with an array of Point objects and return ints instead of floats.

First introduced on the blog under Testing to see if a Point is within a Polygon.

DOWNLOAD

  1. sungil
    October 19, 2008 at 10:18 am

    THANK YOU

  2. October 20, 2008 at 1:32 pm

    You’re welcome!

  3. December 3, 2008 at 12:00 am

    Thank you for your class. I’m using it on my Open Source project. I credited you by adding this blog link on our About dialog.
    Regards,
    Patricio.

  4. December 3, 2008 at 10:51 am

    Thanks Patricio, I hope it is helpful!

  5. Dean
    December 18, 2009 at 5:00 pm

    Thanks – This code is great!

  6. Steve
    May 27, 2014 at 6:41 pm

    code link is dead

  1. No trackbacks yet.

Leave a comment