Glm quaternion slerp
Glm quaternion slerp
我正在尝试使用 glm 中的四元数做 slerp。我正在使用
glm::quat interpolatedquat = quaternion::mix(quat1,quat2,0.5f)
这些是我添加的库
#include <glm/gtc/quaternion.hpp>
#include <glm/gtx/quaternion.hpp>
#include <glm/gtx/euler_angles.hpp>
#include <glm/gtx/norm.hpp>
#include <glmglm.hpp>
#include <glmglmglm.hpp>
using namespace glm;
但我无法让它工作。我添加了所有 glm 四元数 .hpp 的
错误是"四元数"必须是类名或命名空间。
在 GLM 0.9.4.6 中搜索所有文件以查找namespace quaternion
或quaternion::
,gtc/quaternion.hpp
中只有一行已被注释掉。 所有公共 GLM 功能都直接在 glm
命名空间中实现。 实现细节存在于glm::detail
中,偶尔也存在于glm::_detail
中,但切勿直接使用这些命名空间中的任何内容,因为它们在将来的版本中可能会发生变化。
不使用每个模块/扩展的子命名空间。 因此,您只需要:
glm::quat interpolatedquat = glm::mix(quat1,quat2,0.5f)
你可能想要一个分号在最后。
编辑:您可能还想使用glm::slerp
而不是glm::mix
因为它有一个额外的检查,以确保采用最短路径:
// If cosTheta < 0, the interpolation will take the long way around the sphere.
// To fix this, one quat must be negated.
if (cosTheta < T(0))
{
z = -y;
cosTheta = -cosTheta;
}
这在mix
版本中不存在,否则是相同的。