2 #ifndef GRAMODS_GRAPHICS_AABB
3 #define GRAMODS_GRAPHICS_AABB
5 #include <gmGraphics/config.hh>
6 #include <gmGraphics/IntersectionVisitor.hh>
10 BEGIN_NAMESPACE_GMGRAPHICS;
18 AABB(
const AABB &bb) : bmin(bb.bmin), bmax(bb.bmax) {}
19 AABB(
const Eigen::Vector3f &p) : bmin(p), bmax(p) {}
20 AABB(
const AABB &bb,
const Eigen::Vector3f &p)
21 : bmin(bb.bmin.cwiseMin(p)), bmax(bb.bmax.cwiseMax(p)) {}
23 : bmin(op1.bmin.cwiseMin(op2.bmin)), bmax(op1.bmax.cwiseMax(op2.bmax)) {}
25 AABB operator+(
const Eigen::Vector3f &op) {
return AABB(*
this, op); }
26 AABB operator+(
const AABB &op) {
return AABB(*
this, op); }
27 AABB &operator+=(
const Eigen::Vector3f &op) {
return *
this = *
this + op; }
28 AABB &operator+=(
const AABB &op) {
return *
this = *
this + op; }
30 const Eigen::Vector3f &min()
const {
return bmin; }
31 const Eigen::Vector3f &max()
const {
return bmax; }
33 Eigen::Vector3f getCenter() {
return 0.5f * (bmax + bmin); }
35 AABB &addOffset(
const Eigen::Vector3f &op) {
41 std::vector<Eigen::Vector3f> getCorners()
const {
43 Eigen::Vector3f(bmin.x(), bmin.y(), bmin.z()),
44 Eigen::Vector3f(bmin.x(), bmin.y(), bmax.z()),
45 Eigen::Vector3f(bmin.x(), bmax.y(), bmin.z()),
46 Eigen::Vector3f(bmin.x(), bmax.y(), bmax.z()),
47 Eigen::Vector3f(bmax.x(), bmin.y(), bmin.z()),
48 Eigen::Vector3f(bmax.x(), bmin.y(), bmax.z()),
49 Eigen::Vector3f(bmax.x(), bmax.y(), bmin.z()),
50 Eigen::Vector3f(bmax.x(), bmax.y(), bmax.z()),
62 bool isIntersecting(
const Line &line);
69 std::vector<float> getIntersections(
const Line &line);
76 END_NAMESPACE_GMGRAPHICS;
Axis aligned bounding box values with operations.
Definition: AABB.hh:15
IntersectionLine Line
Line for intersection checking.
Definition: AABB.hh:57
Line for intersection with ray or segment.
Definition: IntersectionLine.hh:15