AutoPas  3.0.0
Loading...
Searching...
No Matches
inBox.h
Go to the documentation of this file.
1
8#pragma once
9
10#include <array>
11#include <type_traits>
12
13namespace autopas::utils {
25template <typename T>
26bool inBox(const std::array<T, 3> &position, const std::array<T, 3> &low, const std::array<T, 3> &high) {
27 static_assert(std::is_floating_point<T>::value, "inBox assumes floating point types");
28
29 bool inBox = true;
30 for (int d = 0; d < 3; ++d) {
31 const bool isLargerThanLower = position[d] >= low[d];
32 const bool isSmallerThanHigher = position[d] < high[d];
33 inBox = inBox and isLargerThanLower and isSmallerThanHigher;
34 }
35 return inBox;
36}
37
49template <typename T>
50bool notInBox(const std::array<T, 3> &position, const std::array<T, 3> &low, const std::array<T, 3> &high) {
51 return not(inBox(position, low, high));
52}
53
66template <typename T>
67bool boxesOverlap(const std::array<T, 3> &boxALow, const std::array<T, 3> &boxAHigh, const std::array<T, 3> &boxBLow,
68 const std::array<T, 3> &boxBHigh) {
69 static_assert(std::is_floating_point_v<T>, "boxesOverlap assumes floating point types");
70
71 auto overlap1D = [&](size_t dim) { return boxAHigh[dim] > boxBLow[dim] and boxBHigh[dim] > boxALow[dim]; };
72
73 return overlap1D(0) and overlap1D(1) and overlap1D(2);
74}
75} // namespace autopas::utils
In this namespace some helper classes and functions can be found used inside of AutoPas.
Definition: namespaces.h:44
bool boxesOverlap(const std::array< T, 3 > &boxALow, const std::array< T, 3 > &boxAHigh, const std::array< T, 3 > &boxBLow, const std::array< T, 3 > &boxBHigh)
Checks if two boxes have overlap.
Definition: inBox.h:67
bool notInBox(const std::array< T, 3 > &position, const std::array< T, 3 > &low, const std::array< T, 3 > &high)
Checks if position is not inside of a box defined by low and high.
Definition: inBox.h:50
bool inBox(const std::array< T, 3 > &position, const std::array< T, 3 > &low, const std::array< T, 3 > &high)
Checks if position is inside of a box defined by low and high.
Definition: inBox.h:26