Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

264
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda