• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1///////////////////////////////////////////////////////////////////////////////////
2/// OpenGL Mathematics (glm.g-truc.net)
3///
4/// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
5/// Permission is hereby granted, free of charge, to any person obtaining a copy
6/// of this software and associated documentation files (the "Software"), to deal
7/// in the Software without restriction, including without limitation the rights
8/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9/// copies of the Software, and to permit persons to whom the Software is
10/// furnished to do so, subject to the following conditions:
11///
12/// The above copyright notice and this permission notice shall be included in
13/// all copies or substantial portions of the Software.
14///
15/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21/// THE SOFTWARE.
22///
23/// @ref gtc_epsilon
24/// @file glm/gtc/epsilon.inl
25/// @date 2012-04-07 / 2012-04-07
26/// @author Christophe Riccio
27///////////////////////////////////////////////////////////////////////////////////
28
29// Dependency:
30#include "quaternion.hpp"
31#include "../vector_relational.hpp"
32#include "../common.hpp"
33#include "../vec2.hpp"
34#include "../vec3.hpp"
35#include "../vec4.hpp"
36
37namespace glm
38{
39	template <>
40	GLM_FUNC_QUALIFIER bool epsilonEqual
41	(
42		float const & x,
43		float const & y,
44		float const & epsilon
45	)
46	{
47		return abs(x - y) < epsilon;
48	}
49
50	template <>
51	GLM_FUNC_QUALIFIER bool epsilonEqual
52	(
53		double const & x,
54		double const & y,
55		double const & epsilon
56	)
57	{
58		return abs(x - y) < epsilon;
59	}
60
61	template <>
62	GLM_FUNC_QUALIFIER bool epsilonNotEqual
63	(
64		float const & x,
65		float const & y,
66		float const & epsilon
67	)
68	{
69		return abs(x - y) >= epsilon;
70	}
71
72	template <>
73	GLM_FUNC_QUALIFIER bool epsilonNotEqual
74	(
75		double const & x,
76		double const & y,
77		double const & epsilon
78	)
79	{
80		return abs(x - y) >= epsilon;
81	}
82
83	template <typename T, precision P, template <typename, precision> class vecType>
84	GLM_FUNC_QUALIFIER vecType<bool, P> epsilonEqual
85	(
86		vecType<T, P> const & x,
87		vecType<T, P> const & y,
88		T const & epsilon
89	)
90	{
91		return lessThan(abs(x - y), vecType<T, P>(epsilon));
92	}
93
94	template <typename T, precision P, template <typename, precision> class vecType>
95	GLM_FUNC_QUALIFIER vecType<bool, P> epsilonEqual
96	(
97		vecType<T, P> const & x,
98		vecType<T, P> const & y,
99		vecType<T, P> const & epsilon
100	)
101	{
102		return lessThan(abs(x - y), vecType<T, P>(epsilon));
103	}
104
105	template <typename T, precision P, template <typename, precision> class vecType>
106	GLM_FUNC_QUALIFIER vecType<bool, P> epsilonNotEqual
107	(
108		vecType<T, P> const & x,
109		vecType<T, P> const & y,
110		T const & epsilon
111	)
112	{
113		return greaterThanEqual(abs(x - y), vecType<T, P>(epsilon));
114	}
115
116	template <typename T, precision P, template <typename, precision> class vecType>
117	GLM_FUNC_QUALIFIER vecType<bool, P> epsilonNotEqual
118	(
119		vecType<T, P> const & x,
120		vecType<T, P> const & y,
121		vecType<T, P> const & epsilon
122	)
123	{
124		return greaterThanEqual(abs(x - y), vecType<T, P>(epsilon));
125	}
126
127	template <typename T, precision P>
128	GLM_FUNC_QUALIFIER detail::tvec4<bool, P> epsilonEqual
129	(
130		detail::tquat<T, P> const & x,
131		detail::tquat<T, P> const & y,
132		T const & epsilon
133	)
134	{
135		detail::tvec4<T, P> v(x.x - y.x, x.y - y.y, x.z - y.z, x.w - y.w);
136		return lessThan(abs(v), detail::tvec4<T, P>(epsilon));
137	}
138
139	template <typename T, precision P>
140	GLM_FUNC_QUALIFIER detail::tvec4<bool, P> epsilonNotEqual
141	(
142		detail::tquat<T, P> const & x,
143		detail::tquat<T, P> const & y,
144		T const & epsilon
145	)
146	{
147		detail::tvec4<T, P> v(x.x - y.x, x.y - y.y, x.z - y.z, x.w - y.w);
148		return greaterThanEqual(abs(v), detail::tvec4<T, P>(epsilon));
149	}
150}//namespace glm
151