45 lines
923 B
C++
45 lines
923 B
C++
#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];
|
|
}
|
|
|
|
Point Cuboid::low_pt() const {
|
|
return lowBound;
|
|
}
|
|
|
|
Point Cuboid::high_pt() const {
|
|
return highBound;
|
|
}
|
|
|
|
double Cuboid::length(unsigned dim) const {
|
|
assert(dim < 3);
|
|
return high(dim) - low(dim);
|
|
}
|
|
|
|
double Cuboid::volume() const {
|
|
return length(0) * length(1) * length(2);
|
|
}
|
|
|
|
bool Cuboid::is_empty() const {
|
|
return volume() < 1e-8;
|
|
}
|