相关疑难解决方法(0)

欧拉角到四元数然后四元数到欧拉角

我正在使用lib glm(http://glm.g-truc.net/)进行测试四元数,但我遇到了问题; 当我将欧拉角转换为四元数然后立即将四元数转换为欧拉角时,我的结果与我的初始欧拉角完全不同.这是正常的吗?可能是因为轮换不是交际?

代码测试:

#include <glm\quaternion.hpp>
#include <math.h>

#define PI M_PI
#define RADTODEG(x) ( (x) * 180.0 / PI )
#define DEGTORAD(x) ( (x) * PI / 180.0 )

int         main( void )
{
    float RotX = 90.f;
    float RotY = 180.f;
    float RotZ = -270.f;

    if ( RotX || RotY || RotZ )
    {
        std::cout << "Init: x= " << RotX << ", y= " << RotY << ", z= " << RotZ << "\n";
        glm::quat key_quat(glm::detail::tvec3<float>(DEGTORAD( …
Run Code Online (Sandbox Code Playgroud)

c++ math rotation quaternions euler-angles

13
推荐指数
3
解决办法
4万
查看次数

标签 统计

c++ ×1

euler-angles ×1

math ×1

quaternions ×1

rotation ×1