Ray-casting algorithm: Difference between revisions

m
note: it's one of the possible ways; not The Way.
m (fixed the wikipedia link)
m (note: it's one of the possible ways; not The Way.)
Line 20:
the last "country" we land on is surely ''outside'' (since the inside of the polygon is finite, while the ray continues towards infinity). So, if we crossed an odd number of borders we was surely inside, otherwise we was outside; we can follow the ray backward to see it better: starting from outside, only an odd number of crossing can give an ''inside'': outside-inside, outside-inside-outside-inside, and so on (the - represents the crossing of a border).
 
So the main part of the algorithm is how we determine if a ray intersects a segment. The following text explain one of the possible ways.
 
[[Image:intersect.png|200px|thumb|right]]