2018-02-07 17:59:41 +01:00
|
|
|
#include "common_structures.hpp"
|
|
|
|
|
|
|
|
Cuboid::Cuboid(Point bd1, Point bd2)
|
|
|
|
: lowBound(0, 0, 0), highBound(0, 0, 0)
|
|
|
|
{
|
|
|
|
lowBound = Point(
|
|
|
|
std::min(bd1.x, bd2.x),
|
|
|
|
std::min(bd1.y, bd2.y),
|
|
|
|
std::min(bd1.z, bd2.z));
|
|
|
|
highBound = Point(
|
|
|
|
std::max(bd1.x, bd2.x),
|
|
|
|
std::max(bd1.y, bd2.y),
|
|
|
|
std::max(bd1.z, bd2.z));
|
|
|
|
}
|
|
|
|
|
|
|
|
double Cuboid::low(unsigned dim) const {
|
|
|
|
assert(dim < 3);
|
|
|
|
return lowBound[dim];
|
|
|
|
}
|
|
|
|
|
|
|
|
double Cuboid::high(unsigned dim) const {
|
|
|
|
assert(dim < 3);
|
|
|
|
return highBound[dim];
|
|
|
|
}
|
|
|
|
|
2018-02-13 18:43:02 +01:00
|
|
|
Point Cuboid::low_pt() const {
|
|
|
|
return lowBound;
|
|
|
|
}
|
|
|
|
|
|
|
|
Point Cuboid::high_pt() const {
|
|
|
|
return highBound;
|
|
|
|
}
|
|
|
|
|
2018-02-12 13:18:50 +01:00
|
|
|
double Cuboid::length(unsigned dim) const {
|
|
|
|
assert(dim < 3);
|
|
|
|
return high(dim) - low(dim);
|
|
|
|
}
|
|
|
|
|
2018-02-07 17:59:41 +01:00
|
|
|
double Cuboid::volume() const {
|
2018-02-12 13:18:50 +01:00
|
|
|
return length(0) * length(1) * length(2);
|
2018-02-07 17:59:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Cuboid::is_empty() const {
|
|
|
|
return volume() < 1e-8;
|
|
|
|
}
|