Collision detection with rotated objects

I am trying to detect collision between a rotated and non-rotated object. I’m using the p5 rotate function, and the objects are not in the same coordinate space. Thanks for your help!

   translate(width/2,height/2);
   t.drawTarget();
   a = atan2(mouseY - height / 2, mouseX - width / 2);
   push();
   rotate(a);
   me.drawMe();
   me.moveMe();
   for (let i = 0; i < arrow.length; i++) {
        arrow[i].drawArrow();
        arrow[i].moveArrow();
        arrow[i].hitTarget();
      }
    pop();

link to the full code

2 Likes

My suggestion is that - if you need to do collision - don’t rely on rotate() to determine the position of your things. Instead, track the actual positions of your things, along with their actual velocities and actual accelerations. It’s fine to track the X- and Y- components of these things! Then any forces you apply can be broken into X- and Y- components with a little trig…

2 Likes