X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fmodel%2Fgeometry.hpp;h=0bc17c162b73afb2e457866ca5c0d98617f59865;hb=f0a20986c573c4df1eb1212333489252c4b30efa;hp=f9f87c4f9d14462f31af92b16247e5a6aad584e9;hpb=f417749fb09718cde2faad77e8430cf175c68374;p=blank.git diff --git a/src/model/geometry.hpp b/src/model/geometry.hpp index f9f87c4..0bc17c1 100644 --- a/src/model/geometry.hpp +++ b/src/model/geometry.hpp @@ -2,6 +2,7 @@ #define BLANK_MODEL_GEOMETRY_H_ #include +#include #include @@ -13,6 +14,9 @@ constexpr float PI_0p5 = PI * 0.5f; constexpr float PI_1p5 = PI * 1.5f; constexpr float PI_2p0 = PI * 2.0f; +constexpr float PI_inv = 1.0f / PI; +constexpr float PI_0p5_inv = 1.0f / PI_0p5; + constexpr float DEG_RAD_FACTOR = PI / 180.0f; constexpr float RAD_DEG_FACTOR = 180.0f / PI; @@ -25,6 +29,12 @@ constexpr float rad2deg(float r) { } +template +inline bool iszero(const T &v) { + return dot(v, v) < std::numeric_limits::epsilon(); +} + + template T manhattan_distance(const glm::tvec3 &a, const glm::tvec3 &b) { glm::tvec3 diff(abs(a - b));