• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/// @ref gtc_epsilon
2/// @file glm/gtc/epsilon.inl
3
4// Dependency:
5#include "quaternion.hpp"
6#include "../vector_relational.hpp"
7#include "../common.hpp"
8#include "../vec2.hpp"
9#include "../vec3.hpp"
10#include "../vec4.hpp"
11
12namespace glm
13{
14	template <>
15	GLM_FUNC_QUALIFIER bool epsilonEqual
16	(
17		float const & x,
18		float const & y,
19		float const & epsilon
20	)
21	{
22		return abs(x - y) < epsilon;
23	}
24
25	template <>
26	GLM_FUNC_QUALIFIER bool epsilonEqual
27	(
28		double const & x,
29		double const & y,
30		double const & epsilon
31	)
32	{
33		return abs(x - y) < epsilon;
34	}
35
36	template <>
37	GLM_FUNC_QUALIFIER bool epsilonNotEqual
38	(
39		float const & x,
40		float const & y,
41		float const & epsilon
42	)
43	{
44		return abs(x - y) >= epsilon;
45	}
46
47	template <>
48	GLM_FUNC_QUALIFIER bool epsilonNotEqual
49	(
50		double const & x,
51		double const & y,
52		double const & epsilon
53	)
54	{
55		return abs(x - y) >= epsilon;
56	}
57
58	template <typename T, precision P, template <typename, precision> class vecType>
59	GLM_FUNC_QUALIFIER vecType<bool, P> epsilonEqual
60	(
61		vecType<T, P> const & x,
62		vecType<T, P> const & y,
63		T const & epsilon
64	)
65	{
66		return lessThan(abs(x - y), vecType<T, P>(epsilon));
67	}
68
69	template <typename T, precision P, template <typename, precision> class vecType>
70	GLM_FUNC_QUALIFIER vecType<bool, P> epsilonEqual
71	(
72		vecType<T, P> const & x,
73		vecType<T, P> const & y,
74		vecType<T, P> const & epsilon
75	)
76	{
77		return lessThan(abs(x - y), vecType<T, P>(epsilon));
78	}
79
80	template <typename T, precision P, template <typename, precision> class vecType>
81	GLM_FUNC_QUALIFIER vecType<bool, P> epsilonNotEqual
82	(
83		vecType<T, P> const & x,
84		vecType<T, P> const & y,
85		T const & epsilon
86	)
87	{
88		return greaterThanEqual(abs(x - y), vecType<T, P>(epsilon));
89	}
90
91	template <typename T, precision P, template <typename, precision> class vecType>
92	GLM_FUNC_QUALIFIER vecType<bool, P> epsilonNotEqual
93	(
94		vecType<T, P> const & x,
95		vecType<T, P> const & y,
96		vecType<T, P> const & epsilon
97	)
98	{
99		return greaterThanEqual(abs(x - y), vecType<T, P>(epsilon));
100	}
101
102	template <typename T, precision P>
103	GLM_FUNC_QUALIFIER tvec4<bool, P> epsilonEqual
104	(
105		tquat<T, P> const & x,
106		tquat<T, P> const & y,
107		T const & epsilon
108	)
109	{
110		tvec4<T, P> v(x.x - y.x, x.y - y.y, x.z - y.z, x.w - y.w);
111		return lessThan(abs(v), tvec4<T, P>(epsilon));
112	}
113
114	template <typename T, precision P>
115	GLM_FUNC_QUALIFIER tvec4<bool, P> epsilonNotEqual
116	(
117		tquat<T, P> const & x,
118		tquat<T, P> const & y,
119		T const & epsilon
120	)
121	{
122		tvec4<T, P> v(x.x - y.x, x.y - y.y, x.z - y.z, x.w - y.w);
123		return greaterThanEqual(abs(v), tvec4<T, P>(epsilon));
124	}
125}//namespace glm
126