Avara3D 0.2.0
C++ API reference
AABB.h
1//
2// AABB.h
3// avara3d
4//
5// Created by Morgan Davis on 1/6/26.
6// Copyright © 2026 Morgan K Davis. All rights reserved.
7//
8
9#ifndef AVARA3D_MESH_AABB_H
10#define AVARA3D_MESH_AABB_H
11
12#include "a3d/Math.h"
13
14namespace a3d {
15
17 struct AABB {
18
19 // [Public Static Member Functions]
20
22 static AABB Zero();
23
25 static AABB Invalid();
26
28 static AABB Union(const AABB& a, const AABB& b);
29
31 static void Expand(AABB& a, const math::vec3& p);
32
34 static math::vec3 Center(const AABB& a);
35
36 // [Public Member Functions]
37
39 bool valid() const;
40
42 AABB& operator|=(const AABB& b);
43
46
47 // [Public Member Variables]
48
51 };
52
53 // [Public Non-Member Functions]
54
56 AABB operator|(AABB a, const AABB& b);
57
59 AABB operator|(AABB a, const math::vec3& p);
60
61}
62
63#endif // AVARA3D_MESH_AABB_H
Axis-aligned bounding box defined by minimum and maximum corners.
Definition: AABB.h:17
static void Expand(AABB &a, const math::vec3 &p)
Expands a to contain p, initializing invalid bounds to p.
static AABB Invalid()
Returns an invalid box suitable as an empty accumulation seed.
bool valid() const
Returns whether min is no greater than max on every axis.
static math::vec3 Center(const AABB &a)
Returns the midpoint between a.min and a.max.
AABB & operator|=(const AABB &b)
Expands this box to include b.
static AABB Union(const AABB &a, const AABB &b)
Returns the union of a and b, treating invalid bounds as empty.
math::vec3 max
Maximum corner.
Definition: AABB.h:50
static AABB Zero()
Returns a zero-size box at the origin.
AABB & operator|=(const math::vec3 &p)
Expands this box to include p.
math::vec3 min
Minimum corner.
Definition: AABB.h:49