0

I am trying to compute the overlapping area of two colliding rectangles.

I found the Separating Axis Theorem to compute if they are in collision or not, but I'm not sure can I to use it for computing the area of the collision ?

If yes, please advise which computation do I have to perform?

Basically, I need to compute the percentage of hidden part of a picture (the rectangle A is a picture 256*256 for example), and one other picture overlaps it, I want to get the percentage of the hided part in comparison to the global surface of the picture.

Michal
  • 15,429
  • 10
  • 73
  • 104
user1482649
  • 45
  • 1
  • 7

1 Answers1

2

Check for intersections of edges. Either no edges intersect (easy, 100% or 0% overlap) or some edges overlap. In the latter case, you have an even number of intersection points (disregarding points where edges touch). Trace the resulting convex overlap polygon and calculate its area.

MSalters
  • 173,980
  • 10
  • 155
  • 350
  • I'm not sure to follow you when you say, check for intersection of edges, I'm in a grid were each cell could be an edge, so in this case 2 edge will never intersect (only the extrem point could intersect). My problem is to find an efficient algorithm to order the edge in the correct order to get a single 'Path' around this shape (in order to help me batch bigger area of this shape and reduce draw calls) – user1482649 Jan 21 '13 at 21:43
  • @user1482649: That's inconsistent what you said earlier in the comment, about the rotation differing. – MSalters Jan 22 '13 at 08:16