1 #ifndef BLOBS_MATH_GEOMETRY_HPP_
2 #define BLOBS_MATH_GEOMETRY_HPP_
17 void Adjust() noexcept {
18 if (max.x < min.x) std::swap(max.x, min.x);
19 if (max.y < min.y) std::swap(max.y, min.y);
20 if (max.z < min.z) std::swap(max.z, min.z);
23 glm::dvec3 Center() const noexcept {
24 return min + (max - min) * 0.5;
29 /// matrices must not scale
32 const glm::dmat4 &a_m,
34 const glm::dmat4 &b_m,
36 double &depth) noexcept;
41 Ray(const glm::dvec3 &orig, const glm::dvec3 &dir)
42 : orig(orig), dir(dir), inv_dir(1.0 / dir) { }
44 void Origin(const glm::dvec3 &o) noexcept { orig = o; }
45 const glm::dvec3 &Origin() const noexcept { return orig; }
46 void Direction(const glm::dvec3 &d) noexcept { dir = d; inv_dir = 1.0 / d; }
47 const glm::dvec3 &Direction() const noexcept { return dir; }
48 const glm::dvec3 &InverseDirection() const noexcept { return inv_dir; }
57 /// oriented ray/box intersection test
63 double &dist) noexcept;