简体   繁体   English

笛卡尔到四元数glm

[英]Cartesian to quaternion glm

I have a vector pointing in the direction I need to rotate, but I need to convert it to a quaternion first. 我有一个指向需要旋转的方向的矢量,但是我需要先将其转换为四元数。 I cannot find anything about converting from cartesian coordinates to quaternions in glm. 我找不到关于从笛卡尔坐标转换为glm的四元数的任何信息。 Does such a function exist? 是否存在这样的功能?

Maybe these will help you out. 也许这些会帮助您。 They can be found on their website in the API documents for v0.9.6: 可以在其网站上的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 

and

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 ) 

Within these list of functions; 在这些功能列表中; there are functions that will allow you to rotate using a quaternion from using two vectors that returns a quaternion, to convert to and from a matrix3x3 or 4x4 and other useful functions. 有一些函数可让您使用四元数来旋转,而使用两个返回四元数的向量来进行四元数的旋转,在矩阵3x3或4x4之间来回转换以及其他有用的函数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM