mirror of
https://github.com/g-truc/glm.git
synced 2024-11-30 03:44:38 +00:00
Added matrix inverse tests and clean up space characters
This commit is contained in:
parent
c9a0b87c7b
commit
4fff9b4367
@ -499,10 +499,6 @@ namespace detail
|
|||||||
m[1] * s);
|
m[1] * s);
|
||||||
}
|
}
|
||||||
|
|
||||||
// X
|
|
||||||
// X
|
|
||||||
// X X
|
|
||||||
// X X
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
GLM_FUNC_QUALIFIER tmat2x2<T> operator*
|
GLM_FUNC_QUALIFIER tmat2x2<T> operator*
|
||||||
(
|
(
|
||||||
@ -527,9 +523,6 @@ namespace detail
|
|||||||
m[0][1] * v.x + m[1][1] * v.y);
|
m[0][1] * v.x + m[1][1] * v.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
// X X
|
|
||||||
// X X
|
|
||||||
// X X
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
GLM_FUNC_QUALIFIER typename tmat2x2<T>::row_type operator*
|
GLM_FUNC_QUALIFIER typename tmat2x2<T>::row_type operator*
|
||||||
(
|
(
|
||||||
|
@ -641,6 +641,5 @@ namespace detail
|
|||||||
{
|
{
|
||||||
return (m1[0] != m2[0]) || (m1[1] != m2[1]);
|
return (m1[0] != m2[0]) || (m1[1] != m2[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
} //namespace detail
|
} //namespace detail
|
||||||
} //namespace glm
|
} //namespace glm
|
||||||
|
@ -660,6 +660,5 @@ namespace detail
|
|||||||
{
|
{
|
||||||
return (m1[0] != m2[0]) || (m1[1] != m2[1]);
|
return (m1[0] != m2[0]) || (m1[1] != m2[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
} //namespace detail
|
} //namespace detail
|
||||||
} //namespace glm
|
} //namespace glm
|
||||||
|
@ -48,8 +48,8 @@ namespace detail
|
|||||||
template <typename T> struct tmat4x3;
|
template <typename T> struct tmat4x3;
|
||||||
template <typename T> struct tmat4x4;
|
template <typename T> struct tmat4x4;
|
||||||
|
|
||||||
// \brief Template for 3 columns and 2 rows matrix of floating-point numbers.
|
/// @brief Template for 3 columns and 2 rows matrix of floating-point numbers.
|
||||||
// \ingroup core_template
|
/// @ingroup core_template
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct tmat3x2
|
struct tmat3x2
|
||||||
{
|
{
|
||||||
@ -231,7 +231,6 @@ namespace detail
|
|||||||
tmat3x2<T> const operator++ (
|
tmat3x2<T> const operator++ (
|
||||||
tmat3x2<T> const & m,
|
tmat3x2<T> const & m,
|
||||||
int);
|
int);
|
||||||
|
|
||||||
} //namespace detail
|
} //namespace detail
|
||||||
|
|
||||||
/// @addtogroup core_precision
|
/// @addtogroup core_precision
|
||||||
|
@ -48,8 +48,8 @@ namespace detail
|
|||||||
template <typename T> struct tmat4x3;
|
template <typename T> struct tmat4x3;
|
||||||
template <typename T> struct tmat4x4;
|
template <typename T> struct tmat4x4;
|
||||||
|
|
||||||
// @brief Template for 3 * 3 matrix of floating-point numbers.
|
/// @brief Template for 3 * 3 matrix of floating-point numbers.
|
||||||
// @ingroup core_template
|
/// @ingroup core_template
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct tmat3x3
|
struct tmat3x3
|
||||||
{
|
{
|
||||||
@ -263,7 +263,6 @@ namespace detail
|
|||||||
tmat3x3<T> const operator++ (
|
tmat3x3<T> const operator++ (
|
||||||
tmat3x3<T> const & m,
|
tmat3x3<T> const & m,
|
||||||
int);
|
int);
|
||||||
|
|
||||||
} //namespace detail
|
} //namespace detail
|
||||||
|
|
||||||
/// @addtogroup core_precision
|
/// @addtogroup core_precision
|
||||||
|
@ -515,11 +515,6 @@ namespace detail
|
|||||||
m[0][3] * v.x + m[1][3] * v.y + m[2][3] * v.z);
|
m[0][3] * v.x + m[1][3] * v.y + m[2][3] * v.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
// X X X
|
|
||||||
// X X X
|
|
||||||
// X X X
|
|
||||||
// X X X
|
|
||||||
// X X X X
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
GLM_FUNC_QUALIFIER typename tmat3x4<T>::row_type operator*
|
GLM_FUNC_QUALIFIER typename tmat3x4<T>::row_type operator*
|
||||||
(
|
(
|
||||||
@ -713,6 +708,5 @@ namespace detail
|
|||||||
{
|
{
|
||||||
return (m1[0] != m2[0]) || (m1[1] != m2[1]) || (m1[2] != m2[2]);
|
return (m1[0] != m2[0]) || (m1[1] != m2[1]) || (m1[2] != m2[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
} //namespace detail
|
} //namespace detail
|
||||||
} //namespace glm
|
} //namespace glm
|
||||||
|
@ -236,7 +236,6 @@ namespace detail
|
|||||||
tmat4x2<T> const operator++ (
|
tmat4x2<T> const operator++ (
|
||||||
tmat4x2<T> const & m,
|
tmat4x2<T> const & m,
|
||||||
int);
|
int);
|
||||||
|
|
||||||
} //namespace detail
|
} //namespace detail
|
||||||
|
|
||||||
/// @addtogroup core_precision
|
/// @addtogroup core_precision
|
||||||
|
@ -724,6 +724,5 @@ namespace detail
|
|||||||
{
|
{
|
||||||
return (m1[0] != m2[0]) || (m1[1] != m2[1]) || (m1[2] != m2[2]) || (m1[3] != m2[3]);
|
return (m1[0] != m2[0]) || (m1[1] != m2[1]) || (m1[2] != m2[2]) || (m1[3] != m2[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
} //namespace detail
|
} //namespace detail
|
||||||
} //namespace glm
|
} //namespace glm
|
||||||
|
@ -48,8 +48,8 @@ namespace detail
|
|||||||
template <typename T> struct tmat4x3;
|
template <typename T> struct tmat4x3;
|
||||||
template <typename T> struct tmat4x4;
|
template <typename T> struct tmat4x4;
|
||||||
|
|
||||||
// \brief Template for 4 columns and 3 rows matrix of floating-point numbers.
|
/// @brief Template for 4 columns and 3 rows matrix of floating-point numbers.
|
||||||
// \ingroup core_template
|
/// @ingroup core_template
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct tmat4x3
|
struct tmat4x3
|
||||||
{
|
{
|
||||||
@ -234,7 +234,6 @@ namespace detail
|
|||||||
tmat4x3<T> const operator++ (
|
tmat4x3<T> const operator++ (
|
||||||
tmat4x3<T> const & m,
|
tmat4x3<T> const & m,
|
||||||
int);
|
int);
|
||||||
|
|
||||||
}//namespace detail
|
}//namespace detail
|
||||||
|
|
||||||
/// @addtogroup core_precision
|
/// @addtogroup core_precision
|
||||||
|
@ -732,7 +732,6 @@ namespace detail
|
|||||||
{
|
{
|
||||||
return (m1[0] != m2[0]) || (m1[1] != m2[1]) || (m1[2] != m2[2]) || (m1[3] != m2[3]);
|
return (m1[0] != m2[0]) || (m1[1] != m2[1]) || (m1[2] != m2[2]) || (m1[3] != m2[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
} //namespace detail
|
} //namespace detail
|
||||||
} //namespace glm
|
} //namespace glm
|
||||||
|
|
||||||
|
@ -44,8 +44,8 @@ namespace detail
|
|||||||
template <typename T> struct tvec3;
|
template <typename T> struct tvec3;
|
||||||
template <typename T> struct tvec4;
|
template <typename T> struct tvec4;
|
||||||
|
|
||||||
// The basic 2D vector type.
|
/// The basic 2D vector type.
|
||||||
// \ingroup core_template
|
/// @ingroup core_template
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct tvec2
|
struct tvec2
|
||||||
{
|
{
|
||||||
|
@ -1024,6 +1024,5 @@ namespace detail
|
|||||||
{
|
{
|
||||||
return tvec2<T>(this->x, this->y);
|
return tvec2<T>(this->x, this->y);
|
||||||
}
|
}
|
||||||
|
|
||||||
}//namespace detail
|
}//namespace detail
|
||||||
}//namespace glm
|
}//namespace glm
|
||||||
|
@ -44,8 +44,8 @@ namespace detail
|
|||||||
template <typename T> struct tvec2;
|
template <typename T> struct tvec2;
|
||||||
template <typename T> struct tvec4;
|
template <typename T> struct tvec4;
|
||||||
|
|
||||||
// Basic 3D vector type.
|
/// Basic 3D vector type.
|
||||||
// \ingroup core_template
|
/// @ingroup core_template
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct tvec3
|
struct tvec3
|
||||||
{
|
{
|
||||||
|
@ -56,16 +56,16 @@ namespace glm
|
|||||||
|
|
||||||
/// Returns the component-wise compare of |x - y| < epsilon.
|
/// Returns the component-wise compare of |x - y| < epsilon.
|
||||||
/// @see gtc_epsilon
|
/// @see gtc_epsilon
|
||||||
template <typename genTypeT, typename genTypeU>
|
template <typename genTypeT, typename genTypeU, typename boolType>
|
||||||
bool epsilonEqual(
|
boolType epsilonEqual(
|
||||||
genTypeT const & x,
|
genTypeT const & x,
|
||||||
genTypeT const & y,
|
genTypeT const & y,
|
||||||
genTypeU const & epsilon);
|
genTypeU const & epsilon);
|
||||||
|
|
||||||
/// Returns the component-wise compare of |x - y| >= epsilon.
|
/// Returns the component-wise compare of |x - y| >= epsilon.
|
||||||
/// @see gtc_epsilon
|
/// @see gtc_epsilon
|
||||||
template <typename genTypeT, typename genTypeU>
|
template <typename genTypeT, typename genTypeU, typename boolType>
|
||||||
bool epsilonNotEqual(
|
boolType epsilonNotEqual(
|
||||||
genTypeT const & x,
|
genTypeT const & x,
|
||||||
genTypeT const & y,
|
genTypeT const & y,
|
||||||
genTypeU const & epsilon);
|
genTypeU const & epsilon);
|
||||||
|
@ -28,23 +28,67 @@
|
|||||||
|
|
||||||
namespace glm
|
namespace glm
|
||||||
{
|
{
|
||||||
template <typename genType>
|
template <>
|
||||||
GLM_FUNC_QUALIFIER bool epsilonEqual
|
GLM_FUNC_QUALIFIER bool epsilonEqual
|
||||||
(
|
(
|
||||||
genType const & x,
|
glm::half const & x,
|
||||||
genType const & y,
|
glm::half const & y,
|
||||||
genType const & epsilon
|
glm::half const & epsilon
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return abs(x - y) < epsilon;
|
return abs(x - y) < epsilon;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename genType>
|
template <>
|
||||||
|
GLM_FUNC_QUALIFIER bool epsilonEqual
|
||||||
|
(
|
||||||
|
float const & x,
|
||||||
|
float const & y,
|
||||||
|
float const & epsilon
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return abs(x - y) < epsilon;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
GLM_FUNC_QUALIFIER bool epsilonEqual
|
||||||
|
(
|
||||||
|
double const & x,
|
||||||
|
double const & y,
|
||||||
|
double const & epsilon
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return abs(x - y) < epsilon;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
GLM_FUNC_QUALIFIER bool epsilonNotEqual
|
GLM_FUNC_QUALIFIER bool epsilonNotEqual
|
||||||
(
|
(
|
||||||
genType const & x,
|
glm::half const & x,
|
||||||
genType const & y,
|
glm::half const & y,
|
||||||
genType const & epsilon
|
glm::half const & epsilon
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return abs(x - y) >= epsilon;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
GLM_FUNC_QUALIFIER bool epsilonNotEqual
|
||||||
|
(
|
||||||
|
float const & x,
|
||||||
|
float const & y,
|
||||||
|
float const & epsilon
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return abs(x - y) >= epsilon;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
GLM_FUNC_QUALIFIER bool epsilonNotEqual
|
||||||
|
(
|
||||||
|
double const & x,
|
||||||
|
double const & y,
|
||||||
|
double const & epsilon
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return abs(x - y) >= epsilon;
|
return abs(x - y) >= epsilon;
|
||||||
@ -62,76 +106,6 @@ namespace glm
|
|||||||
abs(x.y - y.y) < epsilon);
|
abs(x.y - y.y) < epsilon);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename valType>
|
|
||||||
GLM_FUNC_QUALIFIER detail::tvec3<bool> epsilonEqual
|
|
||||||
(
|
|
||||||
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>
|
|
||||||
GLM_FUNC_QUALIFIER detail::tvec4<bool> epsilonEqual
|
|
||||||
(
|
|
||||||
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>
|
|
||||||
GLM_FUNC_QUALIFIER detail::tvec2<bool> epsilonNotEqual
|
|
||||||
(
|
|
||||||
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>
|
|
||||||
GLM_FUNC_QUALIFIER detail::tvec3<bool> epsilonNotEqual
|
|
||||||
(
|
|
||||||
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>
|
|
||||||
GLM_FUNC_QUALIFIER detail::tvec4<bool> epsilonNotEqual
|
|
||||||
(
|
|
||||||
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>
|
template <typename valType>
|
||||||
GLM_FUNC_QUALIFIER detail::tvec2<bool> epsilonEqual
|
GLM_FUNC_QUALIFIER detail::tvec2<bool> epsilonEqual
|
||||||
(
|
(
|
||||||
@ -145,6 +119,19 @@ namespace glm
|
|||||||
abs(x.y - y.y) < epsilon.y);
|
abs(x.y - y.y) < epsilon.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename valType>
|
||||||
|
GLM_FUNC_QUALIFIER detail::tvec3<bool> epsilonEqual
|
||||||
|
(
|
||||||
|
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>
|
template <typename valType>
|
||||||
GLM_FUNC_QUALIFIER detail::tvec3<bool> epsilonEqual
|
GLM_FUNC_QUALIFIER detail::tvec3<bool> epsilonEqual
|
||||||
(
|
(
|
||||||
@ -164,22 +151,22 @@ namespace glm
|
|||||||
(
|
(
|
||||||
detail::tvec4<valType> const & x,
|
detail::tvec4<valType> const & x,
|
||||||
detail::tvec4<valType> const & y,
|
detail::tvec4<valType> const & y,
|
||||||
detail::tvec4<valType> const & epsilon
|
valType const & epsilon
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return detail::tvec4<bool>(
|
return detail::tvec4<bool>(
|
||||||
abs(x.x - y.x) < epsilon.x,
|
abs(x.x - y.x) < epsilon,
|
||||||
abs(x.y - y.y) < epsilon.y,
|
abs(x.y - y.y) < epsilon,
|
||||||
abs(x.z - y.z) < epsilon.z,
|
abs(x.z - y.z) < epsilon,
|
||||||
abs(x.w - y.w) < epsilon.w);
|
abs(x.w - y.w) < epsilon);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename valType>
|
template <typename valType>
|
||||||
GLM_FUNC_QUALIFIER detail::tvec4<bool> epsilonEqual
|
GLM_FUNC_QUALIFIER detail::tvec4<bool> epsilonEqual
|
||||||
(
|
(
|
||||||
detail::tquat<valType> const & x,
|
detail::tvec4<valType> const & x,
|
||||||
detail::tquat<valType> const & y,
|
detail::tvec4<valType> const & y,
|
||||||
detail::tquat<valType> const & epsilon
|
detail::tvec4<valType> const & epsilon
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return detail::tvec4<bool>(
|
return detail::tvec4<bool>(
|
||||||
@ -189,6 +176,19 @@ namespace glm
|
|||||||
abs(x.w - y.w) < epsilon.w);
|
abs(x.w - y.w) < epsilon.w);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename valType>
|
||||||
|
GLM_FUNC_QUALIFIER detail::tvec2<bool> epsilonNotEqual
|
||||||
|
(
|
||||||
|
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>
|
template <typename valType>
|
||||||
GLM_FUNC_QUALIFIER detail::tvec2<bool> epsilonNotEqual
|
GLM_FUNC_QUALIFIER detail::tvec2<bool> epsilonNotEqual
|
||||||
(
|
(
|
||||||
@ -202,6 +202,20 @@ namespace glm
|
|||||||
abs(x.y - y.y) >= epsilon.y);
|
abs(x.y - y.y) >= epsilon.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename valType>
|
||||||
|
GLM_FUNC_QUALIFIER detail::tvec3<bool> epsilonNotEqual
|
||||||
|
(
|
||||||
|
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>
|
template <typename valType>
|
||||||
GLM_FUNC_QUALIFIER detail::tvec3<bool> epsilonNotEqual
|
GLM_FUNC_QUALIFIER detail::tvec3<bool> epsilonNotEqual
|
||||||
(
|
(
|
||||||
@ -216,6 +230,21 @@ namespace glm
|
|||||||
abs(x.z - y.z) >= epsilon.z);
|
abs(x.z - y.z) >= epsilon.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename valType>
|
||||||
|
GLM_FUNC_QUALIFIER detail::tvec4<bool> epsilonNotEqual
|
||||||
|
(
|
||||||
|
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>
|
template <typename valType>
|
||||||
GLM_FUNC_QUALIFIER detail::tvec4<bool> epsilonNotEqual
|
GLM_FUNC_QUALIFIER detail::tvec4<bool> epsilonNotEqual
|
||||||
(
|
(
|
||||||
@ -231,6 +260,22 @@ namespace glm
|
|||||||
abs(x.w - y.w) >= epsilon.w);
|
abs(x.w - y.w) >= epsilon.w);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
template <typename valType>
|
||||||
|
GLM_FUNC_QUALIFIER detail::tvec4<bool> epsilonEqual
|
||||||
|
(
|
||||||
|
detail::tquat<valType> const & x,
|
||||||
|
detail::tquat<valType> const & y,
|
||||||
|
detail::tquat<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>
|
template <typename valType>
|
||||||
GLM_FUNC_QUALIFIER detail::tvec4<bool> epsilonNotEqual
|
GLM_FUNC_QUALIFIER detail::tvec4<bool> epsilonNotEqual
|
||||||
(
|
(
|
||||||
@ -245,4 +290,6 @@ namespace glm
|
|||||||
abs(x.z - y.z) >= epsilon.z,
|
abs(x.z - y.z) >= epsilon.z,
|
||||||
abs(x.w - y.w) >= epsilon.w);
|
abs(x.w - y.w) >= epsilon.w);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
}//namespace glm
|
}//namespace glm
|
||||||
|
@ -34,24 +34,20 @@ int test_inverse()
|
|||||||
int Error(0);
|
int Error(0);
|
||||||
|
|
||||||
{
|
{
|
||||||
glm::mat2 Matrix(1, 2, 3, 4);
|
glm::mat2 const Matrix(1, 2, 3, 4);
|
||||||
glm::mat2 Inverse = glm::inverse(Matrix);
|
glm::mat2 const Inverse = glm::inverse(Matrix);
|
||||||
glm::mat2 Identity = Matrix * Inverse;
|
glm::mat2 const Identity = Matrix * Inverse;
|
||||||
|
|
||||||
Error += glm::epsilonEqual(Identity[0][0], 1.0f, 0.01f) ? 0 : 1;
|
Error += glm::all(glm::epsilonEqual(Identity[0], glm::vec2(1.0f, 0.0f), glm::vec2(0.01f))) ? 0 : 1;
|
||||||
Error += glm::epsilonEqual(Identity[0][1], 0.0f, 0.01f) ? 0 : 1;
|
Error += glm::all(glm::epsilonEqual(Identity[1], glm::vec2(0.0f, 1.0f), glm::vec2(0.01f))) ? 0 : 1;
|
||||||
Error += glm::epsilonEqual(Identity[1][0], 0.0f, 0.01f) ? 0 : 1;
|
|
||||||
Error += glm::epsilonEqual(Identity[1][1], 1.0f, 0.01f) ? 0 : 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
glm::mat2 Matrix(1, 2, 3, 4);
|
glm::mat2 const Matrix(1, 2, 3, 4);
|
||||||
glm::mat2 Identity = Matrix / Matrix;
|
glm::mat2 const Identity = Matrix / Matrix;
|
||||||
|
|
||||||
Error += glm::epsilonEqual(Identity[0][0], 1.0f, 0.01f) ? 0 : 1;
|
Error += glm::all(glm::epsilonEqual(Identity[0], glm::vec2(1.0f, 0.0f), glm::vec2(0.01f))) ? 0 : 1;
|
||||||
Error += glm::epsilonEqual(Identity[0][1], 0.0f, 0.01f) ? 0 : 1;
|
Error += glm::all(glm::epsilonEqual(Identity[1], glm::vec2(0.0f, 1.0f), glm::vec2(0.01f))) ? 0 : 1;
|
||||||
Error += glm::epsilonEqual(Identity[1][0], 0.0f, 0.01f) ? 0 : 1;
|
|
||||||
Error += glm::epsilonEqual(Identity[1][1], 1.0f, 0.01f) ? 0 : 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return Error;
|
return Error;
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
|
#include <glm/gtc/epsilon.hpp>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
||||||
void print(glm::dmat3 const & Mat0)
|
void print(glm::dmat3 const & Mat0)
|
||||||
@ -53,12 +54,45 @@ static int test_operators()
|
|||||||
return (S && !R) ? 0 : 1;
|
return (S && !R) ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int test_inverse()
|
||||||
|
{
|
||||||
|
int Error(0);
|
||||||
|
|
||||||
|
{
|
||||||
|
glm::mat3 const Matrix(
|
||||||
|
glm::vec3(0.6f, 0.2f, 0.3f),
|
||||||
|
glm::vec3(0.2f, 0.7f, 0.5f),
|
||||||
|
glm::vec3(0.3f, 0.5f, 0.7f));
|
||||||
|
glm::mat3 const Inverse = glm::inverse(Matrix);
|
||||||
|
glm::mat3 const Identity = Matrix * Inverse;
|
||||||
|
|
||||||
|
Error += glm::all(glm::epsilonEqual(Identity[0], glm::vec3(1.0f, 0.0f, 0.0f), glm::vec3(0.01f))) ? 0 : 1;
|
||||||
|
Error += glm::all(glm::epsilonEqual(Identity[1], glm::vec3(0.0f, 1.0f, 0.0f), glm::vec3(0.01f))) ? 0 : 1;
|
||||||
|
Error += glm::all(glm::epsilonEqual(Identity[2], glm::vec3(0.0f, 0.0f, 1.0f), glm::vec3(0.01f))) ? 0 : 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
glm::mat3 const Matrix(
|
||||||
|
glm::vec3(0.6f, 0.2f, 0.3f),
|
||||||
|
glm::vec3(0.2f, 0.7f, 0.5f),
|
||||||
|
glm::vec3(0.3f, 0.5f, 0.7f));
|
||||||
|
glm::mat3 const Identity = Matrix / Matrix;
|
||||||
|
|
||||||
|
Error += glm::all(glm::epsilonEqual(Identity[0], glm::vec3(1.0f, 0.0f, 0.0f), glm::vec3(0.01f))) ? 0 : 1;
|
||||||
|
Error += glm::all(glm::epsilonEqual(Identity[1], glm::vec3(0.0f, 1.0f, 0.0f), glm::vec3(0.01f))) ? 0 : 1;
|
||||||
|
Error += glm::all(glm::epsilonEqual(Identity[2], glm::vec3(0.0f, 0.0f, 1.0f), glm::vec3(0.01f))) ? 0 : 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Error;
|
||||||
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
int Error = 0;
|
int Error = 0;
|
||||||
|
|
||||||
Error += test_mat3x3();
|
Error += test_mat3x3();
|
||||||
Error += test_operators();
|
Error += test_operators();
|
||||||
|
Error += test_inverse();
|
||||||
|
|
||||||
return Error;
|
return Error;
|
||||||
}
|
}
|
||||||
|
@ -7,8 +7,9 @@
|
|||||||
// File : test/core/type_mat4x4.cpp
|
// File : test/core/type_mat4x4.cpp
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#define GLM_PRECISION_HIGHP_FLOAT
|
//#define GLM_PRECISION_HIGHP_FLOAT
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
|
#include <glm/gtc/epsilon.hpp>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
||||||
void print(glm::dmat4 const & Mat0)
|
void print(glm::dmat4 const & Mat0)
|
||||||
@ -20,7 +21,33 @@ void print(glm::dmat4 const & Mat0)
|
|||||||
printf("\tvec4(%2.3f, %2.3f, %2.3f, %2.3f))\n\n", Mat0[3][0], Mat0[3][1], Mat0[3][2], Mat0[3][3]);
|
printf("\tvec4(%2.3f, %2.3f, %2.3f, %2.3f))\n\n", Mat0[3][0], Mat0[3][1], Mat0[3][2], Mat0[3][3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
int test_mat4x4()
|
void print(glm::mat4 const & Mat0)
|
||||||
|
{
|
||||||
|
printf("mat4(\n");
|
||||||
|
printf("\tvec4(%2.3f, %2.3f, %2.3f, %2.3f)\n", Mat0[0][0], Mat0[0][1], Mat0[0][2], Mat0[0][3]);
|
||||||
|
printf("\tvec4(%2.3f, %2.3f, %2.3f, %2.3f)\n", Mat0[1][0], Mat0[1][1], Mat0[1][2], Mat0[1][3]);
|
||||||
|
printf("\tvec4(%2.3f, %2.3f, %2.3f, %2.3f)\n", Mat0[2][0], Mat0[2][1], Mat0[2][2], Mat0[2][3]);
|
||||||
|
printf("\tvec4(%2.3f, %2.3f, %2.3f, %2.3f))\n\n", Mat0[3][0], Mat0[3][1], Mat0[3][2], Mat0[3][3]);
|
||||||
|
}
|
||||||
|
|
||||||
|
int test_inverse_mat4x4()
|
||||||
|
{
|
||||||
|
glm::mat4 Mat0(
|
||||||
|
glm::vec4(0.6f, 0.2f, 0.3f, 0.4f),
|
||||||
|
glm::vec4(0.2f, 0.7f, 0.5f, 0.3f),
|
||||||
|
glm::vec4(0.3f, 0.5f, 0.7f, 0.2f),
|
||||||
|
glm::vec4(0.4f, 0.3f, 0.2f, 0.6f));
|
||||||
|
glm::mat4 Inv0 = glm::inverse(Mat0);
|
||||||
|
glm::mat4 Res0 = Mat0 * Inv0;
|
||||||
|
|
||||||
|
print(Mat0);
|
||||||
|
print(Inv0);
|
||||||
|
print(Res0);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int test_inverse_dmat4x4()
|
||||||
{
|
{
|
||||||
glm::dmat4 Mat0(
|
glm::dmat4 Mat0(
|
||||||
glm::dvec4(0.6f, 0.2f, 0.3f, 0.4f),
|
glm::dvec4(0.6f, 0.2f, 0.3f, 0.4f),
|
||||||
@ -56,12 +83,54 @@ static bool test_operators()
|
|||||||
return (S && !R) ? 0 : 1;
|
return (S && !R) ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int test_inverse()
|
||||||
|
{
|
||||||
|
int Error(0);
|
||||||
|
|
||||||
|
{
|
||||||
|
glm::mat4 const Matrix(
|
||||||
|
glm::vec4(0.6f, 0.2f, 0.3f, 0.4f),
|
||||||
|
glm::vec4(0.2f, 0.7f, 0.5f, 0.3f),
|
||||||
|
glm::vec4(0.3f, 0.5f, 0.7f, 0.2f),
|
||||||
|
glm::vec4(0.4f, 0.3f, 0.2f, 0.6f));
|
||||||
|
glm::mat4 const Inverse = glm::inverse(Matrix);
|
||||||
|
glm::mat4 const Identity = Matrix * Inverse;
|
||||||
|
|
||||||
|
print(Matrix);
|
||||||
|
print(Inverse);
|
||||||
|
print(Identity);
|
||||||
|
|
||||||
|
Error += glm::all(glm::epsilonEqual(Identity[0], glm::vec4(1.0f, 0.0f, 0.0f, 0.0f), glm::vec4(0.01f))) ? 0 : 1;
|
||||||
|
Error += glm::all(glm::epsilonEqual(Identity[1], glm::vec4(0.0f, 1.0f, 0.0f, 0.0f), glm::vec4(0.01f))) ? 0 : 1;
|
||||||
|
Error += glm::all(glm::epsilonEqual(Identity[2], glm::vec4(0.0f, 0.0f, 1.0f, 0.0f), glm::vec4(0.01f))) ? 0 : 1;
|
||||||
|
Error += glm::all(glm::epsilonEqual(Identity[3], glm::vec4(0.0f, 0.0f, 0.0f, 1.0f), glm::vec4(0.01f))) ? 0 : 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
glm::mat4 const Matrix(
|
||||||
|
glm::vec4(0.6f, 0.2f, 0.3f, 0.4f),
|
||||||
|
glm::vec4(0.2f, 0.7f, 0.5f, 0.3f),
|
||||||
|
glm::vec4(0.3f, 0.5f, 0.7f, 0.2f),
|
||||||
|
glm::vec4(0.4f, 0.3f, 0.2f, 0.6f));
|
||||||
|
glm::mat4 const Identity = Matrix / Matrix;
|
||||||
|
|
||||||
|
Error += glm::all(glm::epsilonEqual(Identity[0], glm::vec4(1.0f, 0.0f, 0.0f, 0.0f), glm::vec4(0.01f))) ? 0 : 1;
|
||||||
|
Error += glm::all(glm::epsilonEqual(Identity[1], glm::vec4(0.0f, 1.0f, 0.0f, 0.0f), glm::vec4(0.01f))) ? 0 : 1;
|
||||||
|
Error += glm::all(glm::epsilonEqual(Identity[2], glm::vec4(0.0f, 0.0f, 1.0f, 0.0f), glm::vec4(0.01f))) ? 0 : 1;
|
||||||
|
Error += glm::all(glm::epsilonEqual(Identity[3], glm::vec4(0.0f, 0.0f, 0.0f, 1.0f), glm::vec4(0.01f))) ? 0 : 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Error;
|
||||||
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
int Error = 0;
|
int Error = 0;
|
||||||
|
|
||||||
Error += test_mat4x4();
|
Error += test_inverse_dmat4x4();
|
||||||
|
Error += test_inverse_mat4x4();
|
||||||
Error += test_operators();
|
Error += test_operators();
|
||||||
|
Error += test_inverse();
|
||||||
|
|
||||||
return Error;
|
return Error;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user