9 #ifndef CUBBYFLOW_BOUNDING_BOX_IMPL_H 10 #define CUBBYFLOW_BOUNDING_BOX_IMPL_H 16 template <
typename T,
size_t N>
22 template <
typename T,
size_t N>
25 for (
size_t i = 0; i < N; ++i)
27 lowerCorner[i] = std::min(point1[i], point2[i]);
28 upperCorner[i] = std::max(point1[i], point2[i]);
32 template <
typename T,
size_t N>
34 lowerCorner(other.lowerCorner), upperCorner(other.upperCorner)
39 template <
typename T,
size_t N>
42 for (
size_t i = 0; i < N; ++i)
53 template <
typename T,
size_t N>
56 for (
size_t i = 0; i < N; ++i)
58 if (upperCorner[i] < point[i] || lowerCorner[i] > point[i])
67 template <
typename T,
size_t N>
72 for (
size_t i = 0; i < N; ++i)
74 result[i] = (upperCorner[i] + lowerCorner[i]) / 2;
80 template <
typename T,
size_t N>
85 for (
size_t i = 0; i < N; ++i)
87 result +=
Square(upperCorner[i] - lowerCorner[i]);
90 return std::sqrt(result);
93 template <
typename T,
size_t N>
98 for (
size_t i = 0; i < N; ++i)
100 result +=
Square(upperCorner[i] - lowerCorner[i]);
106 template <
typename T,
size_t N>
109 for (
size_t i = 0; i < N; ++i)
111 lowerCorner[i] = std::numeric_limits<T>::max();
112 upperCorner[i] = -std::numeric_limits<T>::max();
116 template <
typename T,
size_t N>
119 for (
size_t i = 0; i < N; ++i)
121 lowerCorner[i] = std::min(lowerCorner[i], point[i]);
122 upperCorner[i] = std::max(upperCorner[i], point[i]);
126 template <
typename T,
size_t N>
129 for (
size_t i = 0; i < N; ++i)
131 lowerCorner[i] = std::min(lowerCorner[i], other.
lowerCorner[i]);
132 upperCorner[i] = std::max(upperCorner[i], other.
upperCorner[i]);
136 template <
typename T,
size_t N>
139 for (
size_t i = 0; i < N; ++i)
141 lowerCorner[i] -= delta;
142 upperCorner[i] += delta;
VectorType upperCorner
Upper corner of the bounding box.
Definition: BoundingBox.h:34
bool Contains(const VectorType &point) const
Returns true if the input point is inside of this box.
Definition: BoundingBox-Impl.h:54
VectorType MidPoint() const
Returns the mid-point of this box.
Definition: BoundingBox-Impl.h:68
BoundingBox()
Default constructor.
Definition: BoundingBox-Impl.h:17
Generic N-D axis-aligned bounding box class.
Definition: BoundingBox.h:23
T Square(T x)
Returns the square of x.
Definition: MathUtils-Impl.h:111
void Reset()
Resets this box to initial state (min=infinite, max=-infinite).
Definition: BoundingBox-Impl.h:107
Generic statically-sized N-D vector class.
Definition: Vector.h:33
Definition: pybind11Utils.h:24
VectorType lowerCorner
Lower corner of the bounding box.
Definition: BoundingBox.h:31
T DiagonalLength() const
Returns diagonal length of this box.
Definition: BoundingBox-Impl.h:81
void Merge(const VectorType &point)
Merges this and other point.
Definition: BoundingBox-Impl.h:117
bool Overlaps(const BoundingBox &other) const
Returns true of this box and other box overlaps.
Definition: BoundingBox-Impl.h:40
void Expand(T delta)
Definition: BoundingBox-Impl.h:137
T DiagonalLengthSquared() const
Returns squared diagonal length of this box.
Definition: BoundingBox-Impl.h:94