Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

269
Views
How to determine if there was a collision between a normal rectangle and a rotated rectangle?

Determining whether or not there was a collision between two AABB (axis-aligned bounding box) rectangles is trivial:

doRectanglesCollide(r1X, r1Y, r1W, r1H, r2X, r2Y, r2W, r2H) {
  return r1X < r2X + r2W && r1X + r1W > r2X && r1Y < r2Y + r2H && r1Y + r1H > r2Y;
}

Determining whether or not there was a collision between two rotated rectangles is much less efficient.

However, there is a trick. One can rotate both of the rectangles by the same amount such that one of them becomes an AABB rectangle.

At that point, one would simply need a function that determines whether an AABB rectangle and a rotated rectangle intersect. I assume it would be much more efficient than using the Separating Axis Theorem to determine if two rotated rectangles are intersecting, as the latter is a general formula for determining if two arbitrary polygons are intersecting.

So, to rephrase, here is my question: I have two rectangles that are rotated. Rather than using the linked answer, is there not a more efficient algorithm that takes advantage of the fact that one of the rectangles can be made into an AABB rectangle by rotating both of them by -radians? Because at that point it simply becomes the question of whether or not an AABB rectangle and a rotated rectangle are intersecting.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!