Implemented quadrilaterals

This commit is contained in:
CJSatnarine
2024-07-10 16:03:08 -04:00
parent d3a981d2c8
commit 01eea95971
13 changed files with 636250 additions and 356107 deletions

15
aabb.h
View File

@@ -9,13 +9,17 @@ class aabb {
aabb() {} // The default AABB is empty, since intervals are empty by default.
aabb(const interval& x, const interval& y, const interval& z) : x(x), y(y), z(z) {}
aabb(const interval& x, const interval& y, const interval& z) : x(x), y(y), z(z) {
padToMinimums();
}
aabb(const point3& a, const point3& b) {
// Treat the two points a and b as extrema for the bounding box, so we don't require a particular minimum/maximum coordinate order.
x = (a[0] <= b[0]) ? interval(a[0], b[0]) : interval(b[0], a[0]);
y = (a[1] <= b[1]) ? interval(a[1], b[1]) : interval(b[1], a[1]);
z = (a[2] <= b[2]) ? interval(a[2], b[2]) : interval(b[2], a[2]);
padToMinimums();
}
aabb(const aabb& box0, const aabb& box1) {
@@ -64,6 +68,15 @@ class aabb {
}
static const aabb empty, universe;
private:
void padToMinimums() {
// Adjust the AABB so that no side is narrower than some delta, padding if necessary.
double delta = 0.001;
if (x.size() < delta) x = x.expand(delta);
if (y.size() < delta) y = y.expand(delta);
if (z.size() < delta) z = z.expand(delta);
}
};
const aabb aabb::empty = aabb(interval::empty, interval::empty, interval::empty);