Jet  v1.3.3
bounding_box3.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_BOX3_H_
8 #define INCLUDE_JET_BOUNDING_BOX3_H_
9 
10 #include <jet/bounding_box.h>
11 #include <jet/ray3.h>
12 #include <jet/vector3.h>
13 #include <limits>
14 
15 namespace jet {
16 
22 template <typename T>
25  bool isIntersecting = false;
26 
29 
32 };
33 
40 template <typename T>
41 class BoundingBox<T, 3> {
42  public:
45 
48 
51 
53  BoundingBox(const Vector3<T>& point1, const Vector3<T>& point2);
54 
56  BoundingBox(const BoundingBox& other);
57 
59  T width() const;
60 
62  T height() const;
63 
65  T depth() const;
66 
68  T length(size_t axis);
69 
71  bool overlaps(const BoundingBox& other) const;
72 
74  bool contains(const Vector3<T>& point) const;
75 
77  bool intersects(const Ray3<T>& ray) const;
78 
84  const Ray3<T>& ray) const;
85 
88 
90  T diagonalLength() const;
91 
94 
96  void reset();
97 
99  void merge(const Vector3<T>& point);
100 
102  void merge(const BoundingBox& other);
103 
107  void expand(T delta);
108 
110  Vector3<T> corner(size_t idx) const;
111 
113  Vector3<T> clamp(const Vector3<T>& point) const;
114 
116  bool isEmpty() const;
117 };
118 
120 template <typename T>
122 
125 
128 
131 
134 
135 } // namespace jet
136 
137 #include "detail/bounding_box3-inl.h"
138 
139 #endif // INCLUDE_JET_BOUNDING_BOX3_H_
jet::BoundingBox< T, 3 >::height
T height() const
Returns height of the box.
jet::BoundingBox< T, 3 >::width
T width() const
Returns width of the box.
jet::BoundingBox< T, 3 >::expand
void expand(T delta)
jet::BoundingBox< T, 3 >::upperCorner
Vector3< T > upperCorner
Upper corner of the bounding box.
Definition: bounding_box3.h:47
jet::max
Point2< T > max(const Point2< T > &a, const Point2< T > &b)
Returns element-wise max point: (max(a.x, b.x), max(a.y, b.y)).
jet::BoundingBoxRayIntersection3::tNear
T tNear
Distance to the first intersection point.
Definition: bounding_box3.h:28
jet::BoundingBox< T, 3 >::depth
T depth() const
Returns depth of the box.
jet::BoundingBox< T, 3 >::length
T length(size_t axis)
Returns length of the box in given axis.
jet::BoundingBox< T, 3 >::diagonalLengthSquared
T diagonalLengthSquared() const
Returns squared diagonal length of this box.
jet::BoundingBox< T, 3 >
3-D axis-aligned bounding box class.
Definition: bounding_box3.h:41
jet::BoundingBox< T, 3 >::BoundingBox
BoundingBox(const Vector3< T > &point1, const Vector3< T > &point2)
Constructs a box that tightly covers two points.
jet::BoundingBoxRayIntersection3
3-D box-ray intersection result.
Definition: bounding_box3.h:23
bounding_box.h
jet::BoundingBox< T, 3 >::intersects
bool intersects(const Ray3< T > &ray) const
Returns true if the input ray is intersecting with this box.
jet::BoundingBox< T, 3 >::merge
void merge(const BoundingBox &other)
Merges this and other box.
jet
Definition: advection_solver2.h:18
jet::BoundingBox3D
BoundingBox3< double > BoundingBox3D
Double-type 3-D BoundingBox.
Definition: bounding_box3.h:127
jet::BoundingBox< T, 3 >::reset
void reset()
Resets this box to initial state (min=infinite, max=-infinite).
jet::BoundingBox< T, 3 >::BoundingBox
BoundingBox()
Default constructor.
ray3.h
jet::BoundingBox< T, 3 >::closestIntersection
BoundingBoxRayIntersection3< T > closestIntersection(const Ray3< T > &ray) const
jet::BoundingBox< T, 3 >::clamp
Vector3< T > clamp(const Vector3< T > &point) const
Returns the clamped point.
jet::BoundingBox< T, 3 >::overlaps
bool overlaps(const BoundingBox &other) const
Returns true of this box and other box overlaps.
jet::BoundingBox< T, 3 >::midPoint
Vector3< T > midPoint() const
Returns the mid-point of this box.
jet::BoundingBoxRayIntersection3::isIntersecting
bool isIntersecting
True if the box and ray intersects.
Definition: bounding_box3.h:25
jet::BoundingBoxRayIntersection3D
BoundingBoxRayIntersection3< double > BoundingBoxRayIntersection3D
Double-type 3-D box-ray intersection result.
Definition: bounding_box3.h:133
jet::BoundingBox< T, 3 >::BoundingBox
BoundingBox(const BoundingBox &other)
Constructs a box with other box instance.
jet::Ray< T, 3 >
Class for 2-D ray.
Definition: ray3.h:21
jet::BoundingBox
Generic N-D axis-aligned bounding box class.
Definition: bounding_box.h:21
jet::BoundingBox< T, 3 >::corner
Vector3< T > corner(size_t idx) const
Returns corner position. Index starts from x-first order.
vector3.h
jet::BoundingBox3F
BoundingBox3< float > BoundingBox3F
Float-type 3-D BoundingBox.
Definition: bounding_box3.h:124
jet::Vector< T, 3 >
3-D vector class.
Definition: vector3.h:25
jet::BoundingBox< T, 3 >::diagonalLength
T diagonalLength() const
Returns diagonal length of this box.
jet::BoundingBox< T, 3 >::lowerCorner
Vector3< T > lowerCorner
Lower corner of the bounding box.
Definition: bounding_box3.h:44
jet::BoundingBoxRayIntersection3::tFar
T tFar
Distance to the second (and the last) intersection point.
Definition: bounding_box3.h:31
jet::BoundingBoxRayIntersection3F
BoundingBoxRayIntersection3< float > BoundingBoxRayIntersection3F
Float-type 3-D box-ray intersection result.
Definition: bounding_box3.h:130
jet::BoundingBox< T, 3 >::isEmpty
bool isEmpty() const
Returns true if the box is empty.
jet::BoundingBox< T, 3 >::merge
void merge(const Vector3< T > &point)
Merges this and other point.
jet::BoundingBox< T, 3 >::contains
bool contains(const Vector3< T > &point) const
Returns true if the input vector is inside of this box.