当前位置: 代码迷 >> 综合 >> 旋转矩阵到旋转角的计算
  详细解决方案

旋转矩阵到旋转角的计算

热度:23   发布时间:2023-09-27 17:44:03.0

需要根据旋转矩阵求出x,y,z三个轴的旋转角度    参考

vector<float> matrix2angle(Eigen::Matrix4f rotateMatrix)
{float sy = (float)sqrt(rotateMatrix(0,0) * rotateMatrix(0,0) + rotateMatrix(1,0)*rotateMatrix(1,0));bool singular = sy < 1e-6; // Iffloat x, y, z;if (!singular){x = (float)atan2(rotateMatrix(2,1), rotateMatrix(2,2));y = (float)atan2(-rotateMatrix(2,0), sy);z = (float)atan2(rotateMatrix(1, 0), rotateMatrix(0, 0));}else{x = (float)atan2(-rotateMatrix(1, 2), rotateMatrix(1, 1));y = (float)atan2(-rotateMatrix(2, 0), sy);z = 0;}vector<float> i;i.push_back((float)(x * (180.0f / M_PI)));i.push_back((float)(y * (180.0f / M_PI)));i.push_back((float)(z * (180.0f / M_PI)));return i;
}

 

 

 

  相关解决方案