2017-05-27 50 views
0

它看起来像btTransform :: getOpenGLMatrix正在改变方向。 x的符号被翻转了,但我在getOpenGLMatrix的文档中没有找到任何关于此的信息。是getOpenGLMatrix不断变化的旋转?

auto t = btTransform(btQuaternion(0.7,0,0,0.7), bt(0,0,0)); 
glm::mat4 ogl_t; 
t.getOpenGLMatrix(glm::value_ptr(ogl_t)); 

glm::vec3 scale; 
glm::quat orientation; 
glm::vec3 translation; 
glm::vec3 skew; 
glm::vec4 perspective; 

glm::decompose(ogl_t,scale,orientation,translation,skew,perspective); // returns true 

assert(fabs(orientation.x - 0.7) < 0.02); // fails because x is -0.7 

回答

0

可以相同方向。

让我们来看看四元数的定义[x y z w]: -

// RotationAngle is in radians 
x = RotationAxis.x * sin(RotationAngle/2) 
y = RotationAxis.y * sin(RotationAngle/2) 
z = RotationAxis.z * sin(RotationAngle/2) 
w = cos(RotationAngle/2) 

例子:[x=0.7,y=0,z=0,w=0.7]相同[x=-0.7,y=0,z=0,w=-0.7]
因此,你的实验结果不是证据表明,定向改变

了解更多: