Struct aabb_t

Struct Documentation

struct aabb_t

Simple axis-aligned bounding box (AABB) primitive.

Public Functions

aabb_t() noexcept = default
inline constexpr aabb_t(const pqvec3_t &min, const pqvec3_t &max) noexcept
inline explicit constexpr aabb_t(const pqvec3_t &v)
aabb_t(const aabb_t&) = default
aabb_t &operator=(const aabb_t&) = default
inline constexpr aabb_t operator|(const aabb_t &o) const noexcept

Union of two AABBs.

inline constexpr aabb_t &operator|=(const aabb_t &o) noexcept

Union of two AABBs.

inline constexpr aabb_t operator|(const pqvec3_t &p) const noexcept

Union of two AABBs.

inline constexpr aabb_t &operator|=(const pqvec3_t &p) noexcept

Union of two AABBs.

inline constexpr aabb_t operator&(const aabb_t &o) const noexcept

Intersection of two AABBs.

inline constexpr aabb_t &operator&=(const aabb_t &o) noexcept

Intersection of two AABBs.

inline constexpr bool operator==(const aabb_t&) const noexcept = default
inline constexpr bool empty() const noexcept
inline constexpr bool isfinite() const noexcept
inline constexpr bool overlaps(const aabb_t &o) const noexcept

Checks for overlaps between AABBs.

template<range_inclusiveness_e incl = range_inclusiveness_e::left_inclusive>
inline constexpr bool contains(const pqvec3_t &p) const noexcept

Returns TRUE if p is inside the AABB. Template argument incl handles inclusivity on the AABB faces.

inline constexpr bool contains(const aabb_t &aabb) const noexcept

Returns TRUE if this AABB contains aabb.

inline constexpr pqvec3_t closest_point(const pqvec3_t &p) const noexcept

Returns the closest point in the AABB, or on its faces, to the point p.

inline auto distance2(const pqvec3_t &p) const noexcept

Returns the distance squared from the AABB to the point p.

inline auto distance(const pqvec3_t &p) const noexcept

Returns the distance from the AABB to the point p.

inline constexpr auto volume() const noexcept
inline constexpr auto surface_area() const noexcept
inline constexpr auto surface_area(const dir3_t &dir) const noexcept

Area of the AABB projected upon a plane with normal dir.

inline constexpr auto centre() const noexcept
inline constexpr auto extent() const noexcept
inline constexpr int max_dimension() const noexcept

returns the axis of the AABB that is the longest (0, 1, 2 for x, y, z respectively)

inline constexpr auto grow(const length_t extent) const noexcept
inline constexpr auto grow(const pqvec3_t &extent) const noexcept
inline std::pair<aabb_t, aabb_t> split(int axis, length_t P) const noexcept

Splits the AABB along dimension axis at plane p (in world coordinates).

inline auto vertex(int vid) const noexcept

Returns one of the 8 AABB vertices.

Public Members

pqvec3_t min
pqvec3_t max

Public Static Functions

static inline auto face_normal(int face) noexcept
static inline constexpr aabb_t inf() noexcept
static inline constexpr aabb_t null() noexcept
static inline constexpr aabb_t clamp(const aabb_t &aabb) noexcept
static inline constexpr aabb_t from_points(const std::convertible_to<pqvec3_t> auto&... pts)