X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fgeometry%2Fdistance.hpp;h=b6955af49391e570cd81970e9a75a57bd9787c9f;hb=f5de855fbd4bf5b0df1cad950cbe9069e41369ca;hp=b53fcd7c679c7630051ba7911ecdd35818161b48;hpb=5c0d6397cfdec3a284a6560c3c6b3acbcd9f9331;p=blank.git diff --git a/src/geometry/distance.hpp b/src/geometry/distance.hpp index b53fcd7..b6955af 100644 --- a/src/geometry/distance.hpp +++ b/src/geometry/distance.hpp @@ -4,37 +4,25 @@ #include #include #include +#include +#include namespace blank { -inline float length_squared(const glm::vec3 &v) noexcept { - return dot(v, v); -} - -inline float distance_squared(const glm::vec3 &a, const glm::vec3 &b) noexcept { - return length_squared(a - b); -} - -inline float distance(const glm::vec3 &a, const glm::vec3 &b) noexcept { - return length(a - b); -} - template inline bool iszero(const T &v) noexcept { - return length_squared(v) < std::numeric_limits::epsilon(); + return length2(v) < std::numeric_limits::epsilon(); } template T manhattan_distance(const glm::tvec3 &a, const glm::tvec3 &b) noexcept { - glm::tvec3 diff(abs(a - b)); - return diff.x + diff.y + diff.z; + return compAdd(abs(a - b)); } template T manhattan_radius(const glm::tvec3 &v) noexcept { - glm::tvec3 a(abs(v)); - return std::max(a.x, std::max(a.y, a.z)); + return compMax(abs(v)); } }