Point in Polygon
Write a function to determine whether a given point in the plane lies INSIDE, ON, or OUTSIDE the boundary of a polygon.
Use Ray casting algorithm to implement the function.
The results of the program should look exactly like the above screenshot.
The functions signature will look like this:
/// <summary>
/// Determine whether the Point lies inside or on the boundary of the Polygon
/// </summary>
/// <param name="p">Point to be determined</param>
/// <param name="ptPolygon">Points of the polygon</param>
/// <returns>True if the Point lies inside, False if it lies outside on the boundary of the Polygon, otherwise null if the point lies on the boundary</returns>
static Nullable<bool> IsPointInPolygon(System.Windows.Point p, System.Windows.Media.PointCollection ptPolygon)
Use the following statements to generate the points of polygon and points to be determined:
System.Windows.Media.PointCollection pointsOfPolygon =
new System.Windows.Media.PointCollection(new Point[] {
new Point(1,6),
new Point(6,11),
new Point(8,8),
new Point(7,12),
new Point(10,12),
new Point(10,10),
new Point(12,10),
new Point(13,15),
new Point(15,7),
});
System.Windows.Point[] points =
new Point[] {
new Point(3,8),
new Point(6,8),
new Point(7,10),
new Point(7,11),
new Point(8,7),
new Point(8,8),
new Point(8,10),
new Point(8,15),
new Point(10,8),
new Point(10,11),
new Point(10,15),
new Point(11,10),
new Point(13,7),
new Point(13,8),
new Point(13,10),
new Point(15,10),
};