box.h
Go to the documentation of this file.
1 
7 #ifndef BOX_H
8 #define BOX_H
9 
10 namespace argos {
11  class CBox;
12  class CRay3;
13 }
14 
15 #include <argos3/core/utility/math/vector3.h>
16 #include <argos3/core/utility/math/quaternion.h>
17 
18 namespace argos {
19 
20  class CBox {
21 
22  public:
23 
24  CBox(const CVector3& c_size,
25  const CVector3& c_base_pos = CVector3(),
26  const CQuaternion& c_orient = CQuaternion()) :
27  m_cBasePos(c_base_pos),
28  m_cOrientation(c_orient) {
29  SetSize(c_size);
30  }
31 
32  inline const CVector3& GetSize() const {
33  return m_cSize;
34  }
35 
36  inline void SetSize(const CVector3& c_size) {
37  m_cSize = c_size;
38  m_cXBounds.Set(-m_cSize.GetX() * 0.5, m_cSize.GetX() * 0.5);
39  m_cYBounds.Set(-m_cSize.GetY() * 0.5, m_cSize.GetY() * 0.5);
40  m_cZBounds.Set(0.0, m_cSize.GetZ());
41  }
42 
43  inline const CVector3& GetBasePosition() const {
44  return m_cBasePos;
45  }
46 
47  inline void SetBasePosition(const CVector3& c_base_pos) {
48  m_cBasePos = c_base_pos;
49  }
50 
51  inline const CQuaternion& GetOrientation() const {
52  return m_cOrientation;
53  }
54 
55  inline void SetOrientation(const CQuaternion& c_orient) {
56  m_cOrientation = c_orient;
57  }
58 
59  bool Intersects(Real& f_t_on_ray,
60  const CRay3& c_ray);
61 
62  private:
63 
64  CVector3 m_cSize;
65  CVector3 m_cBasePos;
66  CQuaternion m_cOrientation;
67  CRange<Real> m_cXBounds;
68  CRange<Real> m_cYBounds;
69  CRange<Real> m_cZBounds;
70 
71  };
72 }
73 
74 #endif
float Real
Collects all ARGoS code.
Definition: datatypes.h:39
The namespace containing all the ARGoS related code.
Definition: ci_actuator.h:12
bool Intersects(Real &f_t_on_ray, const CRay3 &c_ray)
Definition: box.cpp:9
const CVector3 & GetBasePosition() const
Definition: box.h:43
void SetOrientation(const CQuaternion &c_orient)
Definition: box.h:55
CBox(const CVector3 &c_size, const CVector3 &c_base_pos=CVector3(), const CQuaternion &c_orient=CQuaternion())
Definition: box.h:24
const CVector3 & GetSize() const
Definition: box.h:32
const CQuaternion & GetOrientation() const
Definition: box.h:51
void SetSize(const CVector3 &c_size)
Definition: box.h:36
void SetBasePosition(const CVector3 &c_base_pos)
Definition: box.h:47
void Set(const T &t_min, const T &t_max)
Definition: range.h:68
A 3D vector class.
Definition: vector3.h:31
Real GetX() const
Returns the x coordinate of this vector.
Definition: vector3.h:105
Real GetY() const
Returns the y coordinate of this vector.
Definition: vector3.h:121
Real GetZ() const
Returns the z coordinate of this vector.
Definition: vector3.h:137