playrho::detail::AABB< N > Struct Template Reference

N-dimensional Axis Aligned Bounding Box. More...

#include <AABB.hpp>

Public Types

using Location = Vector< Length, N >
 Alias for the location type. More...
 

Public Member Functions

PLAYRHO_CONSTEXPR AABB ()=default
 Default constructor. More...
 
template<typename... Tail>
PLAYRHO_CONSTEXPR AABB (std::enable_if_t< sizeof...(Tail)+1==N, LengthInterval > head, Tail... tail) noexcept
 Initializing constructor. More...
 
PLAYRHO_CONSTEXPR AABB (const Location p) noexcept
 Initializing constructor for a single point. More...
 
PLAYRHO_CONSTEXPR AABB (const Location a, const Location b) noexcept
 Initializing constructor for two points. More...
 

Public Attributes

LengthInterval ranges [N]
 Holds the value range of each dimension from 0 to N-1. More...
 

Related Functions

(Note that these are not member functions.)

template<std::size_t N>
PLAYRHO_CONSTEXPR bool operator== (const AABB< N > &lhs, const AABB< N > &rhs) noexcept
 Gets whether the two AABB objects are equal. More...
 
template<std::size_t N>
PLAYRHO_CONSTEXPR bool operator!= (const AABB< N > &lhs, const AABB< N > &rhs) noexcept
 Gets whether the two AABB objects are not equal. More...
 
template<std::size_t N>
bool operator< (const AABB< N > &lhs, const AABB< N > &rhs) noexcept
 Less-than operator. More...
 
template<std::size_t N>
bool operator<= (const AABB< N > &lhs, const AABB< N > &rhs) noexcept
 Less-than or equal-to operator. More...
 
template<std::size_t N>
bool operator> (const AABB< N > &lhs, const AABB< N > &rhs) noexcept
 Greater-than operator. More...
 
template<std::size_t N>
bool operator>= (const AABB< N > &lhs, const AABB< N > &rhs) noexcept
 Greater-than or equal-to operator. More...
 
template<std::size_t N>
PLAYRHO_CONSTEXPR bool TestOverlap (const AABB< N > &a, const AABB< N > &b) noexcept
 Tests for overlap between two axis aligned bounding boxes. More...
 
template<std::size_t N>
PLAYRHO_CONSTEXPR Vector< Length, N > GetCenter (const AABB< N > &aabb) noexcept
 Gets the center of the AABB. More...
 
template<std::size_t N>
PLAYRHO_CONSTEXPR Vector< Length, N > GetDimensions (const AABB< N > &aabb) noexcept
 Gets dimensions of the given AABB. More...
 
template<std::size_t N>
PLAYRHO_CONSTEXPR Vector< Length, N > GetExtents (const AABB< N > &aabb) noexcept
 Gets the extents of the AABB (half-widths). More...
 
template<std::size_t N>
PLAYRHO_CONSTEXPR bool Contains (const AABB< N > &a, const AABB< N > &b) noexcept
 Checks whether the first AABB fully contains the second AABB. More...
 
template<std::size_t N>
PLAYRHO_CONSTEXPR AABB< N > & Include (AABB< N > &var, const Vector< Length, N > &value) noexcept
 Includes the given location into the given AABB. More...
 
template<std::size_t N>
PLAYRHO_CONSTEXPR AABB< N > & Include (AABB< N > &var, const AABB< N > &val) noexcept
 Includes the second AABB into the first one. More...
 
template<std::size_t N>
PLAYRHO_CONSTEXPR AABB< N > & Fatten (AABB< N > &var, const NonNegative< Length > amount) noexcept
 Fattens an AABB by the given amount. More...
 
template<std::size_t N>
PLAYRHO_CONSTEXPR AABB< N > GetDisplacedAABB (AABB< N > aabb, const Vector< Length, N > displacement)
 Gets the AABB that the result of displacing the given AABB by the given displacement amount. More...
 
template<std::size_t N>
PLAYRHO_CONSTEXPR AABB< N > GetFattenedAABB (AABB< N > aabb, const Length amount)
 Gets the fattened AABB result. More...
 
template<std::size_t N>
PLAYRHO_CONSTEXPR AABB< N > GetMovedAABB (AABB< N > aabb, const Vector< Length, N > value) noexcept
 Gets the result of moving the given AABB by the given value. More...
 
template<std::size_t N>
PLAYRHO_CONSTEXPR AABB< N > GetEnclosingAABB (AABB< N > a, const AABB< N > &b)
 Gets the AABB that minimally encloses the given AABBs. More...
 
template<std::size_t N>
PLAYRHO_CONSTEXPR Vector< Length, N > GetLowerBound (const AABB< N > &aabb) noexcept
 Gets the lower bound. More...
 
template<std::size_t N>
PLAYRHO_CONSTEXPR Vector< Length, N > GetUpperBound (const AABB< N > &aabb) noexcept
 Gets the upper bound. More...
 
