private static int Wind(AZGeoPoint location, AZEdge edge, Position position) { if (edge.RelativePositionOf(location) != position) { return(0); } return(1); }
private static int DescendingIntersection(AZGeoPoint location, AZEdge edge) { if (edge.AscendingRelativeTo(location)) { return(0); } if (!edge.LocationInRange(location, Orientation.Descending)) { return(0); } return(Wind(location, edge, Position.Right)); }
public bool Contains(AZGeoPoint location) { //AZGeoPoint[] polygonPointsWithClosure = PolygonPointsWithClosure(); int windingNumber = 0; for (int pointIndex = 0; pointIndex < _pointsWithClosure.Length - 1; pointIndex++) { //AZEdge edge = new AZEdge(_pointsWithClosure.Span[pointIndex], _pointsWithClosure.Span[pointIndex + 1]); AZEdge edge = new AZEdge(_pointsWithClosure[pointIndex], _pointsWithClosure[pointIndex + 1]); windingNumber += AscendingIntersection(location, edge); windingNumber -= DescendingIntersection(location, edge); } return(windingNumber != 0); }