vmath vmath-0.13

Public Member Functions | Public Attributes | Friends | List of all members
Aabb3< T > Class Template Reference

Axes-aligned bounding-box (aka AABB) class. More...

`#include <vmath.h>`

## Public Member Functions
| Aabb3 ()
| Constructs invalid axes-aligned bounding-box. More...
template<typename SrcT >
| Aabb3 (const Vector3< SrcT > &point)
| Constructs axes-aligned bound-box containing one point point. More...
template<typename SrcT >
| Aabb3 (SrcT x0, SrcT y0, SrcT z0, SrcT x1, SrcT y1, SrcT z1)
| Constructs axes-aligned bounding-box form two corner points (x0, y0, z0) and (x1, y1, z1) More...
template<typename SrcT >
| Aabb3 (SrcT x, SrcT y, SrcT z)
| Constructs axes-aligned bounding-box containing point (x, y, z) More...
template<typename SrcT >
| Aabb3 (const Aabb3< SrcT > &src)
| Creates copy of axis-aligned bounding-box. More...
template<typename SrcT >
Aabb3< T > & | operator= (const Aabb3< SrcT > &rhs)
| Assign operator. More...
bool | valid () const
| Checks if bounding-box is valid. More...
void | invalidate ()
| Makes this bounding-box invalid. More...
template<typename SrcT >
void | extend (const Vector3< SrcT > &point)
| Extends this bounding-box by a point point. More...
template<typename SrcT >
void | extend (const Aabb3< SrcT > &box)
| Extends this bounding-box by a box box. More...
template<typename SrcT >
Aabb3< T > | extended (const Vector3< SrcT > &point) const
| Gets a copy of this bounding-box extend by a point point. More...
template<typename SrcT >
Aabb3< T > | extended (const Aabb3< SrcT > &box) const
| Gets a copy of this bounding-box extnended by box box. More...
template<typename SrcT >
bool | intersects (const Vector3< SrcT > &point) const
| Tests if the point point is within this bounding-box. More...
template<typename SrcT >
bool | intersects (const Aabb3< SrcT > &box) const
| Tests if other bounding-box box intersects (even partially) with this bouding-box. More...
template<typename SrcT >
Aabb3< T > | intersection (const Aabb3< SrcT > &other) const
| Gets result of intersection of this bounding-box with other bounding-box. More...
Vector3< T > | center () const
| Gets center point of bounding-box. More...
Vector3< T > | extent () const
| Gets extent of bounding-box. More...
Vector3< T > | size () const
| Gets diagonal size of bounding-box. More...
Vector3< T > | point (size_t i) const
| Gets all 8 corner-points of bounding box. More...
Aabb3< T > | transformed (const Matrix4< T > &t) const
| Gets transformed bounding-box by transform t. More...
template<typename RhsT >
bool | operator== (const Aabb3< RhsT > &rhs) const
| Tests if rhs is equal to this bounding-box. More...
template<typename RhsT >
bool | operator!= (const Aabb3< RhsT > &rhs) const
| Tests if rhs is not equal to this bounding-box. More...
Aabb3< T > | operator* (const Matrix4< T > &rhs) const
| Gets transformed bounding-box by transform rhs. More...
Aabb3< T > & | operator*= (const Matrix4< T > &rhs)
| Apply transform rhs to this bounding-box. More...
template<typename SrcT >
Aabb3< T > & | operator<< (const Vector3< SrcT > &rhs)
| Extends this bounding-box by point rhs. More...
template<typename SrcT >
Aabb3< T > & | operator<< (const Aabb3< SrcT > &rhs)
| Extends this bounding-box by box rhs. More...
template<typename RhsT >
Aabb3< T > | operator| (const Aabb3< RhsT > &rhs) const
| Union of this and rhs bounding-boxes. More...
template<typename RhsT >
Aabb3< T > | operator & (const Aabb3< RhsT > &rhs) const
| Intersection of this and rhs bounding-boxed. More...

## Public Attributes
Vector3< T > | min
| Position of Min corner of bounding box. More...
Vector3< T > | max
| Position of Max corner of bounding box. More...

## Friends
std::ostream & | operator<< (std::ostream &lhs, const Aabb3< T > &rhs)
| Outputs string representation of bounding-box rhs to output stream lhs. More...

## Detailed Description

### template<typename T>
class Aabb3< T >

Axes-aligned bounding-box (aka AABB) class.

This class provides functionality for:

- creating AABB from point, or other AABB,
- testing if point of other AABB intersects with,
- getting result of intersection with other AABB,
- transforming AABB with 4x4 matrix.

There are also overloaded couple of operators to shorten common operation. For instance you can use `operator<<` on AABB to extend it with passed point or other AABB.

Aabb3f aabb;
aabb << Vector3f(1, 1, 2) << Aabb3f(-3,-3,-3, 2, 2, 2);

## Constructor & Destructor Documentation

## ◆ Aabb3() [1/5]

template<typename T>

Aabb3< T >::Aabb3 | ( |  | ) |
| inline

