【发布时间】:2017-05-14 09:09:19
【问题描述】:
最近,我正在使用源对我的 3D 模型进行旋转。但是,调用函数时出现了问题: RotationBetweenVectors,定义在Tutorial 17( 链接:http://www.opengl-tutorial.org/intermediate-tutorials/tutorial-17-quaternions/)。 我想使用四元数方法将向量 _from 旋转到向量 _to。 两个向量定义如下,计算它们之间的quat。
vec3 _from(0, -0.150401f, 0.93125f), _to(-0.383022f, -0.413672f, 1.24691f);
quat _rot = RotationBetweenVectors(_from, _to);
vec3 _to1 = _rot * _from;
vec3 _to2 = _rot * _from * inverse(_rot);
然后我使用这个四元组 _rot 来乘以向量 _from。不幸的是,结果 _to1 和 _to2 都不等于向量 _to。
_rot gives {x=0.0775952041 y=-0.140000001 z=-0.0226106234 w=0.986847401}
_to1 gives {x=-0.264032304 y=-0.285160601 z=0.859544873 }
_to2 gives {x=-0.500465572 y=-0.390112638 z=0.697992325 }
如果有朋友能帮我解决这个问题,我很感激? 非常感谢!
【问题讨论】:
标签: c++ opengl rotation quaternions