Kanzi Framework  3.9.0
Kanzi Engine API
kanzi::Box Class Reference

Class for box volume. More...

#include <kanzi/core/math/box.hpp>

Public Member Functions

 Box ()
 Constructs an empty box. More...
 
 Box (Vector3 point)
 Constructs a box which contains a single point. More...
 
bool contains (Vector3 point) const
 Checks if the given point is inside the box. More...
 
bool contains (const Box &volume2) const
 Checks if box contains other box completely. More...
 
Box extendedBy (Vector3 point) const
 Returns a box extended to include a given point. More...
 
Vector3 getCenter () const
 Gets center of the box. More...
 
Vector3 getMaximumCorner () const
 Gets maximum corner of box. More...
 
Vector3 getMinimumCorner () const
 Gets minimum corner of box. More...
 
Vector3 getSize () const
 Gets size of box. More...
 
float getVolume () const
 Calculates the volume of the box. More...
 
bool isEmpty () const
 Indicates whether the box is empty. More...
 
bool isValid () const
 Indicates whether the box is valid. More...
 
Box translatedBy (Vector3 translation) const
 Translates a box. More...
 

Static Public Member Functions

static Box fromCenterAndSize (Vector3 center, Vector3 size)
 Creates a box from center and size. More...
 
static Box fromContainedPoints (Vector3 point1, Vector3 point2)
 Creates a box from two points. More...
 
static Box fromCornerAndSize (Vector3 minimumCorner, Vector3 size)
 Creates a box from a point and box size. More...
 
static Box fromCorners (Vector3 minimumCorner, Vector3 maximumCorner)
 Creates a box from minimum and maximum corners. More...
 

Friends

Box intersection (const Box &box1, const Box &box2)
 Calculates intersection of two boxes. More...
 
bool intersects (const Box &box1, const Box &box2)
 Checks if intersection of two given boxes is non-empty. More...
 
Box minimumBoundingBox (const Box &box1, const Box &box2)
 Calculates a minimum bounding box for given two boxes. More...
 
bool operator!= (const Box &box1, const Box &box2)
 Checks if two given boxes do not have equal corners. More...
 
bool operator== (const Box &box1, const Box &box2)
 Checks if two given box volumes have equal corners. More...
 

Detailed Description

Class for box volume.

Constructor & Destructor Documentation

◆ Box() [1/2]

kanzi::Box::Box ( )
inlineexplicit

Constructs an empty box.

Note
The box will contain (0, 0, 0).

◆ Box() [2/2]

kanzi::Box::Box ( Vector3  point)
inlineexplicit

Constructs a box which contains a single point.

Parameters
pointPoint for box to contain.

Member Function Documentation

◆ fromContainedPoints()

static Box kanzi::Box::fromContainedPoints ( Vector3  point1,
Vector3  point2 
)
static

Creates a box from two points.

The box will contain the given two points.

Parameters
point1First point.
point2Second point.
Returns
Box which contains both of the given points.

◆ fromCornerAndSize()

static Box kanzi::Box::fromCornerAndSize ( Vector3  minimumCorner,
Vector3  size 
)
static

Creates a box from a point and box size.

Parameters
minimumCornerMinimum corner point for the box.
sizeSize for the box.
Returns
Box which has a specified minimumCorner and size.

◆ fromCenterAndSize()

static Box kanzi::Box::fromCenterAndSize ( Vector3  center,
Vector3  size 
)
static

Creates a box from center and size.

Parameters
centerCenter for the box.
sizeSize for the box.
Returns
Box which has specified center and size.

◆ fromCorners()

static Box kanzi::Box::fromCorners ( Vector3  minimumCorner,
Vector3  maximumCorner 
)
static

Creates a box from minimum and maximum corners.

Parameters
minimumCornerMinimum corner for the box.
maximumCornerMaximum corner for the box.
Returns
Box which has specified minimum and maximum corners.

◆ extendedBy()

Box kanzi::Box::extendedBy ( Vector3  point) const
inline

Returns a box extended to include a given point.

Parameters
pointPoint to be included in the box.
Returns
Box extended with given point.

◆ getMinimumCorner()

Vector3 kanzi::Box::getMinimumCorner ( ) const
inline

Gets minimum corner of box.

Returns
Minimum corner of the box.

◆ getMaximumCorner()

Vector3 kanzi::Box::getMaximumCorner ( ) const
inline

Gets maximum corner of box.

Returns
Maximum corner of the box.

◆ getCenter()

Vector3 kanzi::Box::getCenter ( ) const
inline

Gets center of the box.

Returns
Center of the box.

◆ getSize()

Vector3 kanzi::Box::getSize ( ) const
inline

Gets size of box.

Returns
Size of the box.

◆ isEmpty()

bool kanzi::Box::isEmpty ( ) const
inline

Indicates whether the box is empty.

Returns
true if box is empty, false if box is not empty.

◆ isValid()

bool kanzi::Box::isValid ( ) const
inline

Indicates whether the box is valid.

Box is valid when minimum corner is componentwise less or equal to maximum corner.

Returns
true if minimum corner is componentwise less or equal to maximum corner, otherwise false.

◆ contains() [1/2]

bool kanzi::Box::contains ( Vector3  point) const
inline

Checks if the given point is inside the box.

Note
The box is considered closed from minimum corner (left/right) but open from maximum corner (right/bottom).
Parameters
pointPoint to check to be in the box.
Returns
true if given point was in the box, otherwise false.

◆ contains() [2/2]

bool kanzi::Box::contains ( const Box volume2) const
inline

Checks if box contains other box completely.

Parameters
volume2Other box to test
Returns
true if volume2 is completely inside this box.

◆ getVolume()

float kanzi::Box::getVolume ( ) const
inline

Calculates the volume of the box.

Returns
Volume of the box.

◆ translatedBy()

Box kanzi::Box::translatedBy ( Vector3  translation) const
inline

Translates a box.

Parameters
translationTranslation amount.

Friends And Related Function Documentation

◆ intersects

bool intersects ( const Box box1,
const Box box2 
)
friend

Checks if intersection of two given boxes is non-empty.

Parameters
box1First box.
box2Second box.
Returns
true if intersection of two given boxes is non-empty, otherwise false.

◆ operator==

bool operator== ( const Box box1,
const Box box2 
)
friend

Checks if two given box volumes have equal corners.

Parameters
box1First box volume.
box2Second box volume.
Returns
true if given boxes have equal corners.

◆ operator!=

bool operator!= ( const Box box1,
const Box box2 
)
friend

Checks if two given boxes do not have equal corners.

Parameters
box1First box.
box2Second box.
Returns
true if given boxes do not have equal corners.

◆ minimumBoundingBox

Box minimumBoundingBox ( const Box box1,
const Box box2 
)
friend

Calculates a minimum bounding box for given two boxes.

Parameters
box1First box.
box2Second box.
Returns
Minimum bounding box for given two boxes.

◆ intersection

Box intersection ( const Box box1,
const Box box2 
)
friend

Calculates intersection of two boxes.

Parameters
box1First box.
box2Second box.
Returns
Intersection of two given boxes.

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