Constructs invalid axes-aligned bounding-box.

See also
  valid() for explanation of invalid bounding-box usage.

## ◆ Aabb3() [2/5]

template<typename T>
template<typename SrcT >

Aabb3< T >::Aabb3 | ( | const Vector3< SrcT > & | point | ) |
| inline

Constructs axes-aligned bound-box containing one point point.

Parameters

  point |

## ◆ Aabb3() [3/5]

template<typename T>
template<typename SrcT >

Aabb3< T >::Aabb3 | ( | SrcT | x0,
|  | SrcT | y0,
|  | SrcT | z0,
|  | SrcT | x1,
|  | SrcT | y1,
|  | SrcT | z1
| ) |  |
| inline

Constructs axes-aligned bounding-box form two corner points (x0, y0, z0) and (x1, y1, z1)

Parameters

  x0 | X-coordinate of first point
  y0 | Y-coordinate of first point
  z0 | Z-coordinate of first point
  x1 | X-coordinate of second point
  y1 | Y-coordinate of second point
  z1 | Z-coordinate of second point

## ◆ Aabb3() [4/5]

template<typename T>
template<typename SrcT >

Aabb3< T >::Aabb3 | ( | SrcT | x,
|  | SrcT | y,
|  | SrcT | z
| ) |  |
| inline

Constructs axes-aligned bounding-box containing point (x, y, z)

Parameters

  x | X-coordinate of point
  y | Y-coordinate of point
  z | Z-coordinate of point

## ◆ Aabb3() [5/5]

template<typename T>
template<typename SrcT >

Aabb3< T >::Aabb3 | ( | const Aabb3< SrcT > & | src | ) |
| inline

Creates copy of axis-aligned bounding-box.

Parameters

  src | Source bounding-box

## Member Function Documentation

## ◆ center()

template<typename T>

Vector3<T> Aabb3< T >::center | ( |  | ) | const
| inline

Gets center point of bounding-box.

Returns
  A center point of bounding-box.

## ◆ extend() [1/2]

template<typename T>
template<typename SrcT >

void Aabb3< T >::extend | ( | const Vector3< SrcT > & | point | ) |
| inline

Extends this bounding-box by a point point.

Parameters

  point | A point to extend bounding-box by.

## ◆ extend() [2/2]

template<typename T>
template<typename SrcT >

void Aabb3< T >::extend | ( | const Aabb3< SrcT > & | box | ) |
| inline

Extends this bounding-box by a box box.

Parameters

  box | A box to extend this bounding-box by.

## ◆ extended() [1/2]

template<typename T>
template<typename SrcT >

Aabb3<T> Aabb3< T >::extended | ( | const Vector3< SrcT > & | point | ) | const
| inline

Gets a copy of this bounding-box extend by a point point.

Parameters

  point | A point to extend the box by

Returns
  Copy of extended bounding-box

## ◆ extended() [2/2]

template<typename T>
template<typename SrcT >

Aabb3<T> Aabb3< T >::extended | ( | const Aabb3< SrcT > & | box | ) | const
| inline

Gets a copy of this bounding-box extnended by box box.

Parameters

  box | A box to extend the copy be.

Returns
  Copy of extended bounding-box

## ◆ extent()

template<typename T>

Vector3<T> Aabb3< T >::extent | ( |  | ) | const
| inline

Gets extent of bounding-box.

Returns
  Extent of bounding-box.

## ◆ intersection()

template<typename T>
template<typename SrcT >

Aabb3<T> Aabb3< T >::intersection | ( | const Aabb3< SrcT > & | other | ) | const
| inline

Gets result of intersection of this bounding-box with other bounding-box.

In case the boxes don't intersect, the returned bounding-box is invalid.

Parameters

  other | Box to be tested

Returns
  Result of intersection.

See also
  valid() method for more information on invalid bounding-boxes.

## ◆ intersects() [1/2]

template<typename T>
template<typename SrcT >

bool Aabb3< T >::intersects | ( | const Vector3< SrcT > & | point | ) | const
| inline

Tests if the point point is within this bounding-box.

Parameters

  point | A point to be tested

Returns
  True if point point lies within bounding-box, otherwise false.

## ◆ intersects() [2/2]

template<typename T>
template<typename SrcT >

bool Aabb3< T >::intersects | ( | const Aabb3< SrcT > & | box | ) | const
| inline

Tests if other bounding-box box intersects (even partially) with this bouding-box.

Parameters

  box | A box to be tested for intersection.

Returns
  True if there's intersection between boxes, otherwise false.

## ◆ invalidate()

template<typename T>

void Aabb3< T >::invalidate | ( |  | ) |
| inline

Makes this bounding-box invalid.

So calling valid() gets false.

See also
  valid() method for more info on usage of invalid bounding-boxes.

## ◆ operator &()

template<typename T>
template<typename RhsT >

Aabb3<T> Aabb3< T >::operator& | ( | const Aabb3< RhsT > & | rhs | ) | const
| inline

