glm/glm/gtx/epsilon.inl

205 lines
4.9 KiB
Plaintext
Raw Normal View History

2010-04-29 10:54:07 +00:00
///////////////////////////////////////////////////////////////////////////////////////////////////
2011-01-20 11:40:14 +00:00
// OpenGL Mathematics Copyright (c) 2005 - 2011 G-Truc Creation (www.g-truc.net)
2010-04-29 10:54:07 +00:00
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2005-12-21
// Updated : 2006-01-16
// Licence : This source is under MIT License
// File : glm/gtx/epsilon.inl
///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{
namespace gtx{
namespace epsilon{
template <typename genType>
2011-04-09 08:44:32 +00:00
GLM_FUNC_QUALIFIER bool equalEpsilon
2010-04-29 10:54:07 +00:00
(
genType const & x,
genType const & y,
genType const & epsilon
)
{
return abs(x - y) < epsilon;
}
template <typename genType>
2011-04-09 08:44:32 +00:00
GLM_FUNC_QUALIFIER bool notEqualEpsilon
2010-04-29 10:54:07 +00:00
(
genType const & x,
genType const & y,
genType const & epsilon
)
{
return abs(x - y) >= epsilon;
}
template <typename valType>
2011-04-09 08:44:32 +00:00
GLM_FUNC_QUALIFIER detail::tvec2<bool> equalEpsilon
2010-04-29 10:54:07 +00:00
(
detail::tvec2<valType> const & x,
detail::tvec2<valType> const & y,
valType const & epsilon)
{
return detail::tvec2<bool>(
abs(x.x - y.x) < epsilon,
abs(x.y - y.y) < epsilon);
}
template <typename valType>
2011-04-09 08:44:32 +00:00
GLM_FUNC_QUALIFIER detail::tvec3<bool> equalEpsilon
2010-04-29 10:54:07 +00:00
(
detail::tvec3<valType> const & x,
detail::tvec3<valType> const & y,
valType const & epsilon)
{
return detail::tvec3<bool>(
abs(x.x - y.x) < epsilon,
abs(x.y - y.y) < epsilon,
abs(x.z - y.z) < epsilon);
}
template <typename valType>
2011-04-09 08:44:32 +00:00
GLM_FUNC_QUALIFIER detail::tvec4<bool> equalEpsilon
2010-04-29 10:54:07 +00:00
(
detail::tvec4<valType> const & x,
detail::tvec4<valType> const & y,
valType const & epsilon
)
{
return detail::tvec4<bool>(
abs(x.x - y.x) < epsilon,
abs(x.y - y.y) < epsilon,
abs(x.z - y.z) < epsilon,
abs(x.w - y.w) < epsilon);
}
template <typename valType>
2011-04-09 08:44:32 +00:00
GLM_FUNC_QUALIFIER detail::tvec2<bool> notEqualEpsilon
2010-04-29 10:54:07 +00:00
(
detail::tvec2<valType> const & x,
detail::tvec2<valType> const & y,
valType const & epsilon
)
{
return detail::tvec2<bool>(
abs(x.x - y.x) >= epsilon,
abs(x.y - y.y) >= epsilon);
}
template <typename valType>
2011-04-09 08:44:32 +00:00
GLM_FUNC_QUALIFIER detail::tvec3<bool> notEqualEpsilon
2010-04-29 10:54:07 +00:00
(
detail::tvec3<valType> const & x,
detail::tvec3<valType> const & y,
valType const & epsilon
)
{
return detail::tvec3<bool>(
abs(x.x - y.x) >= epsilon,
abs(x.y - y.y) >= epsilon,
abs(x.z - y.z) >= epsilon);
}
template <typename valType>
2011-04-09 08:44:32 +00:00
GLM_FUNC_QUALIFIER detail::tvec4<bool> notEqualEpsilon
2010-04-29 10:54:07 +00:00
(
detail::tvec4<valType> const & x,
detail::tvec4<valType> const & y,
valType const & epsilon
)
{
return detail::tvec4<bool>(
abs(x.x - y.x) >= epsilon,
abs(x.y - y.y) >= epsilon,
abs(x.z - y.z) >= epsilon,
abs(x.w - y.w) >= epsilon);
}
template <typename valType>
2011-04-09 08:44:32 +00:00
GLM_FUNC_QUALIFIER detail::tvec2<bool> equalEpsilon
2010-04-29 10:54:07 +00:00
(
detail::tvec2<valType> const & x,
detail::tvec2<valType> const & y,
detail::tvec2<valType> const & epsilon
)
{
return detail::tvec2<bool>(
abs(x.x - y.x) < epsilon.x,
abs(x.y - y.y) < epsilon.y);
}
template <typename valType>
2011-04-09 08:44:32 +00:00
GLM_FUNC_QUALIFIER detail::tvec3<bool> equalEpsilon
2010-04-29 10:54:07 +00:00
(
detail::tvec3<valType> const & x,
detail::tvec3<valType> const & y,
detail::tvec3<valType> const & epsilon
)
{
return detail::tvec3<bool>(
abs(x.x - y.x) < epsilon.x,
abs(x.y - y.y) < epsilon.y,
abs(x.z - y.z) < epsilon.z);
}
template <typename valType>
2011-04-09 08:44:32 +00:00
GLM_FUNC_QUALIFIER detail::tvec4<bool> equalEpsilon
2010-04-29 10:54:07 +00:00
(
detail::tvec4<valType> const & x,
detail::tvec4<valType> const & y,
detail::tvec4<valType> const & epsilon
)
{
return detail::tvec4<bool>(
abs(x.x - y.x) < epsilon.x,
abs(x.y - y.y) < epsilon.y,
abs(x.z - y.z) < epsilon.z,
abs(x.w - y.w) < epsilon.w);
}
template <typename valType>
2011-04-09 08:44:32 +00:00
GLM_FUNC_QUALIFIER detail::tvec2<bool> notEqualEpsilon
2010-04-29 10:54:07 +00:00
(
detail::tvec2<valType> const & x,
detail::tvec2<valType> const & y,
detail::tvec2<valType> const & epsilon
)
{
return detail::tvec2<bool>(
abs(x.x - y.x) >= epsilon.x,
abs(x.y - y.y) >= epsilon.y);
}
template <typename valType>
2011-04-09 08:44:32 +00:00
GLM_FUNC_QUALIFIER detail::tvec3<bool> notEqualEpsilon
2010-04-29 10:54:07 +00:00
(
detail::tvec3<valType> const & x,
detail::tvec3<valType> const & y,
detail::tvec3<valType> const & epsilon
)
{
return detail::tvec3<bool>(
abs(x.x - y.x) >= epsilon.x,
abs(x.y - y.y) >= epsilon.y,
abs(x.z - y.z) >= epsilon.z);
}
template <typename valType>
2011-04-09 08:44:32 +00:00
GLM_FUNC_QUALIFIER detail::tvec4<bool> notEqualEpsilon
2010-04-29 10:54:07 +00:00
(
detail::tvec4<valType> const & x,
detail::tvec4<valType> const & y,
detail::tvec4<valType> const & epsilon
)
{
return detail::tvec4<bool>(
abs(x.x - y.x) >= epsilon.x,
abs(x.y - y.y) >= epsilon.y,
abs(x.z - y.z) >= epsilon.z,
abs(x.w - y.w) >= epsilon.w);
}
}//namespace epsilon
}//namespace gtx
}//namespace glm