Glm四元数slerp

时间:2013-10-20 03:45:36

标签: c++ opengl

我正在尝试使用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 <glm\glm.hpp>
#include <glm\glm\glm.hpp>
using namespace glm;

但我无法让它发挥作用。我添加了所有glm四元数.hpp的

错误是“quaternion”必须是类名或命名空间。

1 个答案:

答案 0 :(得分:8)

namespace quaternionquaternion::的GLM 0.9.4.6中的所有文件进行搜索,只会在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版本中没有此版本,否则版本相同。

相关问题