使用Quaternion初始化Matrix3x3坐标系存在问题
作者: kkktaolu创建于 2025年7月23日更新于 2025年7月23日
标签bug
Matrix3x3(const Quaternion& q) { float yy = q.y * q.y; float zz = q.z * q.z; float xy = q.x * q.y; float zw = q.z * q.w; float xz = q.x * q.z; float yw = q.y * q.w; float xx = q.x * q.x; float yz = q.y * q.z; float xw = q.x * q.w; m_mat[0][0] = 1 - 2 * yy - 2 * zz; m_mat[0][1] = 2 * xy + 2 * zw; m_mat[0][2] = 2 * xz - 2 * yw; m_mat[1][0] = 2 * xy - 2 * zw; m_mat[1][1] = 1 - 2 * xx - 2 * zz; m_mat[1][2] = 2 * yz + 2 * xw; m_mat[2][0] = 2 * xz + 2 * yw; m_mat[2][1] = 2 * yz - 2 * xw; m_mat[2][2] = 1 - 2 * xx - 2 * yy; } 这一段转换是按照左手坐标系转的,而包括Matrix3x3的定义和Quaternion::ToRotationMatrix都是按照右手坐标系转的。
内容来源: BoomingTech/Piccolo