矩阵中的缩放值是会影响旋转值的 经过乘以缩放的逆阵,来取正确的旋转值:ide
osg::Matrix matrixSimple = osg::Matrix::identity(); matrixSimple.makeRotate(osg::Vec3(0, 0, 1), osg::Vec3(0, -1, 0)); osg::Quat q1 = matrixSimple.getRotate(); OSG_NOTICE << "1:\t"<< q1.x()<<"\t"<< q1.y()<<"\t"<<q1.z()<<"\t"<<q1.w() << std::endl; // 有缩放 旋转值就错了: osg::Matrix scale = osg::Matrix::scale(osg::Vec3(1.5, 1.2, 3.0)); matrixSimple*= scale; q1 = matrixSimple.getRotate(); OSG_NOTICE << "1:\t" << q1.x() << "\t" << q1.y() << "\t" << q1.z() << "\t" << q1.w() << std::endl; // 取正确的值: matrixSimple *= osg::Matrix::inverse(scale); q1 = matrixSimple.getRotate(); OSG_NOTICE << "1:\t" << q1.x() << "\t" << q1.y() << "\t" << q1.z() << "\t" << q1.w() << std::endl;
输出: code