当前位置: 代码迷 >> 综合 >> 矩阵的相关知识
  详细解决方案

矩阵的相关知识

热度:21   发布时间:2023-09-27 17:38:27.0

 由于工作需要,开发中涉及到了矩阵的相关知识。

const double xre_pi = 3.1415926535897932384626;
const double xre_2pi = xre_pi*2.0;
const double xre_half_pi = xre_pi * 0.5;
const double xre_degree_to_radian = xre_pi / 180.0;
const double xre_radian_to_degree = 180.0 / xre_pi;
const double xre_earth_radius = 6378137;
const float xre_world_pixel_size = 0.00390625f;//1个像素3.90625毫米 s = 1/(2^8) 米/*!
*@brief  全局的浮点数精度
*/
const double xre_double_resolution = 1E-12;
const double xre_min_distance_epsilon = 1E-4;   //最小距离误差
const double xre_max_distance_epsilon = 1.0;    //最大距离误差

    通过改变角度的数值,获取一个新的变换信息。

double angle = xre_degree_to_radian*m_Move_dis;
Vector3d mNormal =GetAxisRealNormalbyPickOper(m_opertype);
trans = TransformCoordinateRotation(trans, mNormal, angle);
Xre::Vector3d CGlobalSectionHandler::GetAxisRealNormalbyPickOper(E_OPERTYPE type)
{Xre::Vector3d _mNormal;if (m_PickOperInx == SectionDir_Left){switch (m_opertype){case OPER_MOVE:_mNormal = -Vector3d::s_unitX;break;case OPER_HEADING:_mNormal = Vector3d::s_unitY;break;case OPER_PITCH:_mNormal = Vector3d::s_unitZ;break;case OPER_MOVEX:_mNormal = Vector3d::s_unitZ;break;case OPER_MOVEY:_mNormal = Vector3d::s_unitY;break;}}else if (m_PickOperInx == SectionDir_Right){switch (m_opertype){case OPER_MOVE:_mNormal = Vector3d::s_unitX;break;case OPER_HEADING:_mNormal = Vector3d::s_unitY;break;case OPER_PITCH:_mNormal = -Vector3d::s_unitZ;break;case OPER_MOVEX:_mNormal = -Vector3d::s_unitZ;break;case OPER_MOVEY:_mNormal = Vector3d::s_unitY;break;}}else if (m_PickOperInx == SectionDir_Front){switch (m_opertype){case OPER_MOVE:_mNormal = -Vector3d::s_unitZ;break;case OPER_HEADING:_mNormal = Vector3d::s_unitX;break;case OPER_PITCH:_mNormal = Vector3d::s_unitY;break;case OPER_MOVEX:_mNormal = Vector3d::s_unitY;break;case OPER_MOVEY:_mNormal = Vector3d::s_unitX;break;}}else if (m_PickOperInx == SectionDir_Back){switch (m_opertype){case OPER_MOVE:_mNormal = Vector3d::s_unitZ;break;case OPER_HEADING:_mNormal = -Vector3d::s_unitX;break;case OPER_PITCH:_mNormal = Vector3d::s_unitY;break;case OPER_MOVEX:_mNormal = Vector3d::s_unitY;break;case OPER_MOVEY:_mNormal = -Vector3d::s_unitX;break;}}else if (m_PickOperInx == SectionDir_Top){switch (m_opertype){case OPER_MOVE:_mNormal = -Vector3d::s_unitY;break;case OPER_HEADING:_mNormal = Vector3d::s_unitZ;break;case OPER_PITCH:_mNormal = Vector3d::s_unitX;break;case OPER_MOVEX:_mNormal = Vector3d::s_unitX;break;case OPER_MOVEY:_mNormal = Vector3d::s_unitZ;break;}}else if (m_PickOperInx == SectionDir_Bottom){switch (m_opertype){case OPER_MOVE:_mNormal = Vector3d::s_unitY;break;case OPER_HEADING:_mNormal = -Vector3d::s_unitZ;break;case OPER_PITCH:_mNormal = Vector3d::s_unitX;break;case OPER_MOVEX:_mNormal = Vector3d::s_unitX;break;case OPER_MOVEY:_mNormal = -Vector3d::s_unitZ;break;}}return _mNormal;
}/*
const HDTransform& trans:原始变换信息 HDTransform
const Vector3d& RotationAxis:某个方向获取的_mNormal值
const double& angle:变换的角度值
note:通过改变的角度值,获取新的变换信息 HDTransform
*/
HDTransform CGlobalSectionHandler::TransformCoordinateRotation(const HDTransform& trans, const Vector3d& RotationAxis, const double& angle)
{HDTransform reTrans=trans;Matrix4x4f _mOldRotateMatrix;EularAngleToMatrix(_mOldRotateMatrix, trans.m_eularAngle);Matrix4x4f _mRotatedMatrix;Xre::Matrix4x4RotationAxis(_mRotatedMatrix, RotationAxis, angle);Matrix4x4Multiply(_mRotatedMatrix, _mRotatedMatrix, _mOldRotateMatrix);MatrixToEularAngle(reTrans.m_eularAngle, _mRotatedMatrix);return reTrans;
}

 

  相关解决方案