# [ODE] dRFromEulerAngles interpretation

Mauro G. Todeschini mauro2006todeschini at itia.cnr.it
Tue Oct 10 08:08:03 MST 2006

```Hi,
I looked at the ODE's code just to understand something of the way It
works but I encoutered the same problem Yefei He pointed out over a year
ago. In my emails of last week I thought I wasn't understanding
row-major, column-major issues... but after reading more code and
experimenting I think the problem is in the function dRFromEulerAngles.
To my understanding dRFromEulerAngles applies a rotation about Z axis
followed by a rotation about Y axis followed by a rotation about X axis.
The order of the rotations to be onest is uncommon (or at least It is
not a standard) and I think It would be a good idea to point It out in
the documentation.
But I don't understand why the rotations are clockwise (I'm considering
a right-hand reference system, row-major matrixes and column vector on
the right). In this case rotation are usually conterclockwise in
letterature and even inside ODE dRFromAxisAndAngle seems to follow
counterclockwise rotations.
Anyone knows the reason of clockwise rotations in dRFromEulerAngles? Is
It a bug or a feature? :D

Bye

Yefei He wrote:
> Hi,
>
>     I think Left handed rule explains my problem. So this means a positive
> angle rotates the object clockwise since rotation is in a left-handed
> coordinate system. My problem is then, how are the angles in the function
> dRFromEulerAngles( R, phi, theta, psi ) interpreted? I use it to set the
> rotation angles. I did a comparison of this to dRFromAxisAngle( R, ax, ay,
> az, angle ). And I noticed the differences in the rotation matrix that
> they generate:
>
>     dRFromEulerAngles( R, a, 0, 0 )
>     1       0       0
>     0    cos(a)  sin(a)
>     0   -sin(a)  cos(a)
>
>     dRFromEulerAngles( R, 0, a, 0 )
>  cos(a)     0   -sin(a)
>     0       1       0
>  sin(a)     0    cos(a)
>
>     dRFromEulerAngles( R, 0, 0, a )
>  cos(a)  sin(a)     0
> -sin(a)  cos(a)     0
>     0       0       1
>
> and
>     dRFromAxisAngle( R, 1, 0, 0, a )
>     1       0       0
>     0    cos(a) -sin(a)
>     0    sin(a)  cos(a)
>
>     dRFromAxisAngle( R, 0, 1, 0, a )
>  cos(a)     0    sin(a)
>     0       1       0
> -sin(a)     0    cos(a)
>
>     dRFromAxisAngle( R, 0, 0, 1, a )
>  cos(a) -sin(a)     0
>  sin(a)  cos(a)     0
>     0       0       1
>
>     That means Euler angles need to be negated to match the results of
> rotation around x, y, or z axis. The discrepancy between Euler angles
> and angular velocity is the same. My next question is then, is there a
> reason why Euler angles are interpreted this way in ODE? I thought
> in the left-handed system, A positive Euler angle would also mean a
> clockwise rotation around axis?
>
>     Yefei
```