#504·Piccolo

使用Quaternion初始化Matrix3x3坐标系有问题

Author: kkktaoluCreated Jul 23, 2025Updated Jul 23, 2025
Labelsbug

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都是按照右手系转的