Extracting rotation from matrix

Blitz3D Forums/Blitz3D Programming/Extracting rotation from matrix

I am making a physics engine in C++ for Blitz3D for my latest project, and internal rotations are represented by 4x4 matrices. What I need to know is how to extract a rotation from the matrix which can be used by Blitz3D. I know how to extract an XYZ rotation from a matrix, but I don't know how to extract a ZXY rotation (which I think Blitz3D uses).

From Sweenies Tokamak Wrapper:

neV3 Mat3ToEulerZXY(neM3 Matrix)
{
	float m_afEntry[9];
	float rfXAngle;
	float rfYAngle;
	float rfZAngle;

	neV3 Result;
	
	m_afEntry[0] = Matrix.M[0].v[0];
	m_afEntry[1] = Matrix.M[0].v[1];
	m_afEntry[2] = Matrix.M[0].v[2];
	m_afEntry[3] = Matrix.M[1].v[0];
	m_afEntry[4] = Matrix.M[1].v[1];
	m_afEntry[5] = Matrix.M[1].v[2];
	m_afEntry[6] = Matrix.M[2].v[0];
	m_afEntry[7] = Matrix.M[2].v[1];
	m_afEntry[8] = Matrix.M[2].v[2];


    if ( m_afEntry[7] < 1.0f )
    {
        if ( m_afEntry[7] > -1.0f )
        {
           rfZAngle = (float)atan2(-m_afEntry[1],m_afEntry[4]);
           rfXAngle = (float)asin((double)m_afEntry[7]);
           rfYAngle = (float)atan2(-m_afEntry[6],m_afEntry[8]);
			Result.v[0] = rfXAngle;
			Result.v[1] = rfYAngle;
			Result.v[2] = rfZAngle;
            return Result;
        }
        else
        {
            // WARNING.  Not unique.  ZA - YA = -atan(r02,r00)
            rfZAngle = (float)-atan2(m_afEntry[2],m_afEntry[0]);
            rfXAngle = -1.570796f;
            rfYAngle = 0.0f;
			Result.v[0] = rfXAngle;
			Result.v[1] = rfYAngle;
			Result.v[2] = rfZAngle;
            return Result;
        }
    }
    else
    {
        // WARNING.  Not unique.  ZA + YA = atan2(r02,r00)
		rfZAngle = (float)atan2(m_afEntry[2],m_afEntry[0]);
		rfXAngle = 1.570796f;
		rfYAngle = 0.0f;
		Result.v[0] = rfXAngle;
		Result.v[1] = rfYAngle;
		Result.v[2] = rfZAngle;
        return Result;
    }
}


Check out Marks native code too:
http://www.blitzbasic.com/Community/posts.php?topic=42657

Thanks, that works fine.