simd_quat.hpp
Go to the documentation of this file.
#pragma once
// Dependency:
#include "../glm.hpp"
#include "../gtc/quaternion.hpp"
#include "../gtx/fast_trigonometry.hpp"
#if(GLM_ARCH != GLM_ARCH_PURE)
#if(GLM_ARCH & GLM_ARCH_SSE2)
# include "../gtx/simd_mat4.hpp"
#else
# error "GLM: GLM_GTX_simd_quat requires compiler support of SSE2 through intrinsics"
#endif
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
# pragma message("GLM: GLM_GTX_simd_quat extension included")
#endif
// Warning silencer for nameless struct/union.
#if (GLM_COMPILER & GLM_COMPILER_VC)
# pragma warning(push)
# pragma warning(disable:4201) // warning C4201: nonstandard extension used : nameless struct/union
#endif
namespace glm{
namespace detail
{
GLM_ALIGNED_STRUCT(16) fquatSIMD
{
typedef __m128 value_type;
typedef std::size_t size_type;
static size_type value_size();
typedef fquatSIMD type;
typedef tquat<bool, defaultp> bool_type;
#ifdef GLM_SIMD_ENABLE_XYZW_UNION
union
{
__m128 Data;
struct {float x, y, z, w;};
};
#else
__m128 Data;
#endif
// Implicit basic constructors
fquatSIMD();
fquatSIMD(__m128 const & Data);
fquatSIMD(fquatSIMD const & q);
// Explicit basic constructors
explicit fquatSIMD(
ctor);
explicit fquatSIMD(
float const & w,
float const & x,
float const & y,
float const & z);
explicit fquatSIMD(
quat const & v);
explicit fquatSIMD(
vec3 const & eulerAngles);
// Unary arithmetic operators
fquatSIMD& operator =(fquatSIMD const & q);
fquatSIMD& operator*=(float const & s);
fquatSIMD& operator/=(float const & s);
};
// Arithmetic operators
detail::fquatSIMD operator- (
detail::fquatSIMD const & q);
detail::fquatSIMD operator+ (
detail::fquatSIMD const & q,
detail::fquatSIMD const & p);
detail::fquatSIMD operator* (
detail::fquatSIMD const & q,
detail::fquatSIMD const & p);
detail::fvec4SIMD operator* (
detail::fquatSIMD const & q,
detail::fvec4SIMD const & v);
detail::fvec4SIMD operator* (
detail::fvec4SIMD const & v,
detail::fquatSIMD const & q);
detail::fquatSIMD operator* (
detail::fquatSIMD const & q,
float s);
detail::fquatSIMD operator* (
float s,
detail::fquatSIMD const & q);
detail::fquatSIMD operator/ (
detail::fquatSIMD const & q,
float s);
}//namespace detail
typedef glm::detail::fquatSIMD simdQuat;
quat quat_cast(
detail::fquatSIMD const & x);
detail::fquatSIMD quatSIMD_cast(
detail::fmat4x4SIMD const & m);
template <typename T, precision P>
detail::fquatSIMD quatSIMD_cast(
tmat4x4<T, P> const & m);
template <typename T, precision P>
detail::fquatSIMD quatSIMD_cast(
tmat3x3<T, P> const & m);
detail::fmat4x4SIMD mat4SIMD_cast(
detail::fquatSIMD const & q);
mat4 mat4_cast(
detail::fquatSIMD const & q);
float length(
detail::fquatSIMD const & x);
detail::fquatSIMD normalize(
detail::fquatSIMD const & x);
float dot(
detail::fquatSIMD const & q1,
detail::fquatSIMD const & q2);
detail::fquatSIMD mix(
detail::fquatSIMD const & x,
detail::fquatSIMD const & y,
float const & a);
detail::fquatSIMD lerp(
detail::fquatSIMD const & x,
detail::fquatSIMD const & y,
float const & a);
detail::fquatSIMD slerp(
detail::fquatSIMD const & x,
detail::fquatSIMD const & y,
float const & a);
detail::fquatSIMD fastMix(
detail::fquatSIMD const & x,
detail::fquatSIMD const & y,
float const & a);
detail::fquatSIMD fastSlerp(
detail::fquatSIMD const & x,
detail::fquatSIMD const & y,
float const & a);
detail::fquatSIMD conjugate(
detail::fquatSIMD const & q);
detail::fquatSIMD inverse(
detail::fquatSIMD const & q);
detail::fquatSIMD angleAxisSIMD(
float const & angle,
vec3 const & axis);
detail::fquatSIMD angleAxisSIMD(
float const & angle,
float const & x,
float const & y,
float const & z);
// TODO: Move this to somewhere more appropriate. Used with fastMix() and fastSlerp().
__m128 fastSin(__m128 x);
}//namespace glm
#include "simd_quat.inl"
#if (GLM_COMPILER & GLM_COMPILER_VC)
# pragma warning(pop)
#endif
#endif//(GLM_ARCH != GLM_ARCH_PURE)
glm::fastSin
GLM_FUNC_DECL T fastSin(T angle)
Faster than the common sin function but less accurate.
glm::quat_cast
GLM_FUNC_DECL tquat< T, P > quat_cast(tmat3x3< T, P > const &x)
Converts a 3 * 3 matrix to a quaternion.
glm::axis
GLM_FUNC_DECL tvec3< T, P > axis(tquat< T, P > const &x)
Returns the q rotation axis.
glm::slerp
GLM_FUNC_DECL tquat< T, P > slerp(tquat< T, P > const &x, tquat< T, P > const &y, T const &a)
Spherical linear interpolation of two quaternions.
Definition: compatibility.hpp:76
glm::angle
GLM_FUNC_DECL T angle(tquat< T, P > const &x)
Returns the quaternion rotation angle.
glm::eulerAngles
GLM_FUNC_DECL tvec3< T, P > eulerAngles(tquat< T, P > const &x)
Returns euler angles, yitch as x, yaw as y, roll as z.
glm::dot
GLM_FUNC_DECL T dot(vecType< T, P > const &x, vecType< T, P > const &y)
Returns the dot product of x and y, i.e., result = x * y.
glm::mat4
mat4x4 mat4
4 columns of 4 components matrix of floating-point numbers.
Definition: type_mat.hpp:442
glm::length
GLM_FUNC_DECL T length(vecType< T, P > const &x)
Returns the length of x, i.e., sqrt(x * x).
glm::normalize
GLM_FUNC_DECL vecType< T, P > normalize(vecType< T, P > const &x)
Returns a vector in the same direction as x but with length of 1.
glm::mix
GLM_FUNC_DECL vecType< T, P > mix(vecType< T, P > const &x, vecType< T, P > const &y, vecType< U, P > const &a)
If genTypeU is a floating scalar or vector: Returns x * (1.0 - a) + y * a, i.e., the linear blend of ...
glm
Definition: _noise.hpp:39
glm::conjugate
GLM_FUNC_DECL tquat< T, P > conjugate(tquat< T, P > const &q)
Returns the q conjugate.
glm::vec3
highp_vec3 vec3
3 components vector of floating-point numbers.
Definition: type_vec.hpp:397
glm::inverse
GLM_FUNC_DECL matType< T, P > inverse(matType< T, P > const &m)
Return the inverse of a squared matrix.
glm::mat4_cast
GLM_FUNC_DECL tmat4x4< T, P > mat4_cast(tquat< T, P > const &x)
Converts a quaternion to a 4 * 4 matrix.
glm::fastMix
GLM_FUNC_DECL tquat< T, P > fastMix(tquat< T, P > const &x, tquat< T, P > const &y, T const &a)
Quaternion normalized linear interpolation.
glm::lerp
GLM_FUNC_DECL tquat< T, P > lerp(tquat< T, P > const &x, tquat< T, P > const &y, T const &a)
Linear interpolation of two quaternions.