Ive been trying to work out how to rotate a bounding box about a position that is not the objects centre and perform collisions based on SAT Collision Dectection. I have the collisions working but i cannot figure out how to rotate the bounding box into the right location as all I seem to be able to manage is to rotate the bounding box around the objects centre position.
This is what i have so far:
float Rot = Entity.getRotation(); D3DXVECTOR2 pos = D3DXVECTOR2(Entity.getPosition().x,Entity.getPosition().y); Centre = Entity.getCentre() + pos; D3DXVECTOR2 X(cosf(Rot), sinf(Rot)); D3DXVECTOR2 Y(-sinf(Rot), cosf(Rot)); X *= Entity.getWidth()/2; Y *= Entity.getHeight()/2; Corner = (Centre - X) - Y; Corner = (Centre + X) - Y; Corner = (Centre + X) + Y; Corner = (Centre - X) + Y;
This code rotates about the objects centre position but i cant mange to rotate about a position say 15 pixels in the positive X direction from its own centre.
Any Ideas on how I would accomplish this?