Paul Sherman (psherman++at++merl.com)
Mon, 15 Feb 1999 18:48:50 -0500
Greetings from up the street.
http://www.eleves.ens.fr:8080/home/massimin/demo/matrixfaq.htm
Q36. How do I convert a rotation matrix to Euler angles?
--------------------------------------------------------
This operation is the exact opposite to the one answered in the question
above. Given that the rotation matrix is:
| CE -CF -D 0 |
M = | -BDE+AF BDF+AE -BC 0 |
| ADE+BF -ADF+BE AC 0 |
| 0 0 0 1 |
where A,B are the cosine and sine of the X-axis rotation axis,
C,D are the cosine and sine of the Y-axis rotation axis,
E,F are the cosine and sine of the Z-axis rotation axis.
-----------------------
Then the entire process can be reversed:
-----------------------------------
angle_y = D = -asin( mat[2]);
C = cos( angle_y );
angle_y *= RADIANS;
if ( fabs( angle_y ) > 0.0005 )
{
trx = mat[10] / C;
try = -mat[6] / C;
angle_x = atan2( try, trx ) * RADIANS;
trx = mat[0] / C;
try = -mat[1] / C;
angle_z = atan2( try, trx ) * RADIANS;
}
else
{
angle_x = 0;
trx = mat[5];
try = mat[4];
angle_z = atan2( try, trx ) * RADIANS;
}
angle_x = clamp( angle_x, 0, 360 );
angle_y = clamp( angle_y, 0, 360 );
angle_z = clamp( angle_z, 0, 360 );
-----------------------------------
Paul Sherman
psherman++at++merl.com
Michael Boccara wrote:
>
> Hi all,
>
> I have a simple (but too exhausting for my little mind) question about 3D
> algebra.
>
> Based on a given 3x3 rotation matrix, how do you compute (one of) its HPR values
> ?
>
> I am using my own 3x3 matrix class, thus I can't use pfMatrix::getOrthoCoord(),
> nor do I have its source code...
>
> Thanks for your help !
>
> Mike
This archive was generated by hypermail 2.0b2 on Mon Feb 15 1999 - 15:48:55 PST