Romero, a game developer wants to design an algorithm to tell whether the dark monster is inside his polygonal hideout. But because the hideout is really strangely shaped, it's hard to tell.
So, to find out, Romero draws out a ray from the location monster. The ray intersects the hideout walls at exactly 8 points.
Is the monster inside his hideout?
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
If you start inside, draw a straight line, and end up outside, that means that you do the following:
1) Leave once (1 intersection)............and then
2) Enter and leave an integer number of times (2 intersections times an integer is an even number)
One plus an even number of intersections is an odd number. Since the actual number is even, he must be outside.