【问题标题】:Cartesian to quaternion glm笛卡尔到四元数 glm
【发布时间】:2016-04-21 17:47:31
【问题描述】:

我有一个向量指向我需要旋转的方向,但我需要先将其转换为四元数。我找不到任何关于在 glm 中从笛卡尔坐标转换为四元数的信息。有这样的功能吗?

【问题讨论】:

    标签: c++ math rotation glm-math


    【解决方案1】:

    也许这些会帮助你。可以在他们的网站上的 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 ) 
    

    在这些函数列表中;有一些函数可以让您使用一个四元数从使用返回一个四元数的两个向量进行旋转,以转换为矩阵 3x3 或 4x4 以及其他有用的函数。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-04-13
      • 2011-03-24
      • 1970-01-01
      • 1970-01-01
      • 2021-10-22
      • 1970-01-01
      • 2013-03-13
      • 2018-07-06
      相关资源
      最近更新 更多