template<class S>
nCine::Primitives::AABB class

Axis-aligned bounding box in a two-dimensional space.

Stored as the left, top, right and bottom edges (L, T, R, B). Provides width and height accessors, center, extents and perimeter queries, containment and overlap tests, intersection and combination of two boxes, and translation by a Vector2.

Public static functions

static auto Intersect(const AABB<S>& a, const AABB<S>& b) -> AABB<S>
Returns the intersection of two boxes, or an empty box if they do not overlap.
static auto Combine(const AABB<S>& a, const AABB<S>& b) -> AABB<S>
Returns the smallest box that contains both boxes.

Constructors, destructors, conversion operators

AABB() constexpr noexcept
AABB(NoInitT) explicit noexcept
AABB(S l, S t, S r, S b) constexpr noexcept
AABB(const Vector2<S>& min, const Vector2<S>& max) constexpr noexcept

Public functions

template<class U>
auto As() -> AABB<U> constexpr
Converts the bounding box to a different element type.
auto GetWidth() const -> S constexpr
Returns the width of the box.
auto GetHeight() const -> S constexpr
Returns the height of the box.
auto GetCenter() const -> Vector2<S>
Returns the center of the box.
auto GetExtents() const -> Vector2<S>
Returns the half-width and half-height of the box.
auto GetPerimeter() const -> S
Returns the perimeter of the box.
auto Contains(S px, S py) const -> bool
Returns true if the point is inside the box.
auto Contains(const Vector2<S>& p) const -> bool
Returns true if the point vector is inside the box.
auto Contains(const AABB<S>& aabb) const -> bool
Returns true if the other box is fully contained within this one.
auto Overlaps(const AABB<S>& aabb) const -> bool
Returns true if this box overlaps the other one in any way.
auto operator==(const AABB& aabb) const -> bool
auto operator!=(const AABB& aabb) const -> bool
auto operator+=(const Vector2<S>& v) -> AABB&
auto operator-=(const Vector2<S>& v) -> AABB&
auto operator+(const Vector2<S>& v) const -> AABB
auto operator-(const Vector2<S>& v) const -> AABB
auto Contains(std::int32_t px, std::int32_t py) const -> bool

Public variables

S L
Left edge X coordinate.
S T
Top edge Y coordinate.
S R
Right edge X coordinate.
S B
Bottom edge Y coordinate.