25#include <olp/core/math/Vector.h>
42 int IntegerBits = std::is_integral<T>::value ?
sizeof(T) * 8 : 0,
43 bool IsSigned = std::numeric_limits<T>::is_signed>
97template <
typename T,
unsigned int N>
101 static const unsigned int numCorners = 1 <<
N;
103 static const unsigned int dimensions =
N;
143 template <
typename OtherT>
301 template <
typename U,
unsigned int X>
312bool CheckAddOperationOverflow(
T a,
T b) {
313 return ((
a > 0) && (
b > 0) && (
a > (std::numeric_limits<T>::max() -
b))) ||
314 ((
a < 0) && (
b < 0) && (
a < (std::numeric_limits<T>::min() -
b)));
320 AlignedBox<double, 3>;
322template <
typename T,
unsigned int N>
327template <
typename T,
unsigned int N>
328template <
typename OtherT>
330 : minimum_(
other.min()), maximum_(
other.max()) {}
332template <
typename T,
unsigned int N>
334 : minimum_(min), maximum_(max) {}
336template <
typename T,
unsigned int N>
338 minimum_ =
VectorType(std::numeric_limits<T>::max());
339 maximum_ =
VectorType(std::numeric_limits<T>::lowest());
342template <
typename T,
unsigned int N>
348template <
typename T,
unsigned int N>
352 if (std::numeric_limits<OverflowType>::is_integer &&
354 for (
unsigned dim = 0;
dim < dimensions; ++
dim) {
369template <
typename T,
unsigned int N>
375template <
typename T,
unsigned int N>
377 return Empty() ?
VectorType(0) : maximum_ - minimum_;
380template <
typename T,
unsigned int N>
385template <
typename T,
unsigned int N>
390template <
typename T,
unsigned int N>
396 for (
unsigned dim = 0;
dim < dimensions;
dim++) {
405template <
typename T,
unsigned int N>
411 for (
unsigned dim = 0;
dim < dimensions; ++
dim) {
421template <
typename T,
unsigned int N>
429 for (
unsigned dim = 0;
dim < dimensions;
dim++) {
437template <
typename T,
unsigned int N>
442template <
typename T,
unsigned int N>
445 for (
unsigned dim = 0;
dim < dimensions;
dim++) {
458template <
typename T,
unsigned int N>
470 return minimum_ ==
box.Minimum() && maximum_ ==
box.Maximum();
473template <
typename T,
unsigned int N>
475 return !(*
this ==
box);
The aligned bounding-box implementation.
Definition AlignedBox.h:98
ValueType Distance(const VectorType &point) const
Computes the distance from a point to the box.
Definition AlignedBox.h:438
bool Intersects(const AlignedBox &box) const
Tests whether the box intersects another box.
Definition AlignedBox.h:422
bool operator==(const AlignedBox &box) const
Checks whether two boxes are equal.
Definition AlignedBox.h:459
ValueType Distance2(const VectorType &point) const
Computes the squared distance from a point to the box.
Definition AlignedBox.h:443
VectorType Center() const
Gets the center point of the box.
Definition AlignedBox.h:349
typename OverflowTrait< T >::Type OverflowType
An alias for the overflow trait.
Definition AlignedBox.h:108
bool Empty() const
Tests whether the box is empty.
Definition AlignedBox.h:370
const VectorType & Minimum() const
Gets the box minimum corner point.
Definition AlignedBox.h:381
void Reset()
Resets the box to empty.
Definition AlignedBox.h:337
bool operator!=(const AlignedBox &box) const
Checks whether two boxes are not equal.
Definition AlignedBox.h:474
typename std::array< VectorType, numCorners > CornerArrayType
An alias for the corner points array type.
Definition AlignedBox.h:117
VectorType Size() const
Gets the size of the box.
Definition AlignedBox.h:376
Vector< ValueType, N > VectorType
An alias for the vector type of the box.
Definition AlignedBox.h:110
bool Contains(const VectorType &point, T epsilon=T()) const
Tests whether the box contains a point.
Definition AlignedBox.h:391
CornerArrayType Corners() const
Gets the corner points of the box.
const VectorType & Maximum() const
Gets the box maximum corner point.
Definition AlignedBox.h:386
VectorType NearestPoint(const VectorType &point) const
Computes the nearest point on the box to a point.
Rules all the other namespaces.
Definition AppleSignInProperties.h:24
Maps an integer type to the one that can handle arithmetic overflows.
Definition AlignedBox.h:44
Represents 3D vectors and points.
Definition Vector.h:86
Vector3< bool > LessThan(Vector3< T > const &v) const
Checks whether the parameters of one vector are less than the parameters of the other vector.
Definition Vector.h:142
T z
The Z component of the vector.
Definition Vector.h:151
T y
The Y component of the vector.
Definition Vector.h:149
T x
The X component of the vector.
Definition Vector.h:147