| Re: [AD] rotate direction | 
[ Thread Index | 
Date Index
| More lists.liballeg.org/allegro-developers Archives
] 
On 26 Oct 2008, at 21:53, Trent Gamblin wrote:
Writing some code for my game I came to realize that the C trig
function sin behaves differently than the al_draw_rotated_*
functions. "sin" starts at 0 (3 o'clock) and moves clockwise so that
pi/2 is at 6 o'clock. The allegro functions however go counter
clockwise, starting at the same 0 with pi/2 at 12 o'clock.
Now we have the option to change or keep this behavior.
First there is the argument that everything should work the same so
we follow the C conventions.
On the other hand, OpenGL by default works like Allegro does at
present. Also, at least in Canada, in school we're taught with
angles that follow the same behavior.
The proper implementation is for the angles in the range [0..2pi) a  
point on a circle rotates in the "positive" direction of orientation.  
This is an anti-clockwise rotation using a conventional right-handed  
axis system. That means phi=0 corresponds to the positive X axis and  
phi=pi/2 corresponds to the positive Y axis.
Computer screens are weird in that they have their y axis inverted  
(going from top to bottom rather than bottom to top), so they are  
"mirrored". This has the effect of turning an anti-clockwise rotation  
into a clockwise rotation. OpenGL is different again in presenting  
you with a normal right handed coordinate system where Y increases  
upward (if my memory serves me).
Now, independent of the backend used, Allegro provides a screen that  
follows the "normal" computer orientation where the Y coordinate  
increases downward. This means that in order to follow normal  
conventions, the net effect is that Allegro should give clockwise  
rotation.
Obviously it doesn't matter in the end, but it does need to be  
clearly documented.
Ok, time to check what everyone else has been replaying to this. :)
Evert