我有一个矢量指向我需要旋转的方向,但我需要首先将它转换为四元数。我在glm中找不到任何关于从笛卡尔坐标转换为四元数的内容。这样的函数是否存在?
发布于 2016-01-16 14:54:23
也许这些能帮到你。可以在他们的网站上找到v0.9.6的API文档:
GLM_FUNC_DECL tvec4<T, P> glm::rotate( tquat<T,P> const &q, tvec4<T,P> const &v )
Rotates a 4 components vector by a quaternion.
See also GLM_GTX_quaternion
GLM_FUNC_DECL tquat<T, P> glm::rotation( tvec3<T,P> const &orig, tvec3<T,P> const &dest )
Compute the rotation between two vectors.
param orig vector, needs to be normalized param dest vector, needs to be normalized
See also GLM_GTX_quaternion
和
template<typename T, precision P>
GLM_FUNC_DECL tvec3<T,P> rotate( tquat<T,P> const &q, tvec3<T,P> const &v )
template<typename T, precision P>
GLM_FUNC_DECL tvec4<T,P> rotate( tquat<T,P> const &q, tvec4<T,P> const &v )
template<typename T, precision P>
GLM_FUNC_DECL tquat<T,P> rotation( tvec3<T,P> const &orig, tvec3<T,P> const &dest )
template<typename T, precision P>
GLM_FUNC_DECL tquat<T,P> shortMix( tquat<T, P> const &x, tquat<T, P> const &y, T const &a )
template<typename T, precision P>
GLM_FUNC_DECL tquat<T,P> squad( tquat<T,P> const &q1, tquat<T,P> const &q2, tquat<T,P> const &s1, tquat<T,P> const &s2, T const &h )
template<typename T, precision P>
GLM_FUNC_DECL tmat3x3<T,P> toMat3( tquat<T,P> const &x )
template<typename T, precision P>
GLM_FUNC_DECL tmat4x4<T,P> toMat4( tquat<T,P> const &x )
template<typename T, precision P>
GLM_FUNC_DECL tquat<T,P> toQuat( tmat3x3<T,P> const &x )
template<typename T, precision P>
GLM_FUNC_DECL tquat<T,P> toQuat( tmat4x4<T,P> const &x )
在这些函数列表中,有一些函数将允许您使用四元数旋转,使用返回四元数的两个向量,以在matrix3x3或4x4和其他有用的函数之间进行转换。
https://stackoverflow.com/questions/34822832
复制相似问题