]> git.localhorst.tv Git - blank.git/blob - src/geometry/distance.hpp
geometry stuff
[blank.git] / src / geometry / distance.hpp
1 #ifndef BLANK_GEOMETRY_DISTANCE_HPP_
2 #define BLANK_GEOMETRY_DISTANCE_HPP_
3
4 #include <algorithm>
5 #include <limits>
6 #include <glm/glm.hpp>
7 #include <glm/gtx/component_wise.hpp>
8 #include <glm/gtx/norm.hpp>
9
10
11 namespace blank {
12
13 template <class T>
14 inline bool iszero(const T &v) noexcept {
15         return length2(v) < std::numeric_limits<typename T::value_type>::epsilon();
16 }
17
18 template<class T>
19 T manhattan_distance(const glm::tvec3<T> &a, const glm::tvec3<T> &b) noexcept {
20         return compAdd(abs(a - b));
21 }
22
23 template<class T>
24 T manhattan_radius(const glm::tvec3<T> &v) noexcept {
25         return compMax(abs(v));
26 }
27
28 }
29
30 #endif