Rendu
A lightweight rendering engine for experimentations
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
BoundingBox Class Reference

Represent the smallest axis-aligne box containing a given object or region of space. More...

#include <Bounds.hpp>

Public Member Functions

 BoundingBox ()=default
 
 BoundingBox (const glm::vec3 &v0, const glm::vec3 &v1)
 
 BoundingBox (const glm::vec3 &v0, const glm::vec3 &v1, const glm::vec3 &v2)
 
void merge (const BoundingBox &box)
 
void merge (const glm::vec3 &point)
 
BoundingSphere getSphere () const
 
glm::vec3 getSize () const
 
std::vector< glm::vec3 > getCorners () const
 
std::vector< glm::vec4 > getHomogeneousCorners () const
 
glm::vec3 getCentroid () const
 
BoundingBox transformed (const glm::mat4 &trans) const
 
bool contains (const glm::vec3 &point) const
 
bool empty () const
 

Public Attributes

glm::vec3 minis = glm::vec3(std::numeric_limits<float>::max())
 Lower-back-left corner of the box.
 
glm::vec3 maxis = glm::vec3(std::numeric_limits<float>::lowest())
 Higher-top-right corner of the box.
 

Detailed Description

Represent the smallest axis-aligne box containing a given object or region of space.

Constructor & Destructor Documentation

◆ BoundingBox() [1/3]

BoundingBox::BoundingBox ( )
default

Empty box constructor.

◆ BoundingBox() [2/3]

BoundingBox::BoundingBox ( const glm::vec3 &  v0,
const glm::vec3 &  v1 
)

Corner-based box constructor.

Parameters
v0first corner
v1second corner

◆ BoundingBox() [3/3]

BoundingBox::BoundingBox ( const glm::vec3 &  v0,
const glm::vec3 &  v1,
const glm::vec3 &  v2 
)

Triangle-based box constructor.

Parameters
v0first triangle vertex
v1second triangle vertex
v2third triangle vertex

Member Function Documentation

◆ contains()

bool BoundingBox::contains ( const glm::vec3 &  point) const

Indicates if a point is inside the bounding box.

Parameters
pointthe point to check
Returns
true if the bounding box contains the point

◆ empty()

bool BoundingBox::empty ( ) const
Returns
true if no point has been added to the bounding box

◆ getCentroid()

glm::vec3 BoundingBox::getCentroid ( ) const

Query the center of the bounding box.

Returns
the centroid

◆ getCorners()

std::vector< glm::vec3 > BoundingBox::getCorners ( ) const

Query the positions of the eight corners of the box, in the following order (with m=mini, M=maxi): (m,m,m), (m,m,M), (m,M,m), (m,M,M), (M,m,m), (M,m,M), (M,M,m), (M,M,M)

Returns
a vector containing the box corners

◆ getHomogeneousCorners()

std::vector< glm::vec4 > BoundingBox::getHomogeneousCorners ( ) const

Query the homogeneous positions of the eight corners of the box, in the following order (with m=mini, M=maxi): (m,m,m,1), (m,m,M,1), (m,M,m,1), (m,M,M,1), (M,m,m,1), (M,m,M,1), (M,M,m,1), (M,M,M,1)

Returns
a vector containing the box corners

◆ getSize()

glm::vec3 BoundingBox::getSize ( ) const

Query the size of this box.

Returns
the size

◆ getSphere()

BoundingSphere BoundingBox::getSphere ( ) const

Query the bounding sphere of this box.

Returns
the bounding sphere

◆ merge() [1/2]

void BoundingBox::merge ( const BoundingBox box)

Extends the current box by another one. The result is the bounding box of the two boxes union.

Parameters
boxthe bounding box to include

◆ merge() [2/2]

void BoundingBox::merge ( const glm::vec3 &  point)

Extends the current box by a point

Parameters
pointthe point to include

◆ transformed()

BoundingBox BoundingBox::transformed ( const glm::mat4 &  trans) const

Compute the bounding box of the transformed current box.

Parameters
transthe transformation to apply
Returns
the bounding box of the transformed box

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