voxelTerrain
 All Classes Functions Variables Typedefs Enumerations Pages
sphere.hpp
1 #ifndef BLUB_SPHERE_HPP
2 #define BLUB_SPHERE_HPP
3 
4 #include "vector3.hpp"
5 
6 
7 namespace blub
8 {
9 
10  class sphere
11  {
12  public:
14  sphere() : mRadius(1.0), mCenter(vector3::ZERO) {}
19  sphere(const vector3& center, real radius)
20  : mRadius(radius), mCenter(center) {}
21 
23  real getRadius(void) const { return mRadius; }
24 
26  void setRadius(real radius) { mRadius = radius; }
27 
29  const vector3& getCenter(void) const { return mCenter; }
30 
32  void setCenter(const vector3& center) { mCenter = center; }
33 
35  bool intersects(const sphere& s) const;
36 
38  bool intersects(const axisAlignedBox& box) const;
39 
41  bool intersects(const vector3& v) const
42  {
43  return ((v - mCenter).squaredLength() <= mRadius*mRadius);
44  }
46  void merge(const sphere& oth);
47 
48  bool contains(const vector3& vec) const
49  {return intersects(vec);}
50 
51  real getSquaredRadius() const
52  {
53  return mRadius*mRadius;
54  }
55 
56  bool inherts(axisAlignedBox aabb) const;
57 
58  protected:
59  real mRadius;
60  vector3 mCenter;
61 
62  };
63 
64 }
65 
66 #endif // BLUB_SPHERE_HPP
sphere(const vector3 &center, real radius)
Definition: sphere.hpp:19
real getRadius(void) const
Definition: sphere.hpp:23
sphere()
Definition: sphere.hpp:14
void setRadius(real radius)
Definition: sphere.hpp:26
const vector3 & getCenter(void) const
Definition: sphere.hpp:29
bool intersects(const sphere &s) const
Definition: sphere.cpp:9
bool intersects(const vector3 &v) const
Definition: sphere.hpp:41
Definition: vector3.hpp:26
Definition: axisAlignedBox.hpp:20
void setCenter(const vector3 &center)
Definition: sphere.hpp:32
void merge(const sphere &oth)
Definition: sphere.cpp:14
Definition: deadlineTimer.hpp:10
Definition: sphere.hpp:10