• 四元数几个操作


    1. 向量v绕一轴旋转一角度(用四元数表示q)

    v’ = q*v*q’

    2.四元数分解到另一轴上

    /**
        Assume that the current quaternion represents the relative orientation between two coordinate frames A and B.
        This method decomposes the current relative rotation into a twist of frame B around the axis v passed in as a
        parameter, and another more arbitrary rotation.

        AqB = AqT * TqB, where T is a frame that is obtained by rotating frame B around the axis v by the angle
        that is returned by this function.

        In the T coordinate frame, v is the same as in B, and AqT is a rotation that aligns v from A to that
        from T.

        It is assumed that vB is a unit vector!! This method returns TqB, which represents a twist about
        the axis vB.
    */
    Quaternion Quaternion::decomposeRotation(const Vector3d vB) const{
        //we need to compute v in A's coordinates
        Vector3d vA = this->rotate(vB);
        vA.toUnit();

        double temp = 0;

        //compute the rotation that alligns the vector v in the two coordinate frames (A and T)
        Vector3d rotAxis = vA.crossProductWith(vB);
        rotAxis.toUnit();
        double rotAngle = -safeACOS(vA.dotProductWith(vB));

        Quaternion TqA = Quaternion::getRotationQuaternion(rotAngle, rotAxis*(-1));
        return TqA * (*this);
    }

  • 相关阅读:
    SpringCloudStream实例
    Gateway环境搭建,通过YML文件配置
    Hystrix图形化监控
    Hystrix服务降级
    SpringBootのRedis
    springboot之缓存
    springboot整合JPA
    留言板
    Python 京东口罩监控+抢购
    2019年 自我总结
  • 原文地址:https://www.cnblogs.com/justin_s/p/1927798.html
Copyright © 2020-2023  润新知