1

I need to check if a rotated rectangle A is inside a rotated rectangle B. That is, if B is completely contained in A. I have the following information stored in a rotated rectangle: the four coordinates and its angle.

Is there is an efficient method to do this? I know that the Separating Axis Theorem can check a intersection situation, but is this method still valid to check a containment situation?

1 Answers1

2

With rectangles, a point in polygon algorithm would be quite efficient. If the four corners of polygon A are inside of polygon B, then polygon A is inside polygon B. You have maximum 4 points to check on 4 edges, so this should be fast. See here for an example of point in polygon implementation.

radouxju
  • 49,636
  • 2
  • 71
  • 144
  • It seems interesting to me. What do you think to use this algorithm to check if there is an intersection between two rotated rectangles? I mean, if one corner of polygon A is inside of polygon B, then A intersects B. Does it make sense? I saw that in the implementation that you mentioned, it is possible to check if the point is also in the border or a polygon or not. Is it right too? – Anderson Carniel Dec 23 '16 at 12:35