hello.

I’m creating an ifc importer.

I’m creating some simple beam with rotation about X , about Y and about Z.

These are the matrixes that i get:

1)Rotation about Z

0.8|0.5|0.0

0.0|0.0|1.0

-0.5|0.8|0.0

i know that the real rotation about Z is :

0.8|0.5|0.0

-0.5|0.8|0.0

0.0|0.0|1.0

then i must swap the axis y with z

1)Rotation about X

0.0|0.8|0.5

1.0|0.0|0.0

0.0|-0.5|0.8

i know that the real rotation about X is :

1.0|0.0|0.0

0.0|0.8|0.5

0.0|0.5|0.8

then i must swap the axis y with x

1)Rotation about Y

0.8|0.0|0.5

0.0|1.0|0.0

0.8|0.0|0.8

that is a correct Y rotation matrix.

Exist a matrix that multiplied for the Z matrix rotation swap the y axis with the z axis and

that multiplied for the X matrix rotation swap the y axis and the x axis?

thanks.

another thing:

i’m working with these matrixes for extract the rotation angles about x,y and z , the function that extract the angle is this :

```
void C3DMatrixIfc::ExtractAxisAngle (C3DVectorIfc& axis, double& angle)
{
// Let (x,y,z) be the unit-length axis and let A be an angle of rotation.
// The rotation matrix is R = I + sin(A)*P + (1-cos(A))*P^2 where
// I is the identity and
//
// +- -+
// P = | 0 -z +y |
// | +z 0 -x |
// | -y +x 0 |
// +- -+
//
// If A > 0, R represents a counterclockwise rotation about the axis in
// the sense of looking from the tip of the axis vector towards the
// origin. Some algebra will show that
//
// cos(A) = (trace(R)-1)/2 and R - R^t = 2*sin(A)*P
//
// In the event that A = pi, R-R^t = 0 which prevents us from extracting
// the axis through P. Instead note that R = I+2*P^2 when A = pi, so
// P^2 = (R-I)/2. The diagonal entries of P^2 are x^2-1, y^2-1, and
// z^2-1. We can solve these for axis (x,y,z). Because the angle is pi,
// it does not matter which sign you choose on the square roots.
double trace = m_X.x + m_Y.y + m_Z.z;
double cs = (0.5)*(trace - 1);
angle = ACos(cs); // in [0,PI]
if (angle > 0)
{
if (angle < PI)
{
axis.x = m_Z.y - m_Y.z;
axis.y = m_X.z - m_Z.x;
axis.z = m_Y.x - m_X.y;
axis.Normalize();
}
else
{
// angle is PI
double halfInverse;
if (m_X.x >= m_Y.y)
{
// r00 >= r11
if (m_X.x >= m_Z.z)
{
// r00 is maximum diagonal term
axis.x = (0.5)*sqrtf(1 + m_X.x - m_Y.y - m_Z.z);
halfInverse = (0.5)/axis.x;
axis.y = halfInverse*m_X.y;
axis.z = halfInverse*m_X.z;
}
else
{
// r22 is maximum diagonal term
axis.z = (0.5)*sqrtf(1 + m_Z.z - m_X.x - m_Y.y);
halfInverse = (0.5)/axis.z;
axis.x = halfInverse*m_X.z;
axis.y = halfInverse*m_Y.z;
}
}
else
{
// r11 > r00
if (m_Y.y >= m_Z.z)
{
// r11 is maximum diagonal term
axis.y = (0.5)* sqrtf(1+ m_Y.y - m_X.x - m_Z.z);
halfInverse = (0.5)/axis.y;
axis.x = halfInverse*m_X.y;
axis.z = halfInverse*m_Y.z;
}
else
{
// r22 is maximum diagonal term
axis.z = (0.5)*sqrtf(1+ m_Z.z - m_X.x - m_Y.y);
halfInverse = (0.5)/axis.z;
axis.x = halfInverse*m_X.z;
axis.y = halfInverse*m_Y.z;
}
}
}
}
else
{
// The angle is 0 and the matrix is the identity. Any axis will
// work, so just use the x-axis.
axis.x = 1;
axis.y = 0;
axis.z = 0;
}
}
```

extracted from wild magic 5 engine of geometrictools.