next up previous contents
Next: Quaternion coordinates Up: Rotation matrices Previous: Angle and axis   Contents

Euler angles

To represent a rotation by Euler angles, first rotate the object about the z-axis, then about the y-axis, and finally about the new z-azis.

Rotations about coordinate axes, lying wholly within the plane perpendicular to the axis, have a simple form:

\begin{eqnarray*}
e^{\omega \Sigma_x} & = & \left[ \begin{array}{ccc}
\cos \om...
...\omega \\
0 & \sin \omega & \cos \omega
\end{array} \right]
\end{eqnarray*}



To perform the indicated rotations in succession, through angles $\phi$, $\rho$, and $\psi$, respectively, means multiplying the corresponding orthogonal matrices.

\begin{eqnarray*}
\lefteqn{e^{\phi \Sigma_x}e^{\rho \Sigma_x} e^{\psi \Sigma_x} ...
...\sin\psi &
\sin\rho\cos\psi &
\cos \rho
\end{array} \right]
\end{eqnarray*}



Figure: Objective-C panel for defining a rotation via its angle and axis
\begin{figure}\begin{picture}(250,200)(15,0)
\epsffile{fig7.eps}\end{picture}\end{figure}

 
/* spheu - generate rotation from euler angles */

void spheu(o,a) double o[][3], a[3]; {
double e0, e1, e2, c0, c1, c2, s0, s1, s2;

e0=(a[0]*3.14159)/180.0;
e1=(a[1]*3.14159)/180.0;
e2=(a[2]*3.14159)/180.0;
c0=cos(e0);
c1=cos(e1);
c2=cos(e2);
s0=sin(e0);
s1=sin(e1);
s2=sin(e2);
o[0][0]= c0*c2-s0*c1*s2;
o[0][1]=-c0*s2-s0*c1*c2;
o[0][2]= s0*s1;
o[1][0]= s0*c2+c0*c1*s2;
o[1][1]=-s0*s2+c0*c1*c2;
o[1][2]=-c0*s1;
o[2][0]= s1*s2;
o[2][1]= s1*c2;
o[2][2]= c1;
}

The formulas for the matrix elements of the Euler angles can be inverted, allowing the angles to be recovered from the matrix. We have:

\begin{eqnarray*}
\rho & = & {\rm arccos}\ O_{33} \\
\psi & = & {\rm arccos}\...
...}/\sin \rho) \\
\phi & = & {\rm arccos}\ (- O_{23}/\sin \rho)
\end{eqnarray*}



wherein the singularity where $\sin \rho$ vanishes should be noted. In that case the first and third rotations occur about the same axis and there is no way to uniquely apportion the rotation between the two.

 
/* sphgeu - find the euler angles of a rotation */

void sphgeu(a,o) double *a, *o[3]; {
double e1, s1;
e1=acos(o[2][2];
s1=sin(e1);
if (s1==0.0) {a[0]=acos(o[1][1]; a[1]=a[2]=0.0;}
    else {a[2]=acos(o[2][1]/s1); a[1]=e1; a[0]=acos(-o[1][2]/s1;}
}


next up previous contents
Next: Quaternion coordinates Up: Rotation matrices Previous: Angle and axis   Contents
Pedro Hernandez 2004-05-13