Jump to content

Ray-casting algorithm: Difference between revisions

m
Small grammar change.
m (Small grammar change.)
Line 18:
An intuitive explanation of why it works is that every time we cross
a border, we change "country" (inside-outside, or outside-inside), but
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 waswere surely inside, otherwise we waswere 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.
1

edit

Cookies help us deliver our services. By using our services, you agree to our use of cookies.