# How to check that whather a Polygon is completly inside of another Polygon?

Let's say I have two polygons. I know the co-ordinates of both polygons. Now, I need to check whether the first Polygon is completely inside of second polygon? IN this figure only 1 polygon is completely inside of red polygon.

-

One way would be to compile a list of all edge pairs, and check whether any edges cross each other. If none do, you can choose any point inside one of the polygons, and check weather it is is the second polygon by using the following theorem:

A point is inside a polygon if a ray from this point crosses the polygon's edges an odd number of times.

If the point is inside both, then one of the polygons is inside the other.

-
I will try this. Thanks. –  user960567 Jun 13 '12 at 15:59
In order for polygon $A$ to be inside polygon $B$, all of the vertices of $A$ must be inside $B$, and all of the vertices of $B$ must be outside $A$. The second condition does not need to be checked if $B$ is known to be convex.