Extracting rotations same as matrix



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 25/02/2006 at 17:52, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   9.102 
    Platform:   Windows  ; Mac  ;  Mac OSX  ; 
    Language(s) :     C++  ;

    ---------
    What is needed is to be able to extract a set of rotations from a local matrix in the same form as those that are used to create the matrix but under differing circumstances. Let me explain. The rotations used to set the object's matrix are ordered-axis angles, using this code:

    ro =     bbc->GetBool(IPP_RORDER);  
    if          (ro == ROTORDER_XYZ)     rot = MatrixRotZ(rotV.z) * MatrixRotY(rotV.y) * MatrixRotX(rotV.x);  
    else if (ro == ROTORDER_XZY)     rot = MatrixRotY(rotV.y) * MatrixRotZ(rotV.z) * MatrixRotX(rotV.x);  
    else if (ro == ROTORDER_YXZ)     rot = MatrixRotZ(rotV.z) * MatrixRotX(rotV.x) * MatrixRotY(rotV.y);  
    else if (ro == ROTORDER_YZX)     rot = MatrixRotX(rotV.x) * MatrixRotZ(rotV.z) * MatrixRotY(rotV.y);  
    else if (ro == ROTORDER_ZXY)     rot = MatrixRotY(rotV.y) * MatrixRotX(rotV.x) * MatrixRotZ(rotV.z);  
    else if (ro == ROTORDER_ZYX)     rot = MatrixRotX(rotV.x) * MatrixRotY(rotV.y) * MatrixRotZ(rotV.z);
    

    This is good when I have the ordered-axis rotation values to start with. But in order to rotate the object using Cinema 4D's rotation tool, I need to extract from the matrix rotations that are ordered-axis and not HPB (thus, MatrixToHPB(ml) or obj->GetRot() will not so simplistically work).

    Yes, I have tried Ken Shoemake's code in Graphics Gems IV (Euler Angle Conversion) with no luck because the matrix is still not converted properly. It is possible that this code will work, but the variations that have been tried show no signs of reconstituting proper angles. I think that the reason for the lack of success is because HPB angles in the matrix are in a particular order and one cannot just extract them using another order (HPB->matrix->HPB works, but HPB->matrix->somethingelse doesn't).

    I have exhausted my resources (books, online searches, ACM literature) trying to determine a way to convert HPB to ordered-axis angles. If anyone has ideas, I am listening!

    Thank you very much,



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 26/02/2006 at 09:41, xxxxxxxx wrote:

    Hi again,

    i think the matrices in cinema are build from hpb angles in this order.

    ml = MatrixRotY( h ) * MatrixRotX( p ) * MatrixRotZ( b )

    The code for MatrixToHPB and HPBToMatrix is avaiable in c4d_tools.cpp. Perhaps it is helpfull for debugging or deriving your code for other rot orders.


Log in to reply