1. Not finding help here? Sign up for a free 30min tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Collision of rectangles

  1. Jul 4, 2005 #1
    I wonder if somebody could help me with this problem I'm solving for my c language class (but it's more a mathematical problem I think).
    So we have 2 different rectangles (ABCD and EFGH) in an ortogonal plane, their sides are paralel to the axes of the ortogonal system. Each of this rectangles is given a velocity vector. Now the task is to determine where the first collision will take place (where these two rectangles (their sides or corners) will meet the first time) if it will take place.
    Any suggestions?
    Can this problem be solved via mathematicl formulas?
    thanks a lot
  2. jcsd
  3. Jul 4, 2005 #2
    I would have to think more about this to solve it mathematically, but if you're talking about computing a bounding-box collision when it happens, what you do is check at every step to see if the two boxes have collided. This will happen if and only if the top or bottom line of one box is between the bottom line of the other box and the top line of the other box, AND the left or right line of one box is between the left and right lines of the other box.

    This is not totally precise--you could miss a corner collision in between steps, if the steps are large enough and the collision is close enough to the corners. To do it mathematically would require more work.
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?

Similar Discussions: Collision of rectangles
  1. A collision (Replies: 2)