mirror of
https://github.com/g-truc/glm.git
synced 2024-11-26 10:14:35 +00:00
Removed define GLMvaltype
This commit is contained in:
parent
34fb881b07
commit
8f517b7505
@ -12,9 +12,6 @@
|
||||
#ifndef glm_glm
|
||||
#define glm_glm
|
||||
|
||||
//! TODO: to delete
|
||||
//#define GLMvalType typename genType::value_type
|
||||
|
||||
#include <cmath>
|
||||
#include <climits>
|
||||
#include <cfloat>
|
||||
|
@ -36,31 +36,31 @@ namespace glm
|
||||
//! From GLM_GTX_spline extension.
|
||||
template <typename genType>
|
||||
genType catmullRom(
|
||||
const genType& v1,
|
||||
const genType& v2,
|
||||
const genType& v3,
|
||||
const genType& v4,
|
||||
const GLMvalType& s);
|
||||
genType const & v1,
|
||||
genType const & v2,
|
||||
genType const & v3,
|
||||
genType const & v4,
|
||||
typename genType::value_type const & s);
|
||||
|
||||
//! Return a point from a hermite curve.
|
||||
//! From GLM_GTX_spline extension.
|
||||
template <typename genType>
|
||||
genType hermite(
|
||||
const genType& v1,
|
||||
const genType& t1,
|
||||
const genType& v2,
|
||||
const genType& t2,
|
||||
const GLMvalType& s);
|
||||
genType const & v1,
|
||||
genType const & t1,
|
||||
genType const & v2,
|
||||
genType const & t2,
|
||||
typename genType::value_type const & s);
|
||||
|
||||
//! Return a point from a cubic curve.
|
||||
//! From GLM_GTX_spline extension.
|
||||
template <typename genType>
|
||||
genType cubic(
|
||||
const genType& v1,
|
||||
const genType& v2,
|
||||
const genType& v3,
|
||||
const genType& v4,
|
||||
const GLMvalType& s);
|
||||
genType const & v1,
|
||||
genType const & v2,
|
||||
genType const & v3,
|
||||
genType const & v4,
|
||||
typename genType::value_type const & s);
|
||||
|
||||
///@}
|
||||
|
||||
|
@ -12,53 +12,59 @@ namespace gtx{
|
||||
namespace spline
|
||||
{
|
||||
template <typename genType>
|
||||
inline genType catmullRom(
|
||||
const genType& v1,
|
||||
const genType& v2,
|
||||
const genType& v3,
|
||||
const genType& v4,
|
||||
const GLMvalType& s)
|
||||
inline genType catmullRom
|
||||
(
|
||||
genType const & v1,
|
||||
genType const & v2,
|
||||
genType const & v3,
|
||||
genType const & v4,
|
||||
typename genType::value_type const & s
|
||||
)
|
||||
{
|
||||
GLMvalType s1 = s;
|
||||
GLMvalType s2 = optimum_pow::pow2(s);
|
||||
GLMvalType s3 = optimum_pow::pow3(s);
|
||||
typename genType::value_type s1 = s;
|
||||
typename genType::value_type s2 = optimum_pow::pow2(s);
|
||||
typename genType::value_type s3 = optimum_pow::pow3(s);
|
||||
|
||||
GLMvalType f1 = -s3 + GLMvalType(2) * s2 - s;
|
||||
GLMvalType f2 = GLMvalType(3) * s3 - GLMvalType(5) * s2 + GLMvalType(2);
|
||||
GLMvalType f3 = GLMvalType(-3) * s3 + GLMvalType(4) * s2 + s;
|
||||
GLMvalType f4 = s3 - s2;
|
||||
typename genType::value_type f1 = -s3 + typename genType::value_type(2) * s2 - s;
|
||||
typename genType::value_type f2 = typename genType::value_type(3) * s3 - typename genType::value_type(5) * s2 + typename genType::value_type(2);
|
||||
typename genType::value_type f3 = typename genType::value_type(-3) * s3 + typename genType::value_type(4) * s2 + s;
|
||||
typename genType::value_type f4 = s3 - s2;
|
||||
|
||||
return (f1 * v1 + f2 * v2 + f3 * v3 + f4 * v4) / GLMvalType(2);
|
||||
return (f1 * v1 + f2 * v2 + f3 * v3 + f4 * v4) / typename genType::value_type(2);
|
||||
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
inline genType hermite(
|
||||
const genType& v1,
|
||||
const genType& t1,
|
||||
const genType& v2,
|
||||
const genType& t2,
|
||||
const GLMvalType& s)
|
||||
inline genType hermite
|
||||
(
|
||||
genType const & v1,
|
||||
genType const & t1,
|
||||
genType const & v2,
|
||||
genType const & t2,
|
||||
typename genType::value_type const & s
|
||||
)
|
||||
{
|
||||
GLMvalType s1 = s;
|
||||
GLMvalType s2 = optimum_pow::pow2(s);
|
||||
GLMvalType s3 = optimum_pow::pow3(s);
|
||||
typename genType::value_type s1 = s;
|
||||
typename genType::value_type s2 = optimum_pow::pow2(s);
|
||||
typename genType::value_type s3 = optimum_pow::pow3(s);
|
||||
|
||||
GLMvalType f1 = GLMvalType(2) * s3 - GLMvalType(3) * s2 + GLMvalType(1);
|
||||
GLMvalType f2 = GLMvalType(-2) * s3 + GLMvalType(3) * s2;
|
||||
GLMvalType f3 = s3 - GLMvalType(2) * s2 + s;
|
||||
GLMvalType f4 = s3 - s2;
|
||||
typename genType::value_type f1 = typename genType::value_type(2) * s3 - typename genType::value_type(3) * s2 + typename genType::value_type(1);
|
||||
typename genType::value_type f2 = typename genType::value_type(-2) * s3 + typename genType::value_type(3) * s2;
|
||||
typename genType::value_type f3 = s3 - typename genType::value_type(2) * s2 + s;
|
||||
typename genType::value_type f4 = s3 - s2;
|
||||
|
||||
return f1 * v1 + f2 * v2 + f3 * t1 + f4 * t2;
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
inline genType cubic(
|
||||
const genType& v1,
|
||||
const genType& v2,
|
||||
const genType& v3,
|
||||
const genType& v4,
|
||||
const GLMvalType& s)
|
||||
inline genType cubic
|
||||
(
|
||||
genType const & v1,
|
||||
genType const & v2,
|
||||
genType const & v3,
|
||||
genType const & v4,
|
||||
typename genType::value_type const & s
|
||||
)
|
||||
{
|
||||
return ((v1 * s + v2) * s + v3) * s + v4;
|
||||
}
|
||||
|
@ -39,9 +39,9 @@ namespace glm
|
||||
//! From GLM_GTX_vector_query extensions.
|
||||
template <typename genType>
|
||||
bool areCollinear(
|
||||
const genType & v0,
|
||||
const genType & v1,
|
||||
typename genType::value_type const epsilon = std::numeric_limits<GLMvalType>::epsilon());
|
||||
genType const & v0,
|
||||
genType const & v1,
|
||||
typename genType::value_type const & epsilon = std::numeric_limits<typename genType::value_type>::epsilon());
|
||||
|
||||
//! Check if two vectors are opposites.
|
||||
//! From GLM_GTX_vector_query extensions.
|
||||
@ -49,45 +49,45 @@ namespace glm
|
||||
bool areOpposite(
|
||||
genType const & v0,
|
||||
genType const & v1,
|
||||
typename genType::value_type const epsilon = std::numeric_limits<GLMvalType>::epsilon());
|
||||
typename genType::value_type const & epsilon = std::numeric_limits<typename genType::value_type>::epsilon());
|
||||
|
||||
//! Check if two vectors are orthogonals.
|
||||
//! From GLM_GTX_vector_query extensions.
|
||||
template <typename genType>
|
||||
bool areOrthogonal(
|
||||
const genType & v0,
|
||||
const genType & v1,
|
||||
const GLMvalType epsilon = std::numeric_limits<GLMvalType>::epsilon());
|
||||
genType const & v0,
|
||||
genType const & v1,
|
||||
typename genType::value_type const & epsilon = std::numeric_limits<typename genType::value_type>::epsilon());
|
||||
|
||||
//! Check if a vector is normalized.
|
||||
//! From GLM_GTX_vector_query extensions.
|
||||
template <typename genType>
|
||||
bool isNormalized(
|
||||
const genType & v,
|
||||
const GLMvalType epsilon = std::numeric_limits<GLMvalType>::epsilon());
|
||||
genType const & v,
|
||||
typename genType::value_type const & epsilon = std::numeric_limits<typename genType::value_type>::epsilon());
|
||||
|
||||
//! Check if a vector is null.
|
||||
//! From GLM_GTX_vector_query extensions.
|
||||
template <typename genType>
|
||||
bool isNull(
|
||||
const genType& v,
|
||||
const GLMvalType epsilon = std::numeric_limits<GLMvalType>::epsilon());
|
||||
genType const & v,
|
||||
typename genType::value_type const & epsilon = std::numeric_limits<typename genType::value_type>::epsilon());
|
||||
|
||||
//! Check if two vectors are orthonormal.
|
||||
//! From GLM_GTX_vector_query extensions.
|
||||
template <typename genType>
|
||||
bool areOrthonormal(
|
||||
const genType & v0,
|
||||
const genType & v1,
|
||||
const GLMvalType epsilon = std::numeric_limits<GLMvalType>::epsilon());
|
||||
genType const & v0,
|
||||
genType const & v1,
|
||||
typename genType::value_type const & epsilon = std::numeric_limits<typename genType::value_type>::epsilon());
|
||||
|
||||
//! Check if two vectors are similar.
|
||||
//! From GLM_GTX_vector_query extensions.
|
||||
template <typename genType>
|
||||
bool areSimilar(
|
||||
const genType& v0,
|
||||
const genType& v1,
|
||||
const GLMvalType epsilon = std::numeric_limits<GLMvalType>::epsilon());
|
||||
genType const & v0,
|
||||
genType const & v1,
|
||||
typename genType::value_type const & epsilon = std::numeric_limits<typename genType::value_type>::epsilon());
|
||||
|
||||
///@}
|
||||
|
||||
|
@ -17,77 +17,100 @@ namespace gtx{
|
||||
namespace vector_query
|
||||
{
|
||||
template <typename T>
|
||||
inline bool areCollinear(
|
||||
const detail::tvec2<T>& v0,
|
||||
const detail::tvec2<T>& v1,
|
||||
const T epsilon)
|
||||
inline bool areCollinear
|
||||
(
|
||||
detail::tvec2<T> const & v0,
|
||||
detail::tvec2<T> const & v1,
|
||||
T const & epsilon
|
||||
)
|
||||
{
|
||||
return length(cross(detail::tvec3<T>(v0, T(0)), detail::tvec3<T>(v1, T(0)))) < epsilon;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline bool areCollinear(
|
||||
const detail::tvec3<T>& v0,
|
||||
const detail::tvec3<T>& v1,
|
||||
const T epsilon)
|
||||
inline bool areCollinear
|
||||
(
|
||||
detail::tvec3<T> const & v0,
|
||||
detail::tvec3<T> const & v1,
|
||||
T const & epsilon
|
||||
)
|
||||
{
|
||||
return length(cross(v0, v1)) < epsilon;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline bool areCollinear(
|
||||
const detail::tvec4<T>& v0,
|
||||
const detail::tvec4<T>& v1,
|
||||
const T epsilon)
|
||||
inline bool areCollinear
|
||||
(
|
||||
detail::tvec4<T> const & v0,
|
||||
detail::tvec4<T> const & v1,
|
||||
T const & epsilon
|
||||
)
|
||||
{
|
||||
return length(cross(detail::tvec3<T>(v0), detail::tvec3<T>(v1))) < epsilon;
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
inline bool areOpposite(
|
||||
const genType& v0,
|
||||
const genType& v1,
|
||||
const GLMvalType epsilon)
|
||||
inline bool areOpposite
|
||||
(
|
||||
genType const & v0,
|
||||
genType const & v1,
|
||||
typename genType::value_type const & epsilon
|
||||
)
|
||||
{
|
||||
assert(isNormalized(v0) && isNormalized(v1));
|
||||
return((genType::value_type(1) + dot(v0, v1)) <= epsilon);
|
||||
return((typename genType::value_type(1) + dot(v0, v1)) <= epsilon);
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
inline bool areOrthogonal(
|
||||
const genType& v0,
|
||||
const genType& v1,
|
||||
const GLMvalType epsilon)
|
||||
inline bool areOrthogonal
|
||||
(
|
||||
genType const & v0,
|
||||
genType const & v1,
|
||||
typename genType::value_type const & epsilon
|
||||
)
|
||||
{
|
||||
return abs(dot(v0, v1)) <= max(GLMvalType(1), length(v0)) * max(GLMvalType(1), length(v1)) * epsilon;
|
||||
return abs(dot(v0, v1)) <= max(
|
||||
typename genType::value_type(1),
|
||||
length(v0)) * max(
|
||||
typename genType::value_type(1),
|
||||
length(v1)) * epsilon;
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
inline bool isNormalized(
|
||||
const genType& v,
|
||||
const GLMvalType epsilon)
|
||||
inline bool isNormalized
|
||||
(
|
||||
genType const & v,
|
||||
typename genType::value_type const & epsilon
|
||||
)
|
||||
{
|
||||
return abs(length(v) - GLMvalType(1)) <= GLMvalType(2) * epsilon;
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
inline bool isNull(const genType& v, const GLMvalType epsilon)
|
||||
inline bool isNull
|
||||
(
|
||||
genType const & v,
|
||||
typename genType::value_type const & epsilon
|
||||
)
|
||||
{
|
||||
return length(v) <= epsilon;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline bool isCompNull(
|
||||
const T s,
|
||||
const T epsilon)
|
||||
inline bool isCompNull
|
||||
(
|
||||
T const & s,
|
||||
T const & epsilon
|
||||
)
|
||||
{
|
||||
return abs(s) < epsilon;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline detail::tvec2<bool> isCompNull(
|
||||
const detail::tvec2<T>& v,
|
||||
const T epsilon)
|
||||
inline detail::tvec2<bool> isCompNull
|
||||
(
|
||||
detail::tvec2<T> const & v,
|
||||
T const & epsilon)
|
||||
{
|
||||
return detail::tvec2<bool>(
|
||||
(abs(v.x) < epsilon),
|
||||
@ -95,9 +118,11 @@ namespace vector_query
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline detail::tvec3<bool> isCompNull(
|
||||
const detail::tvec3<T>& v,
|
||||
const T epsilon)
|
||||
inline detail::tvec3<bool> isCompNull
|
||||
(
|
||||
detail::tvec3<T> const & v,
|
||||
T const & epsilon
|
||||
)
|
||||
{
|
||||
return detail::tvec3<bool>(
|
||||
abs(v.x) < epsilon,
|
||||
@ -106,9 +131,11 @@ namespace vector_query
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline detail::tvec4<bool> isCompNull(
|
||||
const detail::tvec4<T>& v,
|
||||
const T epsilon)
|
||||
inline detail::tvec4<bool> isCompNull
|
||||
(
|
||||
detail::tvec4<T> const & v,
|
||||
T const & epsilon
|
||||
)
|
||||
{
|
||||
return detail::tvec4<bool>(
|
||||
abs(v.x) < epsilon,
|
||||
@ -118,19 +145,23 @@ namespace vector_query
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
inline bool areOrthonormal(
|
||||
const genType& v0,
|
||||
const genType& v1,
|
||||
const GLMvalType epsilon)
|
||||
inline bool areOrthonormal
|
||||
(
|
||||
genType const & v0,
|
||||
genType const & v1,
|
||||
typename genType::value_type const & epsilon
|
||||
)
|
||||
{
|
||||
return isNormalized(v0, epsilon) && isNormalized(v1, epsilon) && (abs(dot(v0, v1)) <= epsilon);
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
inline bool areSimilar(
|
||||
const genType& v0,
|
||||
const genType& v1,
|
||||
const GLMvalType epsilon)
|
||||
inline bool areSimilar
|
||||
(
|
||||
genType const & v0,
|
||||
genType const & v1,
|
||||
typename genType::value_type const & epsilon
|
||||
)
|
||||
{
|
||||
bool similar = true;
|
||||
for(typename genType::size_type i = 0; similar && i < genType::value_size(); i++)
|
||||
|
Loading…
Reference in New Issue
Block a user