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.
How to check that whather a Polygon is completly inside of another Polygon?
5
$\begingroup$
linear-algebra
geometry
2 Answers
4
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.
-
0I will try this. Thanks. – 2012-06-13
3
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.
-
0@mjqxxxx - I apologize, you are correct. – 2012-06-15