27 lowerLeftCorner_m(
std::numeric_limits<double>::
max()),
28 upperRightCorner_m(
std::numeric_limits<double>::lowest())
34 for (
const Vector_t& position : positions) {
43 for (
unsigned int d = 0; d < 3; ++ d) {
51 for (
unsigned int d = 0; d < 3; ++ d) {
60 boost::optional<Vector_t> result = boost::none;
64 for (
unsigned int d = 0; d < 3; ++ d) {
68 double tau =
dot(p0 - position,
sign * normal) /
dot(direction,
sign * normal);
72 Vector_t pointOnPlane = position + tau * direction;
73 Vector_t relativeP = pointOnPlane - p0;
75 for (
unsigned int i = 1; i < 3; ++ i) {
76 unsigned int idx = (d + i) % 3;
77 if (relativeP[idx] < 0 ||
78 relativeP[idx] > dimensions[idx]) {
85 if (distance < minDistance) {
86 minDistance = distance;
87 result = pointOnPlane;
93 normal =
Vector_t(normal[2], normal[0], normal[1]);
103 for (
unsigned int d = 0; d < 3; ++ d) {
104 if (relPosition[d] < 0 || relPosition[d] > dimensions[d])
return false;
111 int prePrecision = output.precision();
112 output << std::setprecision(8);
113 output <<
"Bounding box\n"
double dot(const Vector3D &lhs, const Vector3D &rhs)
Vector dot product.
T euclidean_norm(const Vector< T > &)
Euclidean norm.
T::PETE_Expr_t::PETE_Return_t max(const PETE_Expr< T > &expr, NDIndex< D > &loc)
T::PETE_Expr_t::PETE_Return_t min(const PETE_Expr< T > &expr, NDIndex< D > &loc)
Inform & endl(Inform &inf)
void print(std::ostream &output) const
static BoundingBox getBoundingBox(const std::vector< Vector_t > &positions)
bool isInside(const Vector_t &position) const
Vector_t lowerLeftCorner_m
Vector_t upperRightCorner_m
boost::optional< Vector_t > getIntersectionPoint(const Vector_t &position, const Vector_t &direction) const
void enlargeToContainBoundingBox(const BoundingBox &boundingBox)
void enlargeToContainPosition(const Vector_t &position)
Vektor< double, 3 > Vector_t