I\'m making a 2d game that consists in a plane fighting against spaceships trough missiles, i want the spaceships to rotate in function of the player position, so that they are
I think this should work. Set..
v = centerPosOfShip - centerPosOfUFO
Normalize...
v /= sqrt( v.x * v.x + v.y * v.y )
So now we can say v = [ cos(theta) sin(theta) ]; the rotation matrix is...
[ cos(theta) -sin(theta) ]
[ sin(theta) cos(theta) ]
So we can write in terms of v-components...
[ v.x -v.y centerPosOfUFO.x ][x]
[ v.y v.x centerPosOfUFO.y ][y]
[ 0 0 1 ][1]
where [x y] is any point on the UFO relative to its center.
Hope that makes sense