这是indexloc提供的服务,不要输入任何密码
Skip to content

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

@xuqianld

Description

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions