Developing For .NET

Real World .NET Methods, Tricks, and Examples

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

2 Comments so far

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

    THANK YOU

  2. Joel October 20th, 2008 1:32 pm

    You’re welcome!

Leave a reply