Jet  v1.3.3
bounding_box.h
Go to the documentation of this file.
1 // Copyright (c) 2018 Doyub Kim
2 //
3 // I am making my contributions/submissions to this project solely in my
4 // personal capacity and am not conveying any rights to any intellectual
5 // property of any third parties.
6 
7 #ifndef INCLUDE_JET_BOUNDING_BOX_H_
8 #define INCLUDE_JET_BOUNDING_BOX_H_
9 
10 #include <jet/vector.h>
11 
12 namespace jet {
13 
20 template <typename T, size_t N>
21 class BoundingBox {
22  public:
23  static_assert(
24  N > 0, "Size of static-sized box should be greater than zero.");
25 
27 
30 
33 
36 
38  BoundingBox(const VectorType& point1, const VectorType& point2);
39 
41  BoundingBox(const BoundingBox& other);
42 
43 
45  bool overlaps(const BoundingBox& other) const;
46 
48  bool contains(const VectorType& point) const;
49 
52 
54  T diagonalLength() const;
55 
58 
59 
61  void reset();
62 
64  void merge(const VectorType& point);
65 
67  void merge(const BoundingBox& other);
68 
72  void expand(T delta);
73 };
74 
75 } // namespace jet
76 
77 #include "detail/bounding_box-inl.h"
78 
79 #endif // INCLUDE_JET_BOUNDING_BOX_H_
jet::BoundingBox::BoundingBox
BoundingBox(const VectorType &point1, const VectorType &point2)
Constructs a box that tightly covers two points.
jet::BoundingBox::merge
void merge(const VectorType &point)
Merges this and other point.
jet::BoundingBox::lowerCorner
VectorType lowerCorner
Lower corner of the bounding box.
Definition: bounding_box.h:29
jet::BoundingBox::midPoint
VectorType midPoint() const
Returns the mid-point of this box.
jet::BoundingBox::overlaps
bool overlaps(const BoundingBox &other) const
Returns true of this box and other box overlaps.
jet::Vector
Generic statically-sized N-D vector class.
Definition: vector.h:31
jet::BoundingBox::BoundingBox
BoundingBox()
Default constructor.
jet::BoundingBox::diagonalLengthSquared
T diagonalLengthSquared() const
Returns squared diagonal length of this box.
jet
Definition: advection_solver2.h:18
jet::BoundingBox::reset
void reset()
Resets this box to initial state (min=infinite, max=-infinite).
jet::BoundingBox::merge
void merge(const BoundingBox &other)
Merges this and other boxes.
jet::BoundingBox::upperCorner
VectorType upperCorner
Upper corner of the bounding box.
Definition: bounding_box.h:32
jet::BoundingBox::expand
void expand(T delta)
jet::BoundingBox::BoundingBox
BoundingBox(const BoundingBox &other)
Constructs a box with other box instance.
jet::BoundingBox::diagonalLength
T diagonalLength() const
Returns diagonal length of this box.
jet::BoundingBox
Generic N-D axis-aligned bounding box class.
Definition: bounding_box.h:21
vector.h
jet::BoundingBox::contains
bool contains(const VectorType &point) const
Returns true if the input point is inside of this box.
jet::BoundingBox::VectorType
Vector< T, N > VectorType
Definition: bounding_box.h:24