14 #include "Foundation/BoundingSphere.h"
21 BoundingSphere::BoundingSphere()
22 : m_centre(
Vec3::ZERO),
27 BoundingSphere::BoundingSphere(
const Vec3 ¢re,
double radius)
33 BoundingSphere::~BoundingSphere()
37 const Vec3 &BoundingSphere::getCentre()
const
42 double BoundingSphere::getRadius()
const
47 BoundingBox BoundingSphere::getBBox()
const
49 return BoundingBox(getCentre()-getRadius(), getCentre()+getRadius());
52 BoundingBox BoundingSphere::get2dBBox()
const
56 Vec3(getCentre()[0]-getRadius(), getCentre()[1]-getRadius(), 0.0),
57 Vec3(getCentre()[0]+getRadius(), getCentre()[1]+getRadius(), 0.0)
61 bool BoundingSphere::operator==(
const BoundingSphere &bSphere)
const
65 (getCentre() == bSphere.getCentre())
67 (getRadius() == bSphere.getRadius())
71 bool BoundingSphere::contains(
const Vec3 &pt,
double tolerance)
const
73 const double r = (getRadius() + tolerance);
74 return ((getCentre()-pt).norm2() <= (r*r));
77 bool BoundingSphere::contains(
78 const BoundingSphere &bSphere,
82 const double r = (getRadius()-bSphere.getRadius() + tolerance);
83 return ((getCentre()-bSphere.getCentre()).norm2() <= (r*r));
86 std::ostream &operator<<(std::ostream &oStream,
const BoundingSphere &bSphere)
88 oStream << bSphere.getCentre() <<
" " << bSphere.getRadius();