|
|
@ -59,6 +59,26 @@ namespace detail |
|
|
|
} |
|
|
|
} |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////// |
|
|
|
|
|
|
|
// Accesses |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template <typename T, precision P> |
|
|
|
|
|
|
|
GLM_FUNC_QUALIFIER T & tquat<T, P>::operator[] (length_t i) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
assert(i >= 0 && i < this->length()); |
|
|
|
|
|
|
|
return (&x)[i]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template <typename T, precision P> |
|
|
|
|
|
|
|
GLM_FUNC_QUALIFIER T const & tquat<T, P>::operator[] (length_t i) const |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
assert(i >= 0 && i < this->length()); |
|
|
|
|
|
|
|
return (&x)[i]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////// |
|
|
|
|
|
|
|
// Implicit basic constructors |
|
|
|
|
|
|
|
|
|
|
|
template <typename T, precision P> |
|
|
|
template <typename T, precision P> |
|
|
|
GLM_FUNC_QUALIFIER tquat<T, P>::tquat() |
|
|
|
GLM_FUNC_QUALIFIER tquat<T, P>::tquat() |
|
|
|
# ifndef GLM_FORCE_NO_CTOR_INIT |
|
|
|
# ifndef GLM_FORCE_NO_CTOR_INIT |
|
|
@ -67,48 +87,35 @@ namespace detail |
|
|
|
{} |
|
|
|
{} |
|
|
|
|
|
|
|
|
|
|
|
template <typename T, precision P> |
|
|
|
template <typename T, precision P> |
|
|
|
GLM_FUNC_QUALIFIER tquat<T, P>::tquat(tquat<T, P> const & q) : |
|
|
|
GLM_FUNC_QUALIFIER tquat<T, P>::tquat(tquat<T, P> const & q) |
|
|
|
x(q.x), y(q.y), z(q.z), w(q.w) |
|
|
|
: x(q.x), y(q.y), z(q.z), w(q.w) |
|
|
|
{} |
|
|
|
{} |
|
|
|
|
|
|
|
|
|
|
|
template <typename T, precision P> |
|
|
|
template <typename T, precision P> |
|
|
|
template <precision Q> |
|
|
|
template <precision Q> |
|
|
|
GLM_FUNC_QUALIFIER tquat<T, P>::tquat(tquat<T, Q> const & q) : |
|
|
|
GLM_FUNC_QUALIFIER tquat<T, P>::tquat(tquat<T, Q> const & q) |
|
|
|
x(q.x), y(q.y), z(q.z), w(q.w) |
|
|
|
: x(q.x), y(q.y), z(q.z), w(q.w) |
|
|
|
{} |
|
|
|
{} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////// |
|
|
|
|
|
|
|
// Explicit basic constructors |
|
|
|
|
|
|
|
|
|
|
|
template <typename T, precision P> |
|
|
|
template <typename T, precision P> |
|
|
|
GLM_FUNC_QUALIFIER tquat<T, P>::tquat(ctor) |
|
|
|
GLM_FUNC_QUALIFIER tquat<T, P>::tquat(ctor) |
|
|
|
{} |
|
|
|
{} |
|
|
|
|
|
|
|
|
|
|
|
template <typename T, precision P> |
|
|
|
template <typename T, precision P> |
|
|
|
GLM_FUNC_QUALIFIER tquat<T, P>::tquat |
|
|
|
GLM_FUNC_QUALIFIER tquat<T, P>::tquat(T const & s, tvec3<T, P> const & v) |
|
|
|
( |
|
|
|
: x(v.x), y(v.y), z(v.z), w(s) |
|
|
|
T const & s, |
|
|
|
|
|
|
|
tvec3<T, P> const & v |
|
|
|
|
|
|
|
) : |
|
|
|
|
|
|
|
x(v.x), |
|
|
|
|
|
|
|
y(v.y), |
|
|
|
|
|
|
|
z(v.z), |
|
|
|
|
|
|
|
w(s) |
|
|
|
|
|
|
|
{} |
|
|
|
{} |
|
|
|
|
|
|
|
|
|
|
|
template <typename T, precision P> |
|
|
|
template <typename T, precision P> |
|
|
|
GLM_FUNC_QUALIFIER tquat<T, P>::tquat |
|
|
|
GLM_FUNC_QUALIFIER tquat<T, P>::tquat(T const & w, T const & x, T const & y, T const & z) |
|
|
|
( |
|
|
|
: x(x), y(y), z(z), w(w) |
|
|
|
T const & w, |
|
|
|
|
|
|
|
T const & x, |
|
|
|
|
|
|
|
T const & y, |
|
|
|
|
|
|
|
T const & z |
|
|
|
|
|
|
|
) : |
|
|
|
|
|
|
|
x(x), |
|
|
|
|
|
|
|
y(y), |
|
|
|
|
|
|
|
z(z), |
|
|
|
|
|
|
|
w(w) |
|
|
|
|
|
|
|
{} |
|
|
|
{} |
|
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////// |
|
|
|
////////////////////////////////////////////////////////////// |
|
|
|
// tquat conversions |
|
|
|
// Conversions |
|
|
|
|
|
|
|
|
|
|
|
//template <typename valType> |
|
|
|
//template <typename valType> |
|
|
|
//GLM_FUNC_QUALIFIER tquat<valType>::tquat |
|
|
|
//GLM_FUNC_QUALIFIER tquat<valType>::tquat |
|
|
@ -129,11 +136,7 @@ namespace detail |
|
|
|
//} |
|
|
|
//} |
|
|
|
|
|
|
|
|
|
|
|
template <typename T, precision P> |
|
|
|
template <typename T, precision P> |
|
|
|
GLM_FUNC_QUALIFIER tquat<T, P>::tquat |
|
|
|
GLM_FUNC_QUALIFIER tquat<T, P>::tquat(tvec3<T, P> const & u, tvec3<T, P> const & v) |
|
|
|
( |
|
|
|
|
|
|
|
tvec3<T, P> const & u, |
|
|
|
|
|
|
|
tvec3<T, P> const & v |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
tvec3<T, P> const LocalW(cross(u, v)); |
|
|
|
tvec3<T, P> const LocalW(cross(u, v)); |
|
|
|
T Dot = detail::compute_dot<tvec3, T, P>::call(u, v); |
|
|
|
T Dot = detail::compute_dot<tvec3, T, P>::call(u, v); |
|
|
@ -143,10 +146,7 @@ namespace detail |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
template <typename T, precision P> |
|
|
|
template <typename T, precision P> |
|
|
|
GLM_FUNC_QUALIFIER tquat<T, P>::tquat |
|
|
|
GLM_FUNC_QUALIFIER tquat<T, P>::tquat(tvec3<T, P> const & eulerAngle) |
|
|
|
( |
|
|
|
|
|
|
|
tvec3<T, P> const & eulerAngle |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
tvec3<T, P> c = glm::cos(eulerAngle * T(0.5)); |
|
|
|
tvec3<T, P> c = glm::cos(eulerAngle * T(0.5)); |
|
|
|
tvec3<T, P> s = glm::sin(eulerAngle * T(0.5)); |
|
|
|
tvec3<T, P> s = glm::sin(eulerAngle * T(0.5)); |
|
|
@ -158,54 +158,25 @@ namespace detail |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
template <typename T, precision P> |
|
|
|
template <typename T, precision P> |
|
|
|
GLM_FUNC_QUALIFIER tquat<T, P>::tquat |
|
|
|
GLM_FUNC_QUALIFIER tquat<T, P>::tquat(tmat3x3<T, P> const & m) |
|
|
|
( |
|
|
|
|
|
|
|
tmat3x3<T, P> const & m |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
*this = quat_cast(m); |
|
|
|
*this = quat_cast(m); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
template <typename T, precision P> |
|
|
|
template <typename T, precision P> |
|
|
|
GLM_FUNC_QUALIFIER tquat<T, P>::tquat |
|
|
|
GLM_FUNC_QUALIFIER tquat<T, P>::tquat(tmat4x4<T, P> const & m) |
|
|
|
( |
|
|
|
|
|
|
|
tmat4x4<T, P> const & m |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
*this = quat_cast(m); |
|
|
|
*this = quat_cast(m); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////// |
|
|
|
|
|
|
|
// tquat<T, P> accesses |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template <typename T, precision P> |
|
|
|
template <typename T, precision P> |
|
|
|
GLM_FUNC_QUALIFIER T & tquat<T, P>::operator[] (length_t i) |
|
|
|
GLM_FUNC_QUALIFIER tquat<T, P> conjugate(tquat<T, P> const & q) |
|
|
|
{ |
|
|
|
|
|
|
|
assert(i >= 0 && i < this->length()); |
|
|
|
|
|
|
|
return (&x)[i]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template <typename T, precision P> |
|
|
|
|
|
|
|
GLM_FUNC_QUALIFIER T const & tquat<T, P>::operator[] (length_t i) const |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
assert(i >= 0 && i < this->length()); |
|
|
|
|
|
|
|
return (&x)[i]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template <typename T, precision P> |
|
|
|
|
|
|
|
GLM_FUNC_QUALIFIER tquat<T, P> conjugate |
|
|
|
|
|
|
|
( |
|
|
|
|
|
|
|
tquat<T, P> const & q |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
return tquat<T, P>(q.w, -q.x, -q.y, -q.z); |
|
|
|
return tquat<T, P>(q.w, -q.x, -q.y, -q.z); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
template <typename T, precision P> |
|
|
|
template <typename T, precision P> |
|
|
|
GLM_FUNC_QUALIFIER tquat<T, P> inverse |
|
|
|
GLM_FUNC_QUALIFIER tquat<T, P> inverse(tquat<T, P> const & q) |
|
|
|
( |
|
|
|
|
|
|
|
tquat<T, P> const & q |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
return conjugate(q) / dot(q, q); |
|
|
|
return conjugate(q) / dot(q, q); |
|
|
|
} |
|
|
|
} |
|
|
@ -214,10 +185,7 @@ namespace detail |
|
|
|
// tquat<valType> operators |
|
|
|
// tquat<valType> operators |
|
|
|
|
|
|
|
|
|
|
|
template <typename T, precision P> |
|
|
|
template <typename T, precision P> |
|
|
|
GLM_FUNC_QUALIFIER tquat<T, P> & tquat<T, P>::operator += |
|
|
|
GLM_FUNC_QUALIFIER tquat<T, P> & tquat<T, P>::operator+=(tquat<T, P> const & q) |
|
|
|
( |
|
|
|
|
|
|
|
tquat<T, P> const & q |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
this->w += q.w; |
|
|
|
this->w += q.w; |
|
|
|
this->x += q.x; |
|
|
|
this->x += q.x; |
|
|
@ -227,10 +195,7 @@ namespace detail |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
template <typename T, precision P> |
|
|
|
template <typename T, precision P> |
|
|
|
GLM_FUNC_QUALIFIER tquat<T, P> & tquat<T, P>::operator *= |
|
|
|
GLM_FUNC_QUALIFIER tquat<T, P> & tquat<T, P>::operator*=(tquat<T, P> const & q) |
|
|
|
( |
|
|
|
|
|
|
|
tquat<T, P> const & q |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
tquat<T, P> const p(*this); |
|
|
|
tquat<T, P> const p(*this); |
|
|
|
|
|
|
|
|
|
|
@ -242,10 +207,7 @@ namespace detail |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
template <typename T, precision P> |
|
|
|
template <typename T, precision P> |
|
|
|
GLM_FUNC_QUALIFIER tquat<T, P> & tquat<T, P>::operator *= |
|
|
|
GLM_FUNC_QUALIFIER tquat<T, P> & tquat<T, P>::operator*=(T const & s) |
|
|
|
( |
|
|
|
|
|
|
|
T const & s |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
this->w *= s; |
|
|
|
this->w *= s; |
|
|
|
this->x *= s; |
|
|
|
this->x *= s; |
|
|
@ -255,10 +217,7 @@ namespace detail |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
template <typename T, precision P> |
|
|
|
template <typename T, precision P> |
|
|
|
GLM_FUNC_QUALIFIER tquat<T, P> & tquat<T, P>::operator /= |
|
|
|
GLM_FUNC_QUALIFIER tquat<T, P> & tquat<T, P>::operator/=(T const & s) |
|
|
|
( |
|
|
|
|
|
|
|
T const & s |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
this->w /= s; |
|
|
|
this->w /= s; |
|
|
|
this->x /= s; |
|
|
|
this->x /= s; |
|
|
@ -271,41 +230,26 @@ namespace detail |
|
|
|
// tquat<T, P> external operators |
|
|
|
// tquat<T, P> external operators |
|
|
|
|
|
|
|
|
|
|
|
template <typename T, precision P> |
|
|
|
template <typename T, precision P> |
|
|
|
GLM_FUNC_QUALIFIER tquat<T, P> operator- |
|
|
|
GLM_FUNC_QUALIFIER tquat<T, P> operator-(tquat<T, P> const & q) |
|
|
|
( |
|
|
|
|
|
|
|
tquat<T, P> const & q |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
return tquat<T, P>(-q.w, -q.x, -q.y, -q.z); |
|
|
|
return tquat<T, P>(-q.w, -q.x, -q.y, -q.z); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
template <typename T, precision P> |
|
|
|
template <typename T, precision P> |
|
|
|
GLM_FUNC_QUALIFIER tquat<T, P> operator+ |
|
|
|
GLM_FUNC_QUALIFIER tquat<T, P> operator+(tquat<T, P> const & q, tquat<T, P> const & p) |
|
|
|
( |
|
|
|
|
|
|
|
tquat<T, P> const & q, |
|
|
|
|
|
|
|
tquat<T, P> const & p |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
return tquat<T, P>(q) += p; |
|
|
|
return tquat<T, P>(q) += p; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
template <typename T, precision P> |
|
|
|
template <typename T, precision P> |
|
|
|
GLM_FUNC_QUALIFIER tquat<T, P> operator* |
|
|
|
GLM_FUNC_QUALIFIER tquat<T, P> operator*(tquat<T, P> const & q, tquat<T, P> const & p) |
|
|
|
( |
|
|
|
|
|
|
|
tquat<T, P> const & q, |
|
|
|
|
|
|
|
tquat<T, P> const & p |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
return tquat<T, P>(q) *= p; |
|
|
|
return tquat<T, P>(q) *= p; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Transformation |
|
|
|
// Transformation |
|
|
|
template <typename T, precision P> |
|
|
|
template <typename T, precision P> |
|
|
|
GLM_FUNC_QUALIFIER tvec3<T, P> operator* |
|
|
|
GLM_FUNC_QUALIFIER tvec3<T, P> operator*(tquat<T, P> const & q, tvec3<T, P> const & v) |
|
|
|
( |
|
|
|
|
|
|
|
tquat<T, P> const & q, |
|
|
|
|
|
|
|
tvec3<T, P> const & v |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
tvec3<T, P> const QuatVector(q.x, q.y, q.z); |
|
|
|
tvec3<T, P> const QuatVector(q.x, q.y, q.z); |
|
|
|
tvec3<T, P> const uv(glm::cross(QuatVector, v)); |
|
|
|
tvec3<T, P> const uv(glm::cross(QuatVector, v)); |
|
|
@ -315,62 +259,38 @@ namespace detail |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
template <typename T, precision P> |
|
|
|
template <typename T, precision P> |
|
|
|
GLM_FUNC_QUALIFIER tvec3<T, P> operator* |
|
|
|
GLM_FUNC_QUALIFIER tvec3<T, P> operator*(tvec3<T, P> const & v, tquat<T, P> const & q) |
|
|
|
( |
|
|
|
|
|
|
|
tvec3<T, P> const & v, |
|
|
|
|
|
|
|
tquat<T, P> const & q |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
return glm::inverse(q) * v; |
|
|
|
return glm::inverse(q) * v; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
template <typename T, precision P> |
|
|
|
template <typename T, precision P> |
|
|
|
GLM_FUNC_QUALIFIER tvec4<T, P> operator* |
|
|
|
GLM_FUNC_QUALIFIER tvec4<T, P> operator*(tquat<T, P> const & q, tvec4<T, P> const & v) |
|
|
|
( |
|
|
|
|
|
|
|
tquat<T, P> const & q, |
|
|
|
|
|
|
|
tvec4<T, P> const & v |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
return tvec4<T, P>(q * tvec3<T, P>(v), v.w); |
|
|
|
return tvec4<T, P>(q * tvec3<T, P>(v), v.w); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
template <typename T, precision P> |
|
|
|
template <typename T, precision P> |
|
|
|
GLM_FUNC_QUALIFIER tvec4<T, P> operator* |
|
|
|
GLM_FUNC_QUALIFIER tvec4<T, P> operator*(tvec4<T, P> const & v, tquat<T, P> const & q) |
|
|
|
( |
|
|
|
|
|
|
|
tvec4<T, P> const & v, |
|
|
|
|
|
|
|
tquat<T, P> const & q |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
return glm::inverse(q) * v; |
|
|
|
return glm::inverse(q) * v; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
template <typename T, precision P> |
|
|
|
template <typename T, precision P> |
|
|
|
GLM_FUNC_QUALIFIER tquat<T, P> operator* |
|
|
|
GLM_FUNC_QUALIFIER tquat<T, P> operator*(tquat<T, P> const & q, T const & s) |
|
|
|
( |
|
|
|
|
|
|
|
tquat<T, P> const & q, |
|
|
|
|
|
|
|
T const & s |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
return tquat<T, P>( |
|
|
|
return tquat<T, P>( |
|
|
|
q.w * s, q.x * s, q.y * s, q.z * s); |
|
|
|
q.w * s, q.x * s, q.y * s, q.z * s); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
template <typename T, precision P> |
|
|
|
template <typename T, precision P> |
|
|
|
GLM_FUNC_QUALIFIER tquat<T, P> operator* |
|
|
|
GLM_FUNC_QUALIFIER tquat<T, P> operator*(T const & s, tquat<T, P> const & q) |
|
|
|
( |
|
|
|
|
|
|
|
T const & s, |
|
|
|
|
|
|
|
tquat<T, P> const & q |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
return q * s; |
|
|
|
return q * s; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
template <typename T, precision P> |
|
|
|
template <typename T, precision P> |
|
|
|
GLM_FUNC_QUALIFIER tquat<T, P> operator/ |
|
|
|
GLM_FUNC_QUALIFIER tquat<T, P> operator/(tquat<T, P> const & q, T const & s) |
|
|
|
( |
|
|
|
|
|
|
|
tquat<T, P> const & q, |
|
|
|
|
|
|
|
T const & s |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
return tquat<T, P>( |
|
|
|
return tquat<T, P>( |
|
|
|
q.w / s, q.x / s, q.y / s, q.z / s); |
|
|
|
q.w / s, q.x / s, q.y / s, q.z / s); |
|
|
@ -380,40 +300,26 @@ namespace detail |
|
|
|
// Boolean operators |
|
|
|
// Boolean operators |
|
|
|
|
|
|
|
|
|
|
|
template <typename T, precision P> |
|
|
|
template <typename T, precision P> |
|
|
|
GLM_FUNC_QUALIFIER bool operator== |
|
|
|
GLM_FUNC_QUALIFIER bool operator==(tquat<T, P> const & q1, tquat<T, P> const & q2) |
|
|
|
( |
|
|
|
|
|
|
|
tquat<T, P> const & q1, |
|
|
|
|
|
|
|
tquat<T, P> const & q2 |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
return (q1.x == q2.x) && (q1.y == q2.y) && (q1.z == q2.z) && (q1.w == q2.w); |
|
|
|
return (q1.x == q2.x) && (q1.y == q2.y) && (q1.z == q2.z) && (q1.w == q2.w); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
template <typename T, precision P> |
|
|
|
template <typename T, precision P> |
|
|
|
GLM_FUNC_QUALIFIER bool operator!= |
|
|
|
GLM_FUNC_QUALIFIER bool operator!=(tquat<T, P> const & q1, tquat<T, P> const & q2) |
|
|
|
( |
|
|
|
|
|
|
|
tquat<T, P> const & q1, |
|
|
|
|
|
|
|
tquat<T, P> const & q2 |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
return (q1.x != q2.x) || (q1.y != q2.y) || (q1.z != q2.z) || (q1.w != q2.w); |
|
|
|
return (q1.x != q2.x) || (q1.y != q2.y) || (q1.z != q2.z) || (q1.w != q2.w); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////// |
|
|
|
//////////////////////////////////////////////////////// |
|
|
|
template <typename T, precision P> |
|
|
|
template <typename T, precision P> |
|
|
|
GLM_FUNC_QUALIFIER T length |
|
|
|
GLM_FUNC_QUALIFIER T length(tquat<T, P> const & q) |
|
|
|
( |
|
|
|
|
|
|
|
tquat<T, P> const & q |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
return glm::sqrt(dot(q, q)); |
|
|
|
return glm::sqrt(dot(q, q)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
template <typename T, precision P> |
|
|
|
template <typename T, precision P> |
|
|
|
GLM_FUNC_QUALIFIER tquat<T, P> normalize |
|
|
|
GLM_FUNC_QUALIFIER tquat<T, P> normalize(tquat<T, P> const & q) |
|
|
|
( |
|
|
|
|
|
|
|
tquat<T, P> const & q |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
T len = length(q); |
|
|
|
T len = length(q); |
|
|
|
if(len <= T(0)) // Problem |
|
|
|
if(len <= T(0)) // Problem |
|
|
@ -423,11 +329,7 @@ namespace detail |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
template <typename T, precision P> |
|
|
|
template <typename T, precision P> |
|
|
|
GLM_FUNC_QUALIFIER tquat<T, P> cross |
|
|
|
GLM_FUNC_QUALIFIER tquat<T, P> cross(tquat<T, P> const & q1, tquat<T, P> const & q2) |
|
|
|
( |
|
|
|
|
|
|
|
tquat<T, P> const & q1, |
|
|
|
|
|
|
|
tquat<T, P> const & q2 |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
return tquat<T, P>( |
|
|
|
return tquat<T, P>( |
|
|
|
q1.w * q2.w - q1.x * q2.x - q1.y * q2.y - q1.z * q2.z, |
|
|
|
q1.w * q2.w - q1.x * q2.x - q1.y * q2.y - q1.z * q2.z, |
|
|
@ -438,12 +340,7 @@ namespace detail |
|
|
|
/* |
|
|
|
/* |
|
|
|
// (x * sin(1 - a) * angle / sin(angle)) + (y * sin(a) * angle / sin(angle)) |
|
|
|
// (x * sin(1 - a) * angle / sin(angle)) + (y * sin(a) * angle / sin(angle)) |
|
|
|
template <typename T, precision P> |
|
|
|
template <typename T, precision P> |
|
|
|
GLM_FUNC_QUALIFIER tquat<T, P> mix |
|
|
|
GLM_FUNC_QUALIFIER tquat<T, P> mix(tquat<T, P> const & x, tquat<T, P> const & y, T const & a) |
|
|
|
( |
|
|
|
|
|
|
|
tquat<T, P> const & x, |
|
|
|
|
|
|
|
tquat<T, P> const & y, |
|
|
|
|
|
|
|
T const & a |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
if(a <= T(0)) return x; |
|
|
|
if(a <= T(0)) return x; |
|
|
|
if(a >= T(1)) return y; |
|
|
|
if(a >= T(1)) return y; |
|
|
@ -518,12 +415,7 @@ namespace detail |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
template <typename T, precision P> |
|
|
|
template <typename T, precision P> |
|
|
|
GLM_FUNC_QUALIFIER tquat<T, P> mix |
|
|
|
GLM_FUNC_QUALIFIER tquat<T, P> mix(tquat<T, P> const & x, tquat<T, P> const & y, T const & a) |
|
|
|
( |
|
|
|
|
|
|
|
tquat<T, P> const & x, |
|
|
|
|
|
|
|
tquat<T, P> const & y, |
|
|
|
|
|
|
|
T const & a |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
T cosTheta = dot(x, y); |
|
|
|
T cosTheta = dot(x, y); |
|
|
|
|
|
|
|
|
|
|
@ -546,12 +438,7 @@ namespace detail |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
template <typename T, precision P> |
|
|
|
template <typename T, precision P> |
|
|
|
GLM_FUNC_QUALIFIER tquat<T, P> lerp |
|
|
|
GLM_FUNC_QUALIFIER tquat<T, P> lerp(tquat<T, P> const & x, tquat<T, P> const & y, T const & a) |
|
|
|
( |
|
|
|
|
|
|
|
tquat<T, P> const & x, |
|
|
|
|
|
|
|
tquat<T, P> const & y, |
|
|
|
|
|
|
|
T const & a |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
// Lerp is only defined in [0, 1] |
|
|
|
// Lerp is only defined in [0, 1] |
|
|
|
assert(a >= static_cast<T>(0)); |
|
|
|
assert(a >= static_cast<T>(0)); |
|
|
@ -561,12 +448,7 @@ namespace detail |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
template <typename T, precision P> |
|
|
|
template <typename T, precision P> |
|
|
|
GLM_FUNC_QUALIFIER tquat<T, P> slerp |
|
|
|
GLM_FUNC_QUALIFIER tquat<T, P> slerp(tquat<T, P> const & x, tquat<T, P> const & y, T const & a) |
|
|
|
( |
|
|
|
|
|
|
|
tquat<T, P> const & x, |
|
|
|
|
|
|
|
tquat<T, P> const & y, |
|
|
|
|
|
|
|
T const & a |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
tquat<T, P> z = y; |
|
|
|
tquat<T, P> z = y; |
|
|
|
|
|
|
|
|
|
|
@ -599,12 +481,7 @@ namespace detail |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
template <typename T, precision P> |
|
|
|
template <typename T, precision P> |
|
|
|
GLM_FUNC_QUALIFIER tquat<T, P> rotate |
|
|
|
GLM_FUNC_QUALIFIER tquat<T, P> rotate(tquat<T, P> const & q, T const & angle, tvec3<T, P> const & v) |
|
|
|
( |
|
|
|
|
|
|
|
tquat<T, P> const & q, |
|
|
|
|
|
|
|
T const & angle, |
|
|
|
|
|
|
|
tvec3<T, P> const & v |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
tvec3<T, P> Tmp = v; |
|
|
|
tvec3<T, P> Tmp = v; |
|
|
|
|
|
|
|
|
|
|
@ -626,46 +503,31 @@ namespace detail |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
template <typename T, precision P> |
|
|
|
template <typename T, precision P> |
|
|
|
GLM_FUNC_QUALIFIER tvec3<T, P> eulerAngles |
|
|
|
GLM_FUNC_QUALIFIER tvec3<T, P> eulerAngles(tquat<T, P> const & x) |
|
|
|
( |
|
|
|
|
|
|
|
tquat<T, P> const & x |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
return tvec3<T, P>(pitch(x), yaw(x), roll(x)); |
|
|
|
return tvec3<T, P>(pitch(x), yaw(x), roll(x)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
template <typename T, precision P> |
|
|
|
template <typename T, precision P> |
|
|
|
GLM_FUNC_QUALIFIER T roll |
|
|
|
GLM_FUNC_QUALIFIER T roll(tquat<T, P> const & q) |
|
|
|
( |
|
|
|
|
|
|
|
tquat<T, P> const & q |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
return T(atan(T(2) * (q.x * q.y + q.w * q.z), q.w * q.w + q.x * q.x - q.y * q.y - q.z * q.z)); |
|
|
|
return T(atan(T(2) * (q.x * q.y + q.w * q.z), q.w * q.w + q.x * q.x - q.y * q.y - q.z * q.z)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
template <typename T, precision P> |
|
|
|
template <typename T, precision P> |
|
|
|
GLM_FUNC_QUALIFIER T pitch |
|
|
|
GLM_FUNC_QUALIFIER T pitch(tquat<T, P> const & q) |
|
|
|
( |
|
|
|
|
|
|
|
tquat<T, P> const & q |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
return T(atan(T(2) * (q.y * q.z + q.w * q.x), q.w * q.w - q.x * q.x - q.y * q.y + q.z * q.z)); |
|
|
|
return T(atan(T(2) * (q.y * q.z + q.w * q.x), q.w * q.w - q.x * q.x - q.y * q.y + q.z * q.z)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
template <typename T, precision P> |
|
|
|
template <typename T, precision P> |
|
|
|
GLM_FUNC_QUALIFIER T yaw |
|
|
|
GLM_FUNC_QUALIFIER T yaw(tquat<T, P> const & q) |
|
|
|
( |
|
|
|
|
|
|
|
tquat<T, P> const & q |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
return asin(T(-2) * (q.x * q.z - q.w * q.y)); |
|
|
|
return asin(T(-2) * (q.x * q.z - q.w * q.y)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
template <typename T, precision P> |
|
|
|
template <typename T, precision P> |
|
|
|
GLM_FUNC_QUALIFIER tmat3x3<T, P> mat3_cast |
|
|
|
GLM_FUNC_QUALIFIER tmat3x3<T, P> mat3_cast(tquat<T, P> const & q) |
|
|
|
( |
|
|
|
|
|
|
|
tquat<T, P> const & q |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
tmat3x3<T, P> Result(T(1)); |
|
|
|
tmat3x3<T, P> Result(T(1)); |
|
|
|
T qxx(q.x * q.x); |
|
|
|
T qxx(q.x * q.x); |
|
|
@ -693,19 +555,13 @@ namespace detail |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
template <typename T, precision P> |
|
|
|
template <typename T, precision P> |
|
|
|
GLM_FUNC_QUALIFIER tmat4x4<T, P> mat4_cast |
|
|
|
GLM_FUNC_QUALIFIER tmat4x4<T, P> mat4_cast(tquat<T, P> const & q) |
|
|
|
( |
|
|
|
|
|
|
|
tquat<T, P> const & q |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
return tmat4x4<T, P>(mat3_cast(q)); |
|
|
|
return tmat4x4<T, P>(mat3_cast(q)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
template <typename T, precision P> |
|
|
|
template <typename T, precision P> |
|
|
|
GLM_FUNC_QUALIFIER tquat<T, P> quat_cast |
|
|
|
GLM_FUNC_QUALIFIER tquat<T, P> quat_cast(tmat3x3<T, P> const & m) |
|
|
|
( |
|
|
|
|
|
|
|
tmat3x3<T, P> const & m |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
T fourXSquaredMinus1 = m[0][0] - m[1][1] - m[2][2]; |
|
|
|
T fourXSquaredMinus1 = m[0][0] - m[1][1] - m[2][2]; |
|
|
|
T fourYSquaredMinus1 = m[1][1] - m[0][0] - m[2][2]; |
|
|
|
T fourYSquaredMinus1 = m[1][1] - m[0][0] - m[2][2]; |
|
|
@ -769,28 +625,19 @@ namespace detail |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
template <typename T, precision P> |
|
|
|
template <typename T, precision P> |
|
|
|
GLM_FUNC_QUALIFIER tquat<T, P> quat_cast |
|
|
|
GLM_FUNC_QUALIFIER tquat<T, P> quat_cast(tmat4x4<T, P> const & m4) |
|
|
|
( |
|
|
|
|
|
|
|
tmat4x4<T, P> const & m4 |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
return quat_cast(tmat3x3<T, P>(m4)); |
|
|
|
return quat_cast(tmat3x3<T, P>(m4)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
template <typename T, precision P> |
|
|
|
template <typename T, precision P> |
|
|
|
GLM_FUNC_QUALIFIER T angle |
|
|
|
GLM_FUNC_QUALIFIER T angle(tquat<T, P> const & x) |
|
|
|
( |
|
|
|
|
|
|
|
tquat<T, P> const & x |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
return acos(x.w) * T(2); |
|
|
|
return acos(x.w) * T(2); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
template <typename T, precision P> |
|
|
|
template <typename T, precision P> |
|
|
|
GLM_FUNC_QUALIFIER tvec3<T, P> axis |
|
|
|
GLM_FUNC_QUALIFIER tvec3<T, P> axis(tquat<T, P> const & x) |
|
|
|
( |
|
|
|
|
|
|
|
tquat<T, P> const & x |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
T tmp1 = static_cast<T>(1) - x.w * x.w; |
|
|
|
T tmp1 = static_cast<T>(1) - x.w * x.w; |
|
|
|
if(tmp1 <= static_cast<T>(0)) |
|
|
|
if(tmp1 <= static_cast<T>(0)) |
|
|
@ -800,11 +647,7 @@ namespace detail |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
template <typename T, precision P> |
|
|
|
template <typename T, precision P> |
|
|
|
GLM_FUNC_QUALIFIER tquat<T, P> angleAxis |
|
|
|
GLM_FUNC_QUALIFIER tquat<T, P> angleAxis(T const & angle, tvec3<T, P> const & v) |
|
|
|
( |
|
|
|
|
|
|
|
T const & angle, |
|
|
|
|
|
|
|
tvec3<T, P> const & v |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
tquat<T, P> Result(uninitialize); |
|
|
|
tquat<T, P> Result(uninitialize); |
|
|
|
|
|
|
|
|
|
|
@ -819,11 +662,7 @@ namespace detail |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
template <typename T, precision P> |
|
|
|
template <typename T, precision P> |
|
|
|
GLM_FUNC_QUALIFIER tvec4<bool, P> lessThan |
|
|
|
GLM_FUNC_QUALIFIER tvec4<bool, P> lessThan(tquat<T, P> const & x, tquat<T, P> const & y) |
|
|
|
( |
|
|
|
|
|
|
|
tquat<T, P> const & x, |
|
|
|
|
|
|
|
tquat<T, P> const & y |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
tvec4<bool, P> Result(uninitialize); |
|
|
|
tvec4<bool, P> Result(uninitialize); |
|
|
|
for(detail::component_count_t i = 0; i < detail::component_count(x); ++i) |
|
|
|
for(detail::component_count_t i = 0; i < detail::component_count(x); ++i) |
|
|
@ -832,11 +671,7 @@ namespace detail |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
template <typename T, precision P> |
|
|
|
template <typename T, precision P> |
|
|
|
GLM_FUNC_QUALIFIER tvec4<bool, P> lessThanEqual |
|
|
|
GLM_FUNC_QUALIFIER tvec4<bool, P> lessThanEqual(tquat<T, P> const & x, tquat<T, P> const & y) |
|
|
|
( |
|
|
|
|
|
|
|
tquat<T, P> const & x, |
|
|
|
|
|
|
|
tquat<T, P> const & y |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
tvec4<bool, P> Result(uninitialize); |
|
|
|
tvec4<bool, P> Result(uninitialize); |
|
|
|
for(detail::component_count_t i = 0; i < detail::component_count(x); ++i) |
|
|
|
for(detail::component_count_t i = 0; i < detail::component_count(x); ++i) |
|
|
@ -845,11 +680,7 @@ namespace detail |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
template <typename T, precision P> |
|
|
|
template <typename T, precision P> |
|
|
|
GLM_FUNC_QUALIFIER tvec4<bool, P> greaterThan |
|
|
|
GLM_FUNC_QUALIFIER tvec4<bool, P> greaterThan(tquat<T, P> const & x, tquat<T, P> const & y) |
|
|
|
( |
|
|
|
|
|
|
|
tquat<T, P> const & x, |
|
|
|
|
|
|
|
tquat<T, P> const & y |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
tvec4<bool, P> Result(uninitialize); |
|
|
|
tvec4<bool, P> Result(uninitialize); |
|
|
|
for(detail::component_count_t i = 0; i < detail::component_count(x); ++i) |
|
|
|
for(detail::component_count_t i = 0; i < detail::component_count(x); ++i) |
|
|
@ -858,11 +689,7 @@ namespace detail |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
template <typename T, precision P> |
|
|
|
template <typename T, precision P> |
|
|
|
GLM_FUNC_QUALIFIER tvec4<bool, P> greaterThanEqual |
|
|
|
GLM_FUNC_QUALIFIER tvec4<bool, P> greaterThanEqual(tquat<T, P> const & x, tquat<T, P> const & y) |
|
|
|
( |
|
|
|
|
|
|
|
tquat<T, P> const & x, |
|
|
|
|
|
|
|
tquat<T, P> const & y |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
tvec4<bool, P> Result(uninitialize); |
|
|
|
tvec4<bool, P> Result(uninitialize); |
|
|
|
for(detail::component_count_t i = 0; i < detail::component_count(x); ++i) |
|
|
|
for(detail::component_count_t i = 0; i < detail::component_count(x); ++i) |
|
|
@ -871,11 +698,7 @@ namespace detail |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
template <typename T, precision P> |
|
|
|
template <typename T, precision P> |
|
|
|
GLM_FUNC_QUALIFIER tvec4<bool, P> equal |
|
|
|
GLM_FUNC_QUALIFIER tvec4<bool, P> equal(tquat<T, P> const & x, tquat<T, P> const & y) |
|
|
|
( |
|
|
|
|
|
|
|
tquat<T, P> const & x, |
|
|
|
|
|
|
|
tquat<T, P> const & y |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
tvec4<bool, P> Result(uninitialize); |
|
|
|
tvec4<bool, P> Result(uninitialize); |
|
|
|
for(detail::component_count_t i = 0; i < detail::component_count(x); ++i) |
|
|
|
for(detail::component_count_t i = 0; i < detail::component_count(x); ++i) |
|
|
@ -884,11 +707,7 @@ namespace detail |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
template <typename T, precision P> |
|
|
|
template <typename T, precision P> |
|
|
|
GLM_FUNC_QUALIFIER tvec4<bool, P> notEqual |
|
|
|
GLM_FUNC_QUALIFIER tvec4<bool, P> notEqual(tquat<T, P> const & x, tquat<T, P> const & y) |
|
|
|
( |
|
|
|
|
|
|
|
tquat<T, P> const & x, |
|
|
|
|
|
|
|
tquat<T, P> const & y |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
tvec4<bool, P> Result(uninitialize); |
|
|
|
tvec4<bool, P> Result(uninitialize); |
|
|
|
for(detail::component_count_t i = 0; i < detail::component_count(x); ++i) |
|
|
|
for(detail::component_count_t i = 0; i < detail::component_count(x); ++i) |
|
|
|