2016 Update
This commit is contained in:
parent
948b86eafa
commit
dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions
|
|
@ -1,4 +1,6 @@
|
|||
{{Wikipedia|Point_in_polygon}}
|
||||
|
||||
<br>
|
||||
Given a point and a polygon, check if the point is inside or outside the polygon using the [[wp:Point in polygon#Ray casting algorithm|ray-casting algorithm]].
|
||||
|
||||
A pseudocode can be simply:
|
||||
|
|
@ -27,6 +29,7 @@ So the problematic points are those inside the white area (the box delimited by
|
|||
|
||||
[[Image:posslope.png|128px|thumb|right]]
|
||||
[[Image:negslope.png|128px|thumb|right]]
|
||||
|
||||
Let us take into account a segment AB (the point A having y coordinate always smaller than B's y coordinate, i.e. point A is always below point B) and a point P. Let us use the cumbersome notation PAX to denote the angle between segment AP and AX, where X is always a point on the horizontal line passing by A with x coordinate bigger than the maximum between the x coordinate of A and the x coordinate of B. As explained graphically by the figures on the right, if PAX is greater than the angle BAX, then the ray starting from P intersects the segment AB. (In the images, the ray starting from P<sub>A</sub> does not intersect the segment, while the ray starting from P<sub>B</sub> in the second picture, intersects the segment).
|
||||
|
||||
Points on the boundary or "on" a vertex are someway special and through this approach we do not obtain ''coherent'' results. They could be treated apart, but it is not necessary to do so.
|
||||
|
|
@ -68,4 +71,5 @@ An algorithm for the previous speech could be (if P is a point, Px is its x coor
|
|||
'''end''' '''if'''
|
||||
'''end''' '''if'''
|
||||
|
||||
(To avoid the "ray on vertex" problem, the point is moved upward of a small quantity ε)
|
||||
(To avoid the "ray on vertex" problem, the point is moved upward of a small quantity <big>ε</big>.)
|
||||
<br><br>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue