X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fmodel%2Fgeometry.hpp;h=fd2c42bb8c8fa7f643f7fcae8697aeac26496dd2;hb=8de9eb53c9ae92c6bfa8f01cf6659b683fe2155d;hp=f1b3762d2905ff650ae44c435bd2b4cfdf1cfbaa;hpb=5e8eee742138f2578e83e710ffc41408abd3073f;p=blank.git diff --git a/src/model/geometry.hpp b/src/model/geometry.hpp index f1b3762..fd2c42b 100644 --- a/src/model/geometry.hpp +++ b/src/model/geometry.hpp @@ -13,6 +13,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 +28,19 @@ constexpr float rad2deg(float r) { } +template +T manhattan_distance(const glm::tvec3 &a, const glm::tvec3 &b) { + glm::tvec3 diff(abs(a - b)); + return diff.x + diff.y + diff.z; +} + +template +T manhattan_radius(const glm::tvec3 &v) { + glm::tvec3 a(abs(v)); + return std::max(a.x, std::max(a.y, a.z)); +} + + struct AABB { glm::vec3 min; glm::vec3 max;