1 #ifndef BLANK_GEOMETRY_DISTANCE_HPP_
2 #define BLANK_GEOMETRY_DISTANCE_HPP_
4 #include "../graphics/glm.hpp"
8 #include <glm/gtx/component_wise.hpp>
9 #include <glm/gtx/norm.hpp>
15 inline bool iszero(const T &v) noexcept {
16 return glm::length2(v) < std::numeric_limits<typename T::value_type>::epsilon();
20 inline void limit(Vec &v, float max) noexcept {
21 float len2 = glm::length2(v);
22 float max2 = max * max;
24 v = glm::normalize(v) * max;
28 template<class T, glm::precision P = glm::precision(0)>
29 T manhattan_distance(const TVEC3<T, P> &a, const TVEC3<T, P> &b) noexcept {
30 return glm::compAdd(glm::abs(a - b));
33 template<class T, glm::precision P = glm::precision(0)>
34 T manhattan_radius(const TVEC3<T, P> &v) noexcept {
35 return glm::compMax(glm::abs(v));