| TGX 1.1.2 A tiny 2D/3D graphics library optimized for 32 bits microcontrollers.

Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
tgx::Box3< T > Struct Template Reference

Generic 3D Box [specializations iBox3, fBox3, dBox3]. More...

`#include <Box3.h>`

## Public Member Functions
constexpr | Box3 ()
| default constructor: the box content is undefined.
constexpr | Box3 (const T minx, const T maxx, const T miny, const T maxy, const T minz, const T maxz)
| Constructor with explicit dimensions.
constexpr | Box3 (const Vec3< T > &v)
| Construct a box representing a single point.
| Box3 (const Box3< T > &B)=default
| default copy constructor.
Box3< T > & | operator= (const Box3< T > &B)=default
| default assignment operator.
template<typename U >
| operator Box3< U > () const
| Explicit conversion to another box type.
| operator Box3< typename DefaultFPType< T >::fptype > () const
| Implicit conversion to floating-point type.
constexpr bool | isEmpty () const
| Return true if the box is empty.
void | empty ()
| Make the box empty.
T | lx () const
| Return the box width. More...
T | ly () const
| Return the box height. More...
T | lz () const
| Return the box depth. More...
bool | equals (const Box3< T > &B) const
| Return true if the boxes are equal. More...
bool | operator== (const Box3< T > &B) const
| Return true if the boxes are equal. More...
bool | contains (const Vec3< T > &v) const
| Return true if the box contains the point v.
bool | contains (const Box3< T > &B) const
| Return true if B is included in this box. More...
bool | operator>= (const Box3< T > &B) const
| Return true if B is included in this box. More...
bool | operator<= (const Box3< T > &B) const
| Return true if this box is included in B. More...
bool | operator> (const Box3< T > &B) const
| Return true if B is strictly included in this box (i.e. More...
bool | operator< (const Box3< T > &B) const
| Return true if this box is strictly included inside B (i.e. More...
Box3< T > | operator& (const Box3< T > &B) const
| Return the intersection of this box and B. More...
void | operator&= (const Box3< T > &B)
| Intersect this box with box B. More...
Box3< T > | operator| (const Box3< T > &B) const
| Return the smallest box containing both this box and B.
void | operator|= (const Box3< T > &B)
| Enlarge this box in order to contain B.
Box3< T > | operator| (const Vec3< T > &v) const
| Return the smallest box containing this box and point v.
void | operator|= (const Vec3< T > &v)
| Enlarge this box in order to contain point v.
void | operator+= (const Vec3< T > &V)
| Translate this box by a given vector.
Box3< T > | operator+ (const Vec3< T > &V) const
| Return this box translated by v.
void | operator-= (const Vec3< T > &V)
| Translate the box by a given vector (substracted)
Box3< T > | operator- (const Vec3< T > &V) const
| Return this box translated by v (substracted).
Vec3< T > | center () const
| Return the position of the box center as a 3 dimensional vector.
void | zoomOut ()
| Zoom outside the box (ie increase its size by 1/10th). More...
void | zoomIn ()
| Zoom inside the box (ie decrease its size by 1/8th). More...
void | left ()
| Move the box to the left by 1/10th of its width. More...
void | right ()
| Move the box to the right by 1/10th of its width. More...
void | up ()
| Move the box up by 1/10th of its height. More...
void | down ()
| Move the box down by 1/10th of its height. More...
void | front ()
| Move the box front by 1/10th of its height. More...
void | back ()
| Move the box back by 1/10th of its height. More...

## Public Attributes
T | minX
| min horizontal (X) value (inclusive)
T | maxX
| max horizontal (X) value (inclusive)
T | minY
| min vertical (Y) value (inclusive)
T | maxY
| max vertical (Y) value (inclusive)
T | minZ
| min depth (Z) value (inclusive)
T | maxZ
| max depth (Z) value (inclusive)

## Detailed Description

template<typename T>
struct tgx::Box3< T >

Generic 3D Box [specializations iBox3, fBox3, dBox3].

The class encapsulates of 6 public variables: `minX`, `maxX`, `minY`, `maxY`, `minZ`, `maxZ` which delimit the 3 dimensional closed box: `[minX, maxX] x [minY, maxY] x [minZ, maxZ]`

The box is empty if `maxX` < `minX` or if `maxY` < `minY` or if `maxZ` < `minZ`.

Warning
  Some methods compute things differently depending whether T is an integral or a floating point value type.

Template Parameters

  T | arithmetic type of the box (`int`, `float`...)

See also
  `iBox3`,`fBox3`,`dBox3`

## Member Function Documentation

## ◆ lx()

template<typename T >

T tgx::Box3< T >::lx | ( |  | ) | const
| inline

Return the box width.

Warning
  The width is computed differently depending on whether `T` is of floating point or integral type.
  - If `T` is floating point, the method returns `maxX - minX`.
  - If `T` is integral, the method returns `maxX - minX + 1` (number of horizontal points in the closed box).

## ◆ ly()

template<typename T >

T tgx::Box3< T >::ly | ( |  | ) | const
| inline

Return the box height.

Warning
  The height is computed differently depending on whether `T` is of floating point or integral type.
  - If `T` is floating point, the method returns `maxY - minY`.
  - If `T` is integral, the method returns `maxY - minY + 1` (number of vertical points in the closed box).

## ◆ lz()

template<typename T >

T tgx::Box3< T >::lz | ( |  | ) | const
| inline

Return the box depth.

Warning
  The depth is computed differently depending on whether `T` is of floating point or integral type.
  - If `T` is floating point, the method returns `maxZ - minZ`.
  - If `T` is integral, the method returns `maxZ - minZ + 1` (number of vertical points in the closed box).

## ◆ equals()

template<typename T >

bool tgx::Box3< T >::equals | ( | const Box3< T > & | B | ) | const
| inline

Return true if the boxes are equal.

Note
  Two empty boxes always compare equal.

See also
  operator==()

## ◆ operator==()

template<typename T >

bool tgx::Box3< T >::operator== | ( | const Box3< T > & | B | ) | const
| inline

Return true if the boxes are equal.

Note
  Two empty boxes always compare equal.

See also
  equals()

## ◆ contains()

template<typename T >

bool tgx::Box3< T >::contains | ( | const Box3< T > & | B | ) | const
| inline

Return true if B is included in this box.

Note
  1. An empty box contains nothing.
  2. A non-empty box contains any empty box.

## ◆ operator>=()

template<typename T >

bool tgx::Box3< T >::operator>= | ( | const Box3< T > & | B | ) | const
| inline

Return true if B is included in this box.

Note
  1. An empty box contains nothing.
  2. A non-empty box contains any empty box.

See also
  contains()

## ◆ operator<=()

template<typename T >

bool tgx::Box3< T >::operator<= | ( | const Box3< T > & | B | ) | const
| inline

Return true if this box is included in B.

Note
  1. An empty box contains nothing.
  2. A non-empty box contains any empty box.

See also
  contains()

## ◆ operator>()

template<typename T >

bool tgx::Box3< T >::operator> | ( | const Box3< T > & | B | ) | const
| inline

Return true if B is strictly included in this box (i.e.

contained but not equal).

Note
  1. An empty box contains nothing.
  2. A non-empty box contains any empty box.

## ◆ operator<()

template<typename T >

bool tgx::Box3< T >::operator< | ( | const Box3< T > & | B | ) | const
| inline

Return true if this box is strictly included inside B (i.e.

contained but not equal).

Note
  1. An empty box contains nothing.
  2. A non-empty box contains any empty box.

## ◆ operator&()

template<typename T >

Box3< T > tgx::Box3< T >::operator& | ( | const Box3< T > & | B | ) | const
| inline

Return the intersection of this box and B.

This may return an empty box.

## ◆ operator&=()

template<typename T >

void tgx::Box3< T >::operator&= | ( | const Box3< T > & | B | ) |
| inline

Intersect this box with box B.

May create an empty box.

## ◆ zoomOut()

template<typename T >

void tgx::Box3< T >::zoomOut | ( |  | ) |
| inline

Zoom outside the box (ie increase its size by 1/10th).

See also
  zoomIn()

## ◆ zoomIn()

template<typename T >

void tgx::Box3< T >::zoomIn | ( |  | ) |
| inline

Zoom inside the box (ie decrease its size by 1/8th).

See also
  zoomOut()

## ◆ left()

template<typename T >

void tgx::Box3< T >::left | ( |  | ) |
| inline

Move the box to the left by 1/10th of its width.

See also
  up(),down(),right(),front(),back()

## ◆ right()

template<typename T >

void tgx::Box3< T >::right | ( |  | ) |
| inline

Move the box to the right by 1/10th of its width.

See also
  up(),down(),left(),front(),back()

## ◆ up()

template<typename T >

void tgx::Box3< T >::up | ( |  | ) |
| inline

Move the box up by 1/10th of its height.

See also
  down(),left(),right(),front(),back()

## ◆ down()

template<typename T >

void tgx::Box3< T >::down | ( |  | ) |
| inline

Move the box down by 1/10th of its height.

See also
  up(),left(),right(),front(),back()

## ◆ front()

template<typename T >

void tgx::Box3< T >::front | ( |  | ) |
| inline

Move the box front by 1/10th of its height.

See also
  up(),down(),left(),right(),back()

## ◆ back()

template<typename T >

void tgx::Box3< T >::back | ( |  | ) |
| inline

Move the box back by 1/10th of its height.

See also
  up(),down(),left(),right(),front()

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

- src/Box3.h