ESyS-Particle  2.3.4
BoundingSphere.hpp
Go to the documentation of this file.
1 // //
3 // Copyright (c) 2003-2017 by The University of Queensland //
4 // Centre for Geoscience Computing //
5 // http://earth.uq.edu.au/centre-geoscience-computing //
6 // //
7 // Primary Business: Brisbane, Queensland, Australia //
8 // Licensed under the Open Software License version 3.0 //
9 // http://www.apache.org/licenses/LICENSE-2.0 //
10 // //
12 
13 
15 
16 namespace esys
17 {
18 
19  namespace lsm
20  {
22  : m_centre(Vec3::ZERO),
23  m_radius(0.0)
24  {
25  }
26 
27  BoundingSphere::BoundingSphere(const Vec3 &centre, double radius)
28  : m_centre(centre),
29  m_radius(radius)
30  {
31  }
32 
34  {
35  }
36 
38  {
39  return m_centre;
40  }
41 
43  {
44  return m_radius;
45  }
46 
48  {
50  }
51 
53  {
54  return
56  Vec3(getCentre()[0]-getRadius(), getCentre()[1]-getRadius(), 0.0),
57  Vec3(getCentre()[0]+getRadius(), getCentre()[1]+getRadius(), 0.0)
58  );
59  }
60 
61  bool BoundingSphere::operator==(const BoundingSphere &bSphere) const
62  {
63  return
64  (
65  (getCentre() == bSphere.getCentre())
66  &&
67  (getRadius() == bSphere.getRadius())
68  );
69  }
70 
71  bool BoundingSphere::contains(const Vec3 &pt, double tolerance) const
72  {
73  const double r = (getRadius() + tolerance);
74  return ((getCentre()-pt).norm2() <= (r*r));
75  }
76 
78  const BoundingSphere &bSphere,
79  double tolerance
80  ) const
81  {
82  const double r = (getRadius()-bSphere.getRadius() + tolerance);
83  return ((getCentre()-bSphere.getCentre()).norm2() <= (r*r));
84  }
85 
86  std::ostream &operator<<(std::ostream &oStream, const BoundingSphere &bSphere)
87  {
88  oStream << bSphere.getCentre() << " " << bSphere.getRadius();
89  return oStream;
90  }
91  }
92 }
esys::lsm::BoundingSphere::BoundingSphere
BoundingSphere()
Definition: BoundingSphere.hpp:21
esys::lsm::BoundingSphere
Definition: BoundingSphere.h:28
esys::lsm::BoundingSphere::m_centre
Vec3 m_centre
Definition: BoundingSphere.h:54
esys::lsm::BoundingSphere::getCentre
const Vec3 & getCentre() const
Definition: BoundingSphere.hpp:37
esys::lsm::BoundingSphere::contains
bool contains(const Vec3 &pt, double tolerance=0.0) const
Definition: BoundingSphere.hpp:71
esys::lsm::BoundingSphere::get2dBBox
BoundingBox get2dBBox() const
Definition: BoundingSphere.hpp:52
esys::lsm::BoundingBox
3D bounding box
Definition: BoundingBox.h:28
esys::lsm::BoundingSphere::~BoundingSphere
virtual ~BoundingSphere()
Definition: BoundingSphere.hpp:33
esys
Definition: CheckPointable.cpp:17
esys::lsm::operator<<
std::ostream & operator<<(std::ostream &oStream, const SimpleConnectionData &connectionData)
Definition: GeometryReader.cpp:134
BoundingSphere.h
Vec3
Definition: vec3.h:47
esys::lsm::BoundingSphere::m_radius
double m_radius
Definition: BoundingSphere.h:55
esys::lsm::BoundingSphere::operator==
bool operator==(const BoundingSphere &bSphere) const
Definition: BoundingSphere.hpp:61
esys::lsm::BoundingSphere::getRadius
double getRadius() const
Definition: BoundingSphere.hpp:42
esys::lsm::BoundingSphere::getBBox
BoundingBox getBBox() const
Definition: BoundingSphere.hpp:47