Point in polygon

Said share After the Jordan curve theorem, simplified, the edges of a polygon, the data space into an inside and an outside. For many applications it is necessary to determine whether a point is inside or outside of a polygon.

Beam method

Wherein the beam method, a beam is sent in either direction from the point to be tested. In this case, it is counted how often the ray intersects the edges of the polygon. There are three cases:

If the number is odd, the point is inside the polygon, is it just, it is outside. In the case of infinitely many points of intersection of the beam was directly on an edge. The test must be repeated with a different angle. By a more sophisticated analysis of the relative position of the test point and the edge ends of the collinear case, however, a repetition may be dispensed at a different angle to such. As the following pseudo-code is one along the horizontal rightward beam with particular attention to lie on the corners of the beam:

Function: PunktInPolygon Parameters: vertices of a planar polygon test point Return: if within lies;             When outside is;             When located on    Set and    for      Set KreuzProdTest    Result:    Function: KreuzProdTest Parameters: points, Drop-off: when the beam intersects the edge of the right (except in the lower end point);             When on lies;             otherwise    if      If or        Results: 0      otherwise        Result:    if      Swap and    If and      Result:    If or      Result:    Set    if      Result:    else if      Result:    otherwise      Result: Note: According to the description of the return value of the function KreuzProdTest is returned in the value. If, instead, the sign is returned by the PunktInPolygon function also provides the correct result. In this case, the intersections of the edges are counted by a beam extending from the left.

Areas of application

This method is primarily used in geographic information systems application.

665174
de