diff --git a/GeoLib/AxisAlignedBoundingBox.cpp b/GeoLib/AxisAlignedBoundingBox.cpp index b4dd113cab6c573d515e9f2b14c273fa53e2b241..1d729498e9f42816c6a082760dca3f6ea4989e46 100644 --- a/GeoLib/AxisAlignedBoundingBox.cpp +++ b/GeoLib/AxisAlignedBoundingBox.cpp @@ -86,4 +86,15 @@ bool AABB::containsPoint (double x, double y, double z, double eps) const } else return false; } +bool AABB::containsAABB (AABB const& other_aabb) const +{ + GeoLib::Point const& min_other(other_aabb.getMinPoint()); + GeoLib::Point const& max_other(other_aabb.getMaxPoint()); + for (unsigned k(0); k<3; k++) { + if (_min_pnt[k] > min_other[k] || max_other[k] > _max_pnt[k]) + return false; + } + return true; +} + } // end namespace GeoLib diff --git a/GeoLib/AxisAlignedBoundingBox.h b/GeoLib/AxisAlignedBoundingBox.h index 98c0bef38a8ef8c04bf1c57d3ab65663e82b0328..808c44f28ff567f93cfb6f0c2d9a262a4b8505f4 100644 --- a/GeoLib/AxisAlignedBoundingBox.h +++ b/GeoLib/AxisAlignedBoundingBox.h @@ -79,9 +79,29 @@ public: bool containsPoint(double x, double y, double z, double eps = std::numeric_limits<double>::epsilon()) const; + /** + * returns a point that coordinates are minimal for each dimension + * for the given point set + * @return a point + */ GeoLib::Point const& getMinPoint () const { return _min_pnt; } + + /** + * returns a point that coordinates are maximal for each dimension + * within the given point set + * @return a point + */ GeoLib::Point const& getMaxPoint () const { return _max_pnt; } + /** + * Method checks if the given AABB object is contained within the + * AABB represented by this object. + * @param other the AABB to test with + * @return true if the other AABB is contained in the AABB + * represented by this object + */ + bool containsAABB (AABB const& other) const; + protected: GeoLib::Point _min_pnt; GeoLib::Point _max_pnt;