Intersection of this and rhs bounding-boxed.

Parameters

  rhs | Right-hand side

Returns
  Resulting bouding-box representing the intersection.

## ◆ operator!=()

template<typename T>
template<typename RhsT >

bool Aabb3< T >::operator!= | ( | const Aabb3< RhsT > & | rhs | ) | const
| inline

Tests if rhs is not equal to this bounding-box.

Parameters

  rhs | Right-hand side

Returns
  True if rhs and this bounding-boxes are not equal, otherwise false

## ◆ operator*()

template<typename T>

Aabb3<T> Aabb3< T >::operator* | ( | const Matrix4< T > & | rhs | ) | const
| inline

Gets transformed bounding-box by transform rhs.

Parameters

  rhs | Matrix 4x4 representing the transform

Returns
  Transformed bounding-box

## ◆ operator*=()

template<typename T>

Aabb3<T>& Aabb3< T >::operator*= | ( | const Matrix4< T > & | rhs | ) |
| inline

Apply transform rhs to this bounding-box.

Parameters

  rhs | A transform to be applied

Returns
  Reference to this

## ◆ operator<<() [1/2]

template<typename T>
template<typename SrcT >

Aabb3<T>& Aabb3< T >::operator<< | ( | const Vector3< SrcT > & | rhs | ) |
| inline

Extends this bounding-box by point rhs.

Parameters

  rhs | A point to extend this bounding-box by

Returns
  Reference to this

## ◆ operator<<() [2/2]

template<typename T>
template<typename SrcT >

Aabb3<T>& Aabb3< T >::operator<< | ( | const Aabb3< SrcT > & | rhs | ) |
| inline

Extends this bounding-box by box rhs.

Parameters

  rhs | A box to extend this bounding-box by

Returns
  Reference to this

## ◆ operator=()

template<typename T>
template<typename SrcT >

Aabb3<T>& Aabb3< T >::operator= | ( | const Aabb3< SrcT > & | rhs | ) |
| inline

Assign operator.

Parameters

  rhs | source bounding-box

Returns
  refenrence to this

## ◆ operator==()

template<typename T>
template<typename RhsT >

bool Aabb3< T >::operator== | ( | const Aabb3< RhsT > & | rhs | ) | const
| inline

Tests if rhs is equal to this bounding-box.

Parameters

  rhs | Right-hand side

Returns
  True if rhs and this bounding-boxes are equal, otherwise false

## ◆ operator|()

template<typename T>
template<typename RhsT >

Aabb3<T> Aabb3< T >::operator| | ( | const Aabb3< RhsT > & | rhs | ) | const
| inline

Union of this and rhs bounding-boxes.

Parameters

  rhs | Right-hand side of union

Returns
  A resulting bounding-box representing union

## ◆ point()

template<typename T>

Vector3<T> Aabb3< T >::point | ( | size_t | i | ) | const
| inline

Gets all 8 corner-points of bounding box.

Parameters

  i | An index of bounding-box corner point. Valid values are 0 .. 7.

Returns
  A position of i-th corner-point.

Note
  The order of points is as follows (where `+` denotes max-point and `-` min-point):
  1. (`+` `+` `+`)
  2. (`-` `+` `+`)
  3. (`+` `-` `+`)
  4. (`-` `-` `+`)
  5. (`+` `+` `-`)
  6. (`-` `+` `-`)
  7. (`+` `-` `-`)
  8. (`-` `-` `-`)

## ◆ size()

template<typename T>

Vector3<T> Aabb3< T >::size | ( |  | ) | const
| inline

Gets diagonal size of bounding-box.

Returns
  Sizes for particular dimensions.

## ◆ transformed()

template<typename T>

Aabb3<T> Aabb3< T >::transformed | ( | const Matrix4< T > & | t | ) | const
| inline

Gets transformed bounding-box by transform t.

Parameters

  t | A transform matrix

Returns
  Transformed bounding-box

## ◆ valid()

template<typename T>

bool Aabb3< T >::valid | ( |  | ) | const
| inline

Checks if bounding-box is valid.

Valid bounding-box has non-negative size. If an invalid bounding-box is extended by point or another bounding-box, the target bounding box becomes valid and contains solely the source point or bounding-box respectively.

Returns
  True if box is valid, otherwise false

## Friends And Related Function Documentation

## ◆ operator<<

template<typename T>

std::ostream& operator<< | ( | std::ostream & | lhs,
|  | const Aabb3< T > & | rhs
| ) |  |
| friend

Outputs string representation of bounding-box rhs to output stream lhs.

Parameters

  lhs | Output stream to write to
  rhs | Bounding-box to write to output stream.

Returns
  Reference to output stream lhs

## Member Data Documentation

## ◆ max

template<typename T>

Vector3<T> Aabb3< T >::max

Position of Max corner of bounding box.

## ◆ min

template<typename T>

Vector3<T> Aabb3< T >::min

Position of Min corner of bounding box.

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

- src/vmath.h