Flip rotation matrix

Posted by azer89 on Game Development See other posts from Game Development or by azer89
Published on 2012-04-08T05:42:08Z Indexed on 2012/04/08 5:48 UTC
Read the original article Hit count: 382

Filed under:
|
|
|

right now i'm doing character control with kinect.

Basically i need to mirror the joint orientation because the character faces the player. Somehow by googling through internet i've done it and everything works very well. But i have little idea about how the math works, here's my code:

//-------------------------------------------------------------------------------------
Ogre::Quaternion JointOrientationCalculator::buildQuaternion(Ogre::Vector3 xAxis, Ogre::Vector3 yAxis, Ogre::Vector3 zAxis)
{    
    Ogre::Matrix3 mat;    
    if(isMirror)
    {
        mat = Ogre::Matrix3(xAxis.x, yAxis.x, zAxis.x,
                            xAxis.y, yAxis.y, zAxis.y,
                            xAxis.z, yAxis.z, zAxis.z);    
        Ogre::Matrix3 flipMat(1, 0,  0,
                              0, 1,  0,
                              0, 0, -1);    
        mat = flipMat * mat * flipMat;
    }
    else
    {    
        mat = Ogre::Matrix3(xAxis.x, -yAxis.x, zAxis.x,
                           -xAxis.y, yAxis.y, -zAxis.y,
                           xAxis.z,  -yAxis.z, zAxis.z);
    }

    Ogre::Quaternion q;
    q.FromRotationMatrix(mat);      

    return q;
}

when i need to mirror/flip it by axes z i calculate mat = flipMat * mat * flipMat; but i don't understand how this equation works.

© Game Development or respective owner

Related posts about matrix

Related posts about rotation