[quote name='Elyas_321' timestamp='1307098311' post='4819006']
if the ship is facing right, then its original look vector irrespective of it its position is (1,0) and atan2(0) is always 90
It would be better to say that the original (or default, i.e. unrotated) look vector is [ 0 1 ] (but see below), and that the current look vector is [ 1 0 ] when facing to the right, and all this regardless of the location of the ship. This distinction is necessary because we need the default (or original) vector to be constant. One can say that it is the look direction in the model's local space but expressed in global co-ordinates, and as such it is fixed.
atan2(0) is not defined, because atan2 requires 2 parameters. But atan2(y,0) for any y>0 is always 90°, correct.
if it is up at 90 (0,-1) in reference to your first post should it not be x==0, y<0 for the ship looking up?
Err, does this mean that y increases from top to bottom rather than from bottom to top? Until now I assumed here and in any post above that y increases from the bottom of the screen to its top, because AFAIK it is the way D3D handles this! Please clarify.
[/quote]
If that assumption is wrong, then the vector [ 0 1 ] and its belonging angle +90° will point down, while the vector [ 0 -1 ] and its belonging angle -90° will point up. Moreover, positive angles mean to rotate in CW direction, while negative angles mean to rotate in CCW direction. This can be overcome simply by negating the angle after its computation by atan2, where necessary.
[/quote]
When going up in XNA you need to subtract the y axis, and when going down you need to add to the y axis..yeah it is screwed up..the same with C++ allegro...the graph is upside down...
so if the y<0 and x==0 (0,-1) looking up at 90, if its current look vector is (1, 0) then I need to subtract -90 to make it look right...yeah?
so the code
angle = atan2(y2-y1,x2-x1) - Pi/2 ;