PLAYRHO_CONSTEXPR Length GetPerimeter (const AABB &aabb) noexcept
 Gets the perimeter length of the 2-dimensional AABB. More...
 
template<>
PLAYRHO_CONSTEXPR d2::AABB GetInvalid () noexcept
 Gets an invalid AABB value. More...
 

Detailed Description

template<std::size_t N>
struct playrho::detail::AABB< N >

N-dimensional Axis Aligned Bounding Box.

This is a concrete value class template for an N-dimensional axis aligned bounding box (AABB) which is a type of bounding volume.

Note
This class satisfies at least the following concepts: all the basic concepts, EqualityComparable, and Swappable.
This class is composed of — as in contains and owns — N LengthInterval variables.
Non-defaulted methods of this class are marked noexcept and expect that the Length type doesn't throw.
See also
https://en.wikipedia.org/wiki/Bounding_volume
http://en.cppreference.com/w/cpp/concept

Definition at line 57 of file AABB.hpp.

Member Typedef Documentation

◆ Location

template<std::size_t N>
using playrho::detail::AABB< N >::Location = Vector<Length, N>

Alias for the location type.

Definition at line 60 of file AABB.hpp.

Constructor & Destructor Documentation

◆ AABB() [1/4]

template<std::size_t N>
PLAYRHO_CONSTEXPR playrho::detail::AABB< N >::AABB ( )
inlinedefault

Default constructor.

Constructs an "unset" AABB.

Note
If an unset AABB is added to another AABB, the result will be the other AABB.

◆ AABB() [2/4]

template<std::size_t N>
template<typename... Tail>
PLAYRHO_CONSTEXPR playrho::detail::AABB< N >::AABB ( std::enable_if_t< sizeof...(Tail)+1==N, LengthInterval >  head,
Tail...  tail 
)
inlinenoexcept

Initializing constructor.

Initializing constructor supporting construction by the same number of elements as this AABB template type is defined for.

Note
For example this enables a 2-dimensional AABB to be constructed as:
const auto aabb = AABB<2>{LengthInterval{1_m, 4_m}, LengthInterval{-3_m, 3_m}};

Definition at line 75 of file AABB.hpp.

◆ AABB() [3/4]

template<std::size_t N>
PLAYRHO_CONSTEXPR playrho::detail::AABB< N >::AABB ( const Location  p)
inlineexplicitnoexcept

Initializing constructor for a single point.

Parameters
pPoint location to initialize this AABB with.
Postcondition
rangeX will have its min and max values both set to the given point's X value.
rangeY will have its min and max values both set to the given point's Y value.

Definition at line 88 of file AABB.hpp.

◆ AABB() [4/4]

template<std::size_t N>
PLAYRHO_CONSTEXPR playrho::detail::AABB< N >::AABB ( const Location  a,
const Location  b 
)
inlinenoexcept

Initializing constructor for two points.

Parameters
aPoint location "A" to initialize this AABB with.
bPoint location "B" to initialize this AABB with.

Definition at line 99 of file AABB.hpp.

Friends And Related Function Documentation

◆ operator==()

template<std::size_t N>
PLAYRHO_CONSTEXPR bool operator== ( const AABB< N > &  lhs,
const AABB< N > &  rhs 
)
related

Gets whether the two AABB objects are equal.

Returns
true if the two values are equal, false otherwise.

Definition at line 115 of file AABB.hpp.

◆ operator!=()

template<std::size_t N>
PLAYRHO_CONSTEXPR bool operator!= ( const AABB< N > &  lhs,
const AABB< N > &  rhs 
)
related

Gets whether the two AABB objects are not equal.

Returns
true if the two values are not equal, false otherwise.

Definition at line 131 of file AABB.hpp.

◆ operator<()

template<std::size_t N>
bool operator< ( const AABB< N > &  lhs,
const AABB< N > &  rhs 
)
related

Less-than operator.

Definition at line 139 of file AABB.hpp.

◆ operator<=()

template<std::size_t N>
bool operator<= ( const AABB< N > &  lhs,
const AABB< N > &  rhs 
)
related

Less-than or equal-to operator.

Definition at line 149 of file AABB.hpp.

◆ operator>()

template<std::size_t N>
bool operator> ( const AABB< N > &  lhs,
const AABB< N > &  rhs 
)
related

Greater-than operator.

Definition at line 161 of file AABB.hpp.

◆ operator>=()

template<std::size_t N>
bool operator>= ( const AABB< N > &  lhs,
const AABB< N > &  rhs 
)
related

Greater-than or equal-to operator.

Definition at line 171 of file AABB.hpp.

◆ TestOverlap()

template<std::size_t N>
PLAYRHO_CONSTEXPR bool TestOverlap ( const AABB< N > &  a,
const AABB< N > &  b 
)
related

Tests for overlap between two axis aligned bounding boxes.

Note
This function's complexity is constant.
Examples
World.cpp.

Definition at line 184 of file AABB.hpp.

◆ GetCenter()

template<std::size_t N>
PLAYRHO_CONSTEXPR Vector< Length, N > GetCenter ( const AABB< N > &  aabb)
related

Gets the center of the AABB.

Definition at line 211 of file AABB.hpp.

◆ GetDimensions()

template<std::size_t N>
PLAYRHO_CONSTEXPR Vector< Length, N > GetDimensions ( const AABB< N > &  aabb)
related

Gets dimensions of the given AABB.

Definition at line 224 of file AABB.hpp.

◆ GetExtents()

template<std::size_t N>
PLAYRHO_CONSTEXPR Vector< Length, N > GetExtents ( const AABB< N > &  aabb)
related

Gets the extents of the AABB (half-widths).

Definition at line 237 of file AABB.hpp.

◆ Contains()

template<std::size_t N>
PLAYRHO_CONSTEXPR bool Contains ( const AABB< N > &  a,
const AABB< N > &  b 
)
related

Checks whether the first AABB fully contains the second AABB.

Whether the first AABB contains the entirety of the second AABB where containment is defined as being equal-to or within an AABB.

Note
The "unset" AABB is contained by all valid AABBs including the "unset" AABB itself.
Parameters
aAABB to test whether it contains the second AABB.
bAABB to test whether it's contained by the first AABB.

Definition at line 252 of file AABB.hpp.

◆ Include() [1/2]

template<std::size_t N>
PLAYRHO_CONSTEXPR AABB< N > & Include ( AABB< N > &  var,
const Vector< Length, N > &  value 
)
related

Includes the given location into the given AABB.

Examples
World.cpp.

Definition at line 267 of file AABB.hpp.

◆ Include() [2/2]

template<std::size_t N>
PLAYRHO_CONSTEXPR AABB< N > & Include ( AABB< N > &  var,
const AABB< N > &  val 
)
related

Includes the second AABB into the first one.

Note
If an unset AABB is added to the first AABB, the result will be the first AABB.
If the first AABB is unset and another AABB is added to it, the result will be the other AABB.

Definition at line 282 of file AABB.hpp.

◆ Fatten()

template<std::size_t N>
PLAYRHO_CONSTEXPR AABB< N > & Fatten ( AABB< N > &  var,
const NonNegative< Length amount 
)
related

Fattens an AABB by the given amount.

Definition at line 305 of file AABB.hpp.

◆ GetDisplacedAABB()

template<std::size_t N>
PLAYRHO_CONSTEXPR AABB< N > GetDisplacedAABB ( AABB< N >  aabb,
const Vector< Length, N >  displacement 
)
related

Gets the AABB that the result of displacing the given AABB by the given displacement amount.

Definition at line 318 of file AABB.hpp.

◆ GetFattenedAABB()

template<std::size_t N>
PLAYRHO_CONSTEXPR AABB< N > GetFattenedAABB ( AABB< N >  aabb,
const Length  amount 
)
related

Gets the fattened AABB result.

Definition at line 330 of file AABB.hpp.

◆ GetMovedAABB()

template<std::size_t N>
PLAYRHO_CONSTEXPR AABB< N > GetMovedAABB ( AABB< N >  aabb,
const Vector< Length, N >  value 
)
related

Gets the result of moving the given AABB by the given value.

Definition at line 338 of file AABB.hpp.

◆ GetEnclosingAABB()

template<std::size_t N>
PLAYRHO_CONSTEXPR AABB< N > GetEnclosingAABB ( AABB< N >  a,
const AABB< N > &  b 
)
related

Gets the AABB that minimally encloses the given AABBs.

Definition at line 346 of file AABB.hpp.

◆ GetLowerBound()

template<std::size_t N>
PLAYRHO_CONSTEXPR Vector< Length, N > GetLowerBound ( const AABB< N > &  aabb)
related

Gets the lower bound.

Definition at line 354 of file AABB.hpp.

◆ GetUpperBound()

template<std::size_t N>
PLAYRHO_CONSTEXPR Vector< Length, N > GetUpperBound ( const AABB< N > &  aabb)
related

Gets the upper bound.

Definition at line 367 of file AABB.hpp.

◆ GetPerimeter()

template<std::size_t N>
PLAYRHO_CONSTEXPR Length GetPerimeter ( const AABB< N > &  aabb)
related

Gets the perimeter length of the 2-dimensional AABB.

Warning
Behavior is undefined for an invalid AABB.
Returns
Twice the sum of the width and height.
See also
https://en.wikipedia.org/wiki/Perimeter

Definition at line 422 of file AABB.hpp.

◆ GetInvalid()

PLAYRHO_CONSTEXPR d2::AABB GetInvalid ( )
related

Gets an invalid AABB value.

Definition at line 483 of file AABB.hpp.

Member Data Documentation

◆ ranges

template<std::size_t N>
LengthInterval playrho::detail::AABB< N >::ranges[N]

Holds the value range of each dimension from 0 to N-1.

Definition at line 108 of file AABB.hpp.


The documentation for this struct was generated from the following file: