Clean up coding style
This commit is contained in:
@@ -72,6 +72,12 @@ namespace glm
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const;
|
||||
#endif//GLM_FORCE_SIZE_FUNC
|
||||
|
||||
//////////////////////////////////////
|
||||
// Accesses
|
||||
|
||||
GLM_FUNC_DECL T & operator[](length_t i);
|
||||
GLM_FUNC_DECL T const & operator[](length_t i) const;
|
||||
|
||||
//////////////////////////////////////
|
||||
// Implicit basic constructors
|
||||
|
||||
@@ -87,6 +93,7 @@ namespace glm
|
||||
GLM_FUNC_DECL explicit tquat(T const & s, tvec3<T, P> const & v);
|
||||
GLM_FUNC_DECL tquat(T const & w, T const & x, T const & y, T const & z);
|
||||
|
||||
//////////////////////////////////////
|
||||
// Convertions
|
||||
|
||||
/// Create a quaternion from two normalized axis
|
||||
@@ -95,21 +102,13 @@ namespace glm
|
||||
/// @param v A second normalized axis
|
||||
/// @see gtc_quaternion
|
||||
/// @see http://lolengine.net/blog/2013/09/18/beautiful-maths-quaternion-from-vectors
|
||||
GLM_FUNC_DECL explicit tquat(
|
||||
tvec3<T, P> const & u,
|
||||
tvec3<T, P> const & v);
|
||||
GLM_FUNC_DECL explicit tquat(tvec3<T, P> const & u, tvec3<T, P> const & v);
|
||||
/// Build a quaternion from euler angles (pitch, yaw, roll), in radians.
|
||||
GLM_FUNC_DECL explicit tquat(
|
||||
tvec3<T, P> const & eulerAngles);
|
||||
GLM_FUNC_DECL explicit tquat(
|
||||
tmat3x3<T, P> const & m);
|
||||
GLM_FUNC_DECL explicit tquat(
|
||||
tmat4x4<T, P> const & m);
|
||||
|
||||
// Accesses
|
||||
GLM_FUNC_DECL T & operator[](length_t i);
|
||||
GLM_FUNC_DECL T const & operator[](length_t i) const;
|
||||
GLM_FUNC_DECL explicit tquat(tvec3<T, P> const & eulerAngles);
|
||||
GLM_FUNC_DECL explicit tquat(tmat3x3<T, P> const & m);
|
||||
GLM_FUNC_DECL explicit tquat(tmat4x4<T, P> const & m);
|
||||
|
||||
//////////////////////////////////////
|
||||
// Operators
|
||||
GLM_FUNC_DECL tquat<T, P> & operator+=(tquat<T, P> const & q);
|
||||
GLM_FUNC_DECL tquat<T, P> & operator*=(tquat<T, P> const & q);
|
||||
@@ -118,75 +117,52 @@ namespace glm
|
||||
};
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tquat<T, P> operator- (
|
||||
tquat<T, P> const & q);
|
||||
GLM_FUNC_DECL tquat<T, P> operator-(tquat<T, P> const & q);
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tquat<T, P> operator+ (
|
||||
tquat<T, P> const & q,
|
||||
tquat<T, P> const & p);
|
||||
GLM_FUNC_DECL tquat<T, P> operator+(tquat<T, P> const & q, tquat<T, P> const & p);
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tquat<T, P> operator* (
|
||||
tquat<T, P> const & q,
|
||||
tquat<T, P> const & p);
|
||||
GLM_FUNC_DECL tquat<T, P> operator*(tquat<T, P> const & q, tquat<T, P> const & p);
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tvec3<T, P> operator* (
|
||||
tquat<T, P> const & q,
|
||||
tvec3<T, P> const & v);
|
||||
GLM_FUNC_DECL tvec3<T, P> operator*(tquat<T, P> const & q, tvec3<T, P> const & v);
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tvec3<T, P> operator* (
|
||||
tvec3<T, P> const & v,
|
||||
tquat<T, P> const & q);
|
||||
GLM_FUNC_DECL tvec3<T, P> operator*(tvec3<T, P> const & v, tquat<T, P> const & q);
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tvec4<T, P> operator* (
|
||||
tquat<T, P> const & q,
|
||||
tvec4<T, P> const & v);
|
||||
GLM_FUNC_DECL tvec4<T, P> operator*(tquat<T, P> const & q, tvec4<T, P> const & v);
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tvec4<T, P> operator* (
|
||||
tvec4<T, P> const & v,
|
||||
tquat<T, P> const & q);
|
||||
GLM_FUNC_DECL tvec4<T, P> operator*(tvec4<T, P> const & v, tquat<T, P> const & q);
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tquat<T, P> operator* (
|
||||
tquat<T, P> const & q,
|
||||
T const & s);
|
||||
GLM_FUNC_DECL tquat<T, P> operator*(tquat<T, P> const & q, T const & s);
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tquat<T, P> operator* (
|
||||
T const & s,
|
||||
tquat<T, P> const & q);
|
||||
GLM_FUNC_DECL tquat<T, P> operator*(T const & s, tquat<T, P> const & q);
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tquat<T, P> operator/ (
|
||||
tquat<T, P> const & q,
|
||||
T const & s);
|
||||
GLM_FUNC_DECL tquat<T, P> operator/(tquat<T, P> const & q, T const & s);
|
||||
|
||||
/// Returns the length of the quaternion.
|
||||
///
|
||||
/// @see gtc_quaternion
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL T length(
|
||||
tquat<T, P> const & q);
|
||||
GLM_FUNC_DECL T length(tquat<T, P> const & q);
|
||||
|
||||
/// Returns the normalized quaternion.
|
||||
///
|
||||
/// @see gtc_quaternion
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tquat<T, P> normalize(
|
||||
tquat<T, P> const & q);
|
||||
GLM_FUNC_DECL tquat<T, P> normalize(tquat<T, P> const & q);
|
||||
|
||||
/// Returns dot product of q1 and q2, i.e., q1[0] * q2[0] + q1[1] * q2[1] + ...
|
||||
///
|
||||
/// @see gtc_quaternion
|
||||
template <typename T, precision P, template <typename, precision> class quatType>
|
||||
GLM_FUNC_DECL T dot(
|
||||
quatType<T, P> const & x,
|
||||
quatType<T, P> const & y);
|
||||
GLM_FUNC_DECL T dot(quatType<T, P> const & x, quatType<T, P> const & y);
|
||||
|
||||
/// Spherical linear interpolation of two quaternions.
|
||||
/// The interpolation is oriented and the rotation is performed at constant speed.
|
||||
@@ -199,10 +175,7 @@ namespace glm
|
||||
/// @see gtc_quaternion
|
||||
/// @see - slerp(tquat<T, P> const & x, tquat<T, P> const & y, T const & a)
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tquat<T, P> mix(
|
||||
tquat<T, P> const & x,
|
||||
tquat<T, P> const & y,
|
||||
T const & a);
|
||||
GLM_FUNC_DECL tquat<T, P> mix(tquat<T, P> const & x, tquat<T, P> const & y, T const & a);
|
||||
|
||||
/// Linear interpolation of two quaternions.
|
||||
/// The interpolation is oriented.
|
||||
@@ -213,10 +186,7 @@ namespace glm
|
||||
/// @tparam T Value type used to build the quaternion. Supported: half, float or double.
|
||||
/// @see gtc_quaternion
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tquat<T, P> lerp(
|
||||
tquat<T, P> const & x,
|
||||
tquat<T, P> const & y,
|
||||
T const & a);
|
||||
GLM_FUNC_DECL tquat<T, P> lerp(tquat<T, P> const & x, tquat<T, P> const & y, T const & a);
|
||||
|
||||
/// Spherical linear interpolation of two quaternions.
|
||||
/// The interpolation always take the short path and the rotation is performed at constant speed.
|
||||
@@ -227,24 +197,19 @@ namespace glm
|
||||
/// @tparam T Value type used to build the quaternion. Supported: half, float or double.
|
||||
/// @see gtc_quaternion
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tquat<T, P> slerp(
|
||||
tquat<T, P> const & x,
|
||||
tquat<T, P> const & y,
|
||||
T const & a);
|
||||
GLM_FUNC_DECL tquat<T, P> slerp(tquat<T, P> const & x, tquat<T, P> const & y, T const & a);
|
||||
|
||||
/// Returns the q conjugate.
|
||||
///
|
||||
/// @see gtc_quaternion
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tquat<T, P> conjugate(
|
||||
tquat<T, P> const & q);
|
||||
GLM_FUNC_DECL tquat<T, P> conjugate(tquat<T, P> const & q);
|
||||
|
||||
/// Returns the q inverse.
|
||||
///
|
||||
/// @see gtc_quaternion
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tquat<T, P> inverse(
|
||||
tquat<T, P> const & q);
|
||||
GLM_FUNC_DECL tquat<T, P> inverse(tquat<T, P> const & q);
|
||||
|
||||
/// Rotates a quaternion from a vector of 3 components axis and an angle.
|
||||
///
|
||||
@@ -254,18 +219,14 @@ namespace glm
|
||||
///
|
||||
/// @see gtc_quaternion
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tquat<T, P> rotate(
|
||||
tquat<T, P> const & q,
|
||||
T const & angle,
|
||||
tvec3<T, P> const & axis);
|
||||
GLM_FUNC_DECL tquat<T, P> rotate(tquat<T, P> const & q, T const & angle, tvec3<T, P> const & axis);
|
||||
|
||||
/// Returns euler angles, yitch as x, yaw as y, roll as z.
|
||||
/// The result is expressed in radians if GLM_FORCE_RADIANS is defined or degrees otherwise.
|
||||
///
|
||||
/// @see gtc_quaternion
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tvec3<T, P> eulerAngles(
|
||||
tquat<T, P> const & x);
|
||||
GLM_FUNC_DECL tvec3<T, P> eulerAngles(tquat<T, P> const & x);
|
||||
|
||||
/// Returns roll value of euler angles expressed in radians.
|
||||
///
|
||||
@@ -289,29 +250,25 @@ namespace glm
|
||||
///
|
||||
/// @see gtc_quaternion
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tmat3x3<T, P> mat3_cast(
|
||||
tquat<T, P> const & x);
|
||||
GLM_FUNC_DECL tmat3x3<T, P> mat3_cast(tquat<T, P> const & x);
|
||||
|
||||
/// Converts a quaternion to a 4 * 4 matrix.
|
||||
///
|
||||
/// @see gtc_quaternion
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tmat4x4<T, P> mat4_cast(
|
||||
tquat<T, P> const & x);
|
||||
GLM_FUNC_DECL tmat4x4<T, P> mat4_cast(tquat<T, P> const & x);
|
||||
|
||||
/// Converts a 3 * 3 matrix to a quaternion.
|
||||
///
|
||||
/// @see gtc_quaternion
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tquat<T, P> quat_cast(
|
||||
tmat3x3<T, P> const & x);
|
||||
GLM_FUNC_DECL tquat<T, P> quat_cast(tmat3x3<T, P> const & x);
|
||||
|
||||
/// Converts a 4 * 4 matrix to a quaternion.
|
||||
///
|
||||
/// @see gtc_quaternion
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tquat<T, P> quat_cast(
|
||||
tmat4x4<T, P> const & x);
|
||||
GLM_FUNC_DECL tquat<T, P> quat_cast(tmat4x4<T, P> const & x);
|
||||
|
||||
/// Returns the quaternion rotation angle.
|
||||
///
|
||||
@@ -323,8 +280,7 @@ namespace glm
|
||||
///
|
||||
/// @see gtc_quaternion
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tvec3<T, P> axis(
|
||||
tquat<T, P> const & x);
|
||||
GLM_FUNC_DECL tvec3<T, P> axis(tquat<T, P> const & x);
|
||||
|
||||
/// Build a quaternion from an angle and a normalized axis.
|
||||
///
|
||||
@@ -333,9 +289,7 @@ namespace glm
|
||||
///
|
||||
/// @see gtc_quaternion
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tquat<T, P> angleAxis(
|
||||
T const & angle,
|
||||
tvec3<T, P> const & axis);
|
||||
GLM_FUNC_DECL tquat<T, P> angleAxis(T const & angle, tvec3<T, P> const & axis);
|
||||
|
||||
/// Returns the component-wise comparison result of x < y.
|
||||
///
|
||||
@@ -343,9 +297,7 @@ namespace glm
|
||||
///
|
||||
/// @see gtc_quaternion
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tvec4<bool, P> lessThan(
|
||||
tquat<T, P> const & x,
|
||||
tquat<T, P> const & y);
|
||||
GLM_FUNC_DECL tvec4<bool, P> lessThan(tquat<T, P> const & x, tquat<T, P> const & y);
|
||||
|
||||
/// Returns the component-wise comparison of result x <= y.
|
||||
///
|
||||
@@ -353,9 +305,7 @@ namespace glm
|
||||
///
|
||||
/// @see gtc_quaternion
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tvec4<bool, P> lessThanEqual(
|
||||
tquat<T, P> const & x,
|
||||
tquat<T, P> const & y);
|
||||
GLM_FUNC_DECL tvec4<bool, P> lessThanEqual(tquat<T, P> const & x, tquat<T, P> const & y);
|
||||
|
||||
/// Returns the component-wise comparison of result x > y.
|
||||
///
|
||||
@@ -363,9 +313,7 @@ namespace glm
|
||||
///
|
||||
/// @see gtc_quaternion
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tvec4<bool, P> greaterThan(
|
||||
tquat<T, P> const & x,
|
||||
tquat<T, P> const & y);
|
||||
GLM_FUNC_DECL tvec4<bool, P> greaterThan(tquat<T, P> const & x, tquat<T, P> const & y);
|
||||
|
||||
/// Returns the component-wise comparison of result x >= y.
|
||||
///
|
||||
@@ -373,9 +321,7 @@ namespace glm
|
||||
///
|
||||
/// @see gtc_quaternion
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tvec4<bool, P> greaterThanEqual(
|
||||
tquat<T, P> const & x,
|
||||
tquat<T, P> const & y);
|
||||
GLM_FUNC_DECL tvec4<bool, P> greaterThanEqual(tquat<T, P> const & x, tquat<T, P> const & y);
|
||||
|
||||
/// Returns the component-wise comparison of result x == y.
|
||||
///
|
||||
@@ -383,9 +329,7 @@ namespace glm
|
||||
///
|
||||
/// @see gtc_quaternion
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tvec4<bool, P> equal(
|
||||
tquat<T, P> const & x,
|
||||
tquat<T, P> const & y);
|
||||
GLM_FUNC_DECL tvec4<bool, P> equal(tquat<T, P> const & x, tquat<T, P> const & y);
|
||||
|
||||
/// Returns the component-wise comparison of result x != y.
|
||||
///
|
||||
@@ -393,10 +337,7 @@ namespace glm
|
||||
///
|
||||
/// @see gtc_quaternion
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL tvec4<bool, P> notEqual(
|
||||
tquat<T, P> const & x,
|
||||
tquat<T, P> const & y);
|
||||
|
||||
GLM_FUNC_DECL tvec4<bool, P> notEqual(tquat<T, P> const & x, tquat<T, P> const & y);
|
||||
/// @}
|
||||
} //namespace glm
|
||||
|
||||
|
||||
@@ -59,6 +59,26 @@ namespace detail
|
||||
}
|
||||
#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>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P>::tquat()
|
||||
# ifndef GLM_FORCE_NO_CTOR_INIT
|
||||
@@ -67,48 +87,35 @@ namespace detail
|
||||
{}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P>::tquat(tquat<T, P> const & q) :
|
||||
x(q.x), y(q.y), z(q.z), w(q.w)
|
||||
GLM_FUNC_QUALIFIER tquat<T, P>::tquat(tquat<T, P> const & q)
|
||||
: x(q.x), y(q.y), z(q.z), w(q.w)
|
||||
{}
|
||||
|
||||
template <typename T, precision P>
|
||||
template <precision 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)
|
||||
GLM_FUNC_QUALIFIER tquat<T, P>::tquat(tquat<T, Q> const & q)
|
||||
: x(q.x), y(q.y), z(q.z), w(q.w)
|
||||
{}
|
||||
|
||||
//////////////////////////////////////
|
||||
// Explicit basic constructors
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P>::tquat(ctor)
|
||||
{}
|
||||
|
||||
template <typename T, precision P>
|
||||
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)
|
||||
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)
|
||||
{}
|
||||
|
||||
template <typename T, precision P>
|
||||
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)
|
||||
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)
|
||||
{}
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
// tquat conversions
|
||||
// Conversions
|
||||
|
||||
//template <typename valType>
|
||||
//GLM_FUNC_QUALIFIER tquat<valType>::tquat
|
||||
@@ -129,11 +136,7 @@ namespace detail
|
||||
//}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P>::tquat
|
||||
(
|
||||
tvec3<T, P> const & u,
|
||||
tvec3<T, P> const & v
|
||||
)
|
||||
GLM_FUNC_QUALIFIER tquat<T, P>::tquat(tvec3<T, P> const & u, tvec3<T, P> const & v)
|
||||
{
|
||||
tvec3<T, P> const LocalW(cross(u, v));
|
||||
T Dot = detail::compute_dot<tvec3, T, P>::call(u, v);
|
||||
@@ -143,10 +146,7 @@ namespace detail
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P>::tquat
|
||||
(
|
||||
tvec3<T, P> const & eulerAngle
|
||||
)
|
||||
GLM_FUNC_QUALIFIER tquat<T, P>::tquat(tvec3<T, P> const & eulerAngle)
|
||||
{
|
||||
tvec3<T, P> c = glm::cos(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>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P>::tquat
|
||||
(
|
||||
tmat3x3<T, P> const & m
|
||||
)
|
||||
GLM_FUNC_QUALIFIER tquat<T, P>::tquat(tmat3x3<T, P> const & m)
|
||||
{
|
||||
*this = quat_cast(m);
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P>::tquat
|
||||
(
|
||||
tmat4x4<T, P> const & m
|
||||
)
|
||||
GLM_FUNC_QUALIFIER tquat<T, P>::tquat(tmat4x4<T, P> const & m)
|
||||
{
|
||||
*this = quat_cast(m);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
// tquat<T, P> 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];
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> conjugate
|
||||
(
|
||||
tquat<T, P> const & q
|
||||
)
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> conjugate(tquat<T, P> const & q)
|
||||
{
|
||||
return tquat<T, P>(q.w, -q.x, -q.y, -q.z);
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> inverse
|
||||
(
|
||||
tquat<T, P> const & q
|
||||
)
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> inverse(tquat<T, P> const & q)
|
||||
{
|
||||
return conjugate(q) / dot(q, q);
|
||||
}
|
||||
@@ -214,10 +185,7 @@ namespace detail
|
||||
// tquat<valType> operators
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> & tquat<T, P>::operator +=
|
||||
(
|
||||
tquat<T, P> const & q
|
||||
)
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> & tquat<T, P>::operator+=(tquat<T, P> const & q)
|
||||
{
|
||||
this->w += q.w;
|
||||
this->x += q.x;
|
||||
@@ -227,10 +195,7 @@ namespace detail
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> & tquat<T, P>::operator *=
|
||||
(
|
||||
tquat<T, P> const & q
|
||||
)
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> & tquat<T, P>::operator*=(tquat<T, P> const & q)
|
||||
{
|
||||
tquat<T, P> const p(*this);
|
||||
|
||||
@@ -242,10 +207,7 @@ namespace detail
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> & tquat<T, P>::operator *=
|
||||
(
|
||||
T const & s
|
||||
)
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> & tquat<T, P>::operator*=(T const & s)
|
||||
{
|
||||
this->w *= s;
|
||||
this->x *= s;
|
||||
@@ -255,10 +217,7 @@ namespace detail
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> & tquat<T, P>::operator /=
|
||||
(
|
||||
T const & s
|
||||
)
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> & tquat<T, P>::operator/=(T const & s)
|
||||
{
|
||||
this->w /= s;
|
||||
this->x /= s;
|
||||
@@ -271,41 +230,26 @@ namespace detail
|
||||
// tquat<T, P> external operators
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> operator-
|
||||
(
|
||||
tquat<T, P> const & q
|
||||
)
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> operator-(tquat<T, P> const & q)
|
||||
{
|
||||
return tquat<T, P>(-q.w, -q.x, -q.y, -q.z);
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> operator+
|
||||
(
|
||||
tquat<T, P> const & q,
|
||||
tquat<T, P> const & p
|
||||
)
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> operator+(tquat<T, P> const & q, tquat<T, P> const & p)
|
||||
{
|
||||
return tquat<T, P>(q) += p;
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> operator*
|
||||
(
|
||||
tquat<T, P> const & q,
|
||||
tquat<T, P> const & p
|
||||
)
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> operator*(tquat<T, P> const & q, tquat<T, P> const & p)
|
||||
{
|
||||
return tquat<T, P>(q) *= p;
|
||||
}
|
||||
|
||||
// Transformation
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tvec3<T, P> operator*
|
||||
(
|
||||
tquat<T, P> const & q,
|
||||
tvec3<T, P> const & v
|
||||
)
|
||||
GLM_FUNC_QUALIFIER tvec3<T, P> operator*(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 uv(glm::cross(QuatVector, v));
|
||||
@@ -315,62 +259,38 @@ namespace detail
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tvec3<T, P> operator*
|
||||
(
|
||||
tvec3<T, P> const & v,
|
||||
tquat<T, P> const & q
|
||||
)
|
||||
GLM_FUNC_QUALIFIER tvec3<T, P> operator*(tvec3<T, P> const & v, tquat<T, P> const & q)
|
||||
{
|
||||
return glm::inverse(q) * v;
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tvec4<T, P> operator*
|
||||
(
|
||||
tquat<T, P> const & q,
|
||||
tvec4<T, P> const & v
|
||||
)
|
||||
GLM_FUNC_QUALIFIER tvec4<T, P> operator*(tquat<T, P> const & q, tvec4<T, P> const & v)
|
||||
{
|
||||
return tvec4<T, P>(q * tvec3<T, P>(v), v.w);
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tvec4<T, P> operator*
|
||||
(
|
||||
tvec4<T, P> const & v,
|
||||
tquat<T, P> const & q
|
||||
)
|
||||
GLM_FUNC_QUALIFIER tvec4<T, P> operator*(tvec4<T, P> const & v, tquat<T, P> const & q)
|
||||
{
|
||||
return glm::inverse(q) * v;
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> operator*
|
||||
(
|
||||
tquat<T, P> const & q,
|
||||
T const & s
|
||||
)
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> operator*(tquat<T, P> const & q, T const & s)
|
||||
{
|
||||
return tquat<T, P>(
|
||||
q.w * s, q.x * s, q.y * s, q.z * s);
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> operator*
|
||||
(
|
||||
T const & s,
|
||||
tquat<T, P> const & q
|
||||
)
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> operator*(T const & s, tquat<T, P> const & q)
|
||||
{
|
||||
return q * s;
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> operator/
|
||||
(
|
||||
tquat<T, P> const & q,
|
||||
T const & s
|
||||
)
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> operator/(tquat<T, P> const & q, T const & s)
|
||||
{
|
||||
return tquat<T, P>(
|
||||
q.w / s, q.x / s, q.y / s, q.z / s);
|
||||
@@ -380,40 +300,26 @@ namespace detail
|
||||
// Boolean operators
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER bool operator==
|
||||
(
|
||||
tquat<T, P> const & q1,
|
||||
tquat<T, P> const & q2
|
||||
)
|
||||
GLM_FUNC_QUALIFIER bool operator==(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);
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER bool operator!=
|
||||
(
|
||||
tquat<T, P> const & q1,
|
||||
tquat<T, P> const & q2
|
||||
)
|
||||
GLM_FUNC_QUALIFIER bool operator!=(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);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T length
|
||||
(
|
||||
tquat<T, P> const & q
|
||||
)
|
||||
GLM_FUNC_QUALIFIER T length(tquat<T, P> const & q)
|
||||
{
|
||||
return glm::sqrt(dot(q, q));
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> normalize
|
||||
(
|
||||
tquat<T, P> const & q
|
||||
)
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> normalize(tquat<T, P> const & q)
|
||||
{
|
||||
T len = length(q);
|
||||
if(len <= T(0)) // Problem
|
||||
@@ -423,11 +329,7 @@ namespace detail
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> cross
|
||||
(
|
||||
tquat<T, P> const & q1,
|
||||
tquat<T, P> const & q2
|
||||
)
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> cross(tquat<T, P> const & q1, tquat<T, P> const & q2)
|
||||
{
|
||||
return tquat<T, P>(
|
||||
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))
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> mix
|
||||
(
|
||||
tquat<T, P> const & x,
|
||||
tquat<T, P> const & y,
|
||||
T const & a
|
||||
)
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> mix(tquat<T, P> const & x, tquat<T, P> const & y, T const & a)
|
||||
{
|
||||
if(a <= T(0)) return x;
|
||||
if(a >= T(1)) return y;
|
||||
@@ -518,12 +415,7 @@ namespace detail
|
||||
*/
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> mix
|
||||
(
|
||||
tquat<T, P> const & x,
|
||||
tquat<T, P> const & y,
|
||||
T const & a
|
||||
)
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> mix(tquat<T, P> const & x, tquat<T, P> const & y, T const & a)
|
||||
{
|
||||
T cosTheta = dot(x, y);
|
||||
|
||||
@@ -546,12 +438,7 @@ namespace detail
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> lerp
|
||||
(
|
||||
tquat<T, P> const & x,
|
||||
tquat<T, P> const & y,
|
||||
T const & a
|
||||
)
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> lerp(tquat<T, P> const & x, tquat<T, P> const & y, T const & a)
|
||||
{
|
||||
// Lerp is only defined in [0, 1]
|
||||
assert(a >= static_cast<T>(0));
|
||||
@@ -561,12 +448,7 @@ namespace detail
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> slerp
|
||||
(
|
||||
tquat<T, P> const & x,
|
||||
tquat<T, P> const & y,
|
||||
T const & a
|
||||
)
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> slerp(tquat<T, P> const & x, tquat<T, P> const & y, T const & a)
|
||||
{
|
||||
tquat<T, P> z = y;
|
||||
|
||||
@@ -599,12 +481,7 @@ namespace detail
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> rotate
|
||||
(
|
||||
tquat<T, P> const & q,
|
||||
T const & angle,
|
||||
tvec3<T, P> const & v
|
||||
)
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> rotate(tquat<T, P> const & q, T const & angle, tvec3<T, P> const & v)
|
||||
{
|
||||
tvec3<T, P> Tmp = v;
|
||||
|
||||
@@ -626,46 +503,31 @@ namespace detail
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tvec3<T, P> eulerAngles
|
||||
(
|
||||
tquat<T, P> const & x
|
||||
)
|
||||
GLM_FUNC_QUALIFIER tvec3<T, P> eulerAngles(tquat<T, P> const & x)
|
||||
{
|
||||
return tvec3<T, P>(pitch(x), yaw(x), roll(x));
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T roll
|
||||
(
|
||||
tquat<T, P> const & q
|
||||
)
|
||||
GLM_FUNC_QUALIFIER T roll(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));
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T pitch
|
||||
(
|
||||
tquat<T, P> const & q
|
||||
)
|
||||
GLM_FUNC_QUALIFIER T pitch(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));
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T yaw
|
||||
(
|
||||
tquat<T, P> const & q
|
||||
)
|
||||
GLM_FUNC_QUALIFIER T yaw(tquat<T, P> const & q)
|
||||
{
|
||||
return asin(T(-2) * (q.x * q.z - q.w * q.y));
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tmat3x3<T, P> mat3_cast
|
||||
(
|
||||
tquat<T, P> const & q
|
||||
)
|
||||
GLM_FUNC_QUALIFIER tmat3x3<T, P> mat3_cast(tquat<T, P> const & q)
|
||||
{
|
||||
tmat3x3<T, P> Result(T(1));
|
||||
T qxx(q.x * q.x);
|
||||
@@ -693,19 +555,13 @@ namespace detail
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tmat4x4<T, P> mat4_cast
|
||||
(
|
||||
tquat<T, P> const & q
|
||||
)
|
||||
GLM_FUNC_QUALIFIER tmat4x4<T, P> mat4_cast(tquat<T, P> const & q)
|
||||
{
|
||||
return tmat4x4<T, P>(mat3_cast(q));
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> quat_cast
|
||||
(
|
||||
tmat3x3<T, P> const & m
|
||||
)
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> quat_cast(tmat3x3<T, P> const & m)
|
||||
{
|
||||
T fourXSquaredMinus1 = m[0][0] - m[1][1] - 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>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> quat_cast
|
||||
(
|
||||
tmat4x4<T, P> const & m4
|
||||
)
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> quat_cast(tmat4x4<T, P> const & m4)
|
||||
{
|
||||
return quat_cast(tmat3x3<T, P>(m4));
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T angle
|
||||
(
|
||||
tquat<T, P> const & x
|
||||
)
|
||||
GLM_FUNC_QUALIFIER T angle(tquat<T, P> const & x)
|
||||
{
|
||||
return acos(x.w) * T(2);
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tvec3<T, P> axis
|
||||
(
|
||||
tquat<T, P> const & x
|
||||
)
|
||||
GLM_FUNC_QUALIFIER tvec3<T, P> axis(tquat<T, P> const & x)
|
||||
{
|
||||
T tmp1 = static_cast<T>(1) - x.w * x.w;
|
||||
if(tmp1 <= static_cast<T>(0))
|
||||
@@ -800,11 +647,7 @@ namespace detail
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> angleAxis
|
||||
(
|
||||
T const & angle,
|
||||
tvec3<T, P> const & v
|
||||
)
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> angleAxis(T const & angle, tvec3<T, P> const & v)
|
||||
{
|
||||
tquat<T, P> Result(uninitialize);
|
||||
|
||||
@@ -819,11 +662,7 @@ namespace detail
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tvec4<bool, P> lessThan
|
||||
(
|
||||
tquat<T, P> const & x,
|
||||
tquat<T, P> const & y
|
||||
)
|
||||
GLM_FUNC_QUALIFIER tvec4<bool, P> lessThan(tquat<T, P> const & x, tquat<T, P> const & y)
|
||||
{
|
||||
tvec4<bool, P> Result(uninitialize);
|
||||
for(detail::component_count_t i = 0; i < detail::component_count(x); ++i)
|
||||
@@ -832,11 +671,7 @@ namespace detail
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tvec4<bool, P> lessThanEqual
|
||||
(
|
||||
tquat<T, P> const & x,
|
||||
tquat<T, P> const & y
|
||||
)
|
||||
GLM_FUNC_QUALIFIER tvec4<bool, P> lessThanEqual(tquat<T, P> const & x, tquat<T, P> const & y)
|
||||
{
|
||||
tvec4<bool, P> Result(uninitialize);
|
||||
for(detail::component_count_t i = 0; i < detail::component_count(x); ++i)
|
||||
@@ -845,11 +680,7 @@ namespace detail
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tvec4<bool, P> greaterThan
|
||||
(
|
||||
tquat<T, P> const & x,
|
||||
tquat<T, P> const & y
|
||||
)
|
||||
GLM_FUNC_QUALIFIER tvec4<bool, P> greaterThan(tquat<T, P> const & x, tquat<T, P> const & y)
|
||||
{
|
||||
tvec4<bool, P> Result(uninitialize);
|
||||
for(detail::component_count_t i = 0; i < detail::component_count(x); ++i)
|
||||
@@ -858,11 +689,7 @@ namespace detail
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tvec4<bool, P> greaterThanEqual
|
||||
(
|
||||
tquat<T, P> const & x,
|
||||
tquat<T, P> const & y
|
||||
)
|
||||
GLM_FUNC_QUALIFIER tvec4<bool, P> greaterThanEqual(tquat<T, P> const & x, tquat<T, P> const & y)
|
||||
{
|
||||
tvec4<bool, P> Result(uninitialize);
|
||||
for(detail::component_count_t i = 0; i < detail::component_count(x); ++i)
|
||||
@@ -871,11 +698,7 @@ namespace detail
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tvec4<bool, P> equal
|
||||
(
|
||||
tquat<T, P> const & x,
|
||||
tquat<T, P> const & y
|
||||
)
|
||||
GLM_FUNC_QUALIFIER tvec4<bool, P> equal(tquat<T, P> const & x, tquat<T, P> const & y)
|
||||
{
|
||||
tvec4<bool, P> Result(uninitialize);
|
||||
for(detail::component_count_t i = 0; i < detail::component_count(x); ++i)
|
||||
@@ -884,11 +707,7 @@ namespace detail
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tvec4<bool, P> notEqual
|
||||
(
|
||||
tquat<T, P> const & x,
|
||||
tquat<T, P> const & y
|
||||
)
|
||||
GLM_FUNC_QUALIFIER tvec4<bool, P> notEqual(tquat<T, P> const & x, tquat<T, P> const & y)
|
||||
{
|
||||
tvec4<bool, P> Result(uninitialize);
|
||||
for(detail::component_count_t i = 0; i < detail::component_count(x); ++i)
|
||||
|
||||
Reference in New Issue
Block a user