Sceneview
 All Classes Functions Variables Enumerations Enumerator Groups Pages
axis_aligned_box.hpp
1 // Copyright [2015] Albert Huang
2 
3 #ifndef SCENEVIEW_AXIS_ALIGNED_BOX_HPP__
4 #define SCENEVIEW_AXIS_ALIGNED_BOX_HPP__
5 
6 #include <QVector3D>
7 
8 namespace sv {
9 
18  public:
26 
30  AxisAlignedBox(const QVector3D& min, const QVector3D& max);
31 
35  void SetBounds(const QVector3D& min, const QVector3D& max);
36 
40  void IncludePoint(const QVector3D& point);
41 
45  void IncludeBox(const AxisAlignedBox& other);
46 
51  bool Valid() const;
52 
56  const QVector3D& Min() const { return min_; }
57 
61  const QVector3D& Max() const { return max_; }
62 
66  AxisAlignedBox Transformed(const QMatrix4x4& transform) const;
67 
73  AxisAlignedBox Intersection(const AxisAlignedBox& other) const;
74 
78  bool Intersects(const AxisAlignedBox& other) const;
79 
83  bool operator==(const AxisAlignedBox& other) const;
84 
85  bool operator!=(const AxisAlignedBox& other) const {
86  return !(*this == other); }
87 
91  QString ToString() const;
92 
93  private:
94  QVector3D min_;
95  QVector3D max_;
96 };
97 
98 } // namespace sv
99 
100 #endif // SCENEVIEW_AXIS_ALIGNED_BOUNDING_BOX_HPP__
const QVector3D & Min() const
Returns the box corner with lowest coordinates.
Definition: axis_aligned_box.hpp:56
AxisAlignedBox()
Constructs an invalid box.
An axis-aligned box typically used for bounding box and intersection calculations.
Definition: axis_aligned_box.hpp:17
bool Intersects(const AxisAlignedBox &other) const
Check if this box intersects with another.
QString ToString() const
For debugging.
const QVector3D & Max() const
Returns the box corner with greatest coordinates.
Definition: axis_aligned_box.hpp:61
bool operator==(const AxisAlignedBox &other) const
Check if this box is identical to another.
void IncludeBox(const AxisAlignedBox &other)
Modifies the box to fully contain the specified other box.
bool Valid() const
Check if the box is valid or not.
void IncludePoint(const QVector3D &point)
Modifies the box to contain the specified point.
void SetBounds(const QVector3D &min, const QVector3D &max)
Manually set the box extents.
AxisAlignedBox Intersection(const AxisAlignedBox &other) const
Computes the intersection of this box with another.
AxisAlignedBox Transformed(const QMatrix4x4 &transform) const
Transforms and axis-aligns the corners of this box.