Mitsuba Renderer  0.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
mitsuba::TAABB< T > Struct Template Reference

Generic multi-dimensional bounding box data structure. More...

#include <mitsuba/core/aabb.h>

Public Types

typedef T PointType
 
typedef T::Scalar Scalar
 
typedef T::VectorType VectorType
 
typedef TRay< PointType,
VectorType
RayType
 

Public Member Functions

 TAABB ()
 Create a new invalid bounding box. More...
 
 TAABB (Stream *stream)
 Unserialize a bounding box from a binary data stream. More...
 
 TAABB (const PointType &p)
 Create a collapsed AABB from a single point. More...
 
 TAABB (const PointType &min, const PointType &max)
 Create a bounding box from two positions. More...
 
 TAABB (const TAABB &aabb)
 Copy constructor. More...
 
bool operator== (const TAABB &aabb) const
 Equality test. More...
 
bool operator!= (const TAABB &aabb) const
 Inequality test. More...
 
void clip (const TAABB &aabb)
 Clip to another bounding box. More...
 
void reset ()
 Mark the bounding box as invalid. More...
 
Scalar getVolume () const
 Calculate the n-dimensional volume of the bounding box. More...
 
Float getSurfaceArea () const
 Calculate the n-1 dimensional volume of the boundary. More...
 
PointType getCenter () const
 Return the center point. More...
 
PointType getCorner (int index) const
 Return the position of one of the corners (in 0..2^dim-1) More...
 
TAABB getChild (int index) const
 Return a child bounding box in a interval-, quad-, octree, etc. More...
 
bool contains (const PointType &p) const
 Check whether a point lies on or inside the bounding box. More...
 
bool contains (const TAABB &aabb) const
 Check whether a given bounding box is contained within this one. More...
 
bool overlaps (const TAABB &aabb) const
 Axis-aligned bounding box overlap test. More...
 
void expandBy (const PointType &p)
 Expand the bounding box to contain another point. More...
 
void expandBy (const TAABB &aabb)
 Expand the bounding box to contain another bounding box. More...
 
Scalar squaredDistanceTo (const PointType &p) const
 Calculate the squared point-AABB distance. More...
 
Scalar distanceTo (const PointType &p) const
 Calculate the point-AABB distance. More...
 
Scalar squaredDistanceTo (const TAABB &aabb) const
 Calculate the minimum squared AABB-AABB distance. More...
 
Scalar distanceTo (const TAABB &aabb) const
 Calculate the minimum AABB-AABB distance. More...
 
bool isValid () const
 Return whether this bounding box is valid. More...
 
bool isEmpty () const
 Return whether or not this bounding box covers anything at all. More...
 
int getLargestAxis () const
 Return the axis index with the largest associated side length. More...
 
int getShortestAxis () const
 Return the axis index with the shortest associated side length. More...
 
VectorType getExtents () const
 Calculate the bounding box extents. More...
 
FINLINE bool rayIntersect (const RayType &ray, Float &nearT, Float &farT) const
 Calculate the near and far ray-AABB intersection points (if they exist). More...
 
FINLINE bool rayIntersect (const RayType &ray, Float &nearT, Float &farT, PointType &near, PointType &far) const
 Calculate the overlap between an axis-aligned bounding box and a ray segment. More...
 
void serialize (Stream *stream) const
 Serialize this bounding box to a binary data stream. More...
 
std::string toString () const
 Return a string representation of the bounding box. More...
 

Public Attributes

PointType min
 Component-wise minimum. More...
 
PointType max
 Component-wise maximum. More...
 

Detailed Description

template<typename T>
struct mitsuba::TAABB< T >

Generic multi-dimensional bounding box data structure.

Maintains a component-wise minimum and maximum position and provides various convenience functions to query or change them.

Template Parameters
TUnderlying point data type (e.g. TPoint3<float>)

Member Typedef Documentation

template<typename T>
typedef T mitsuba::TAABB< T >::PointType
template<typename T>
typedef TRay<PointType, VectorType> mitsuba::TAABB< T >::RayType
template<typename T>
typedef T::Scalar mitsuba::TAABB< T >::Scalar
template<typename T>
typedef T::VectorType mitsuba::TAABB< T >::VectorType

Constructor & Destructor Documentation

template<typename T>
mitsuba::TAABB< T >::TAABB ( )
inline

Create a new invalid bounding box.

Initializes the components of the minimum and maximum position to \(\infty\) and \(-\infty\), respectively.

template<typename T>
mitsuba::TAABB< T >::TAABB ( Stream stream)
inline

Unserialize a bounding box from a binary data stream.

template<typename T>
mitsuba::TAABB< T >::TAABB ( const PointType p)
inline

Create a collapsed AABB from a single point.

template<typename T>
mitsuba::TAABB< T >::TAABB ( const PointType min,
const PointType max 
)
inline

Create a bounding box from two positions.

template<typename T>
mitsuba::TAABB< T >::TAABB ( const TAABB< T > &  aabb)
inline

Copy constructor.

Member Function Documentation

template<typename T>
void mitsuba::TAABB< T >::clip ( const TAABB< T > &  aabb)
inline

Clip to another bounding box.

template<typename T>
bool mitsuba::TAABB< T >::contains ( const PointType p) const
inline

Check whether a point lies on or inside the bounding box.

template<typename T>
bool mitsuba::TAABB< T >::contains ( const TAABB< T > &  aabb) const
inline

Check whether a given bounding box is contained within this one.

template<typename T>
Scalar mitsuba::TAABB< T >::distanceTo ( const PointType p) const
inline

Calculate the point-AABB distance.

template<typename T>
Scalar mitsuba::TAABB< T >::distanceTo ( const TAABB< T > &  aabb) const
inline

Calculate the minimum AABB-AABB distance.

template<typename T>
void mitsuba::TAABB< T >::expandBy ( const PointType p)
inline

Expand the bounding box to contain another point.

template<typename T>
void mitsuba::TAABB< T >::expandBy ( const TAABB< T > &  aabb)
inline

Expand the bounding box to contain another bounding box.

template<typename T>
PointType mitsuba::TAABB< T >::getCenter ( ) const
inline

Return the center point.

template<typename T>
TAABB mitsuba::TAABB< T >::getChild ( int  index) const
inline

Return a child bounding box in a interval-, quad-, octree, etc.

template<typename T>
PointType mitsuba::TAABB< T >::getCorner ( int  index) const
inline

Return the position of one of the corners (in 0..2^dim-1)

template<typename T>
VectorType mitsuba::TAABB< T >::getExtents ( ) const
inline

Calculate the bounding box extents.

Returns
max-min
template<typename T>
int mitsuba::TAABB< T >::getLargestAxis ( ) const
inline

Return the axis index with the largest associated side length.

template<typename T>
int mitsuba::TAABB< T >::getShortestAxis ( ) const
inline

Return the axis index with the shortest associated side length.

template<typename T>
Float mitsuba::TAABB< T >::getSurfaceArea ( ) const
inline

Calculate the n-1 dimensional volume of the boundary.

template<typename T>
Scalar mitsuba::TAABB< T >::getVolume ( ) const
inline

Calculate the n-dimensional volume of the bounding box.

template<typename T>
bool mitsuba::TAABB< T >::isEmpty ( ) const
inline

Return whether or not this bounding box covers anything at all.

A bounding box which only covers a single point is considered nonempty.

template<typename T>
bool mitsuba::TAABB< T >::isValid ( ) const
inline

Return whether this bounding box is valid.

template<typename T>
bool mitsuba::TAABB< T >::operator!= ( const TAABB< T > &  aabb) const
inline

Inequality test.

template<typename T>
bool mitsuba::TAABB< T >::operator== ( const TAABB< T > &  aabb) const
inline

Equality test.

template<typename T>
bool mitsuba::TAABB< T >::overlaps ( const TAABB< T > &  aabb) const
inline

Axis-aligned bounding box overlap test.

template<typename T>
FINLINE bool mitsuba::TAABB< T >::rayIntersect ( const RayType ray,
Float nearT,
Float farT 
) const
inline

Calculate the near and far ray-AABB intersection points (if they exist).

The parameters nearT and farT are used to return the ray distances to the intersections (including negative distances). Any previously contained value is overwritten, even if there was no intersection.

Remarks
In the Python bindings, this function returns the nearT and farT values as a tuple (or None, when no intersection was found)
template<typename T>
FINLINE bool mitsuba::TAABB< T >::rayIntersect ( const RayType ray,
Float nearT,
Float farT,
PointType near,
PointType far 
) const
inline

Calculate the overlap between an axis-aligned bounding box and a ray segment.

This function is an extended version of the simpler rayIntersect command provided above. The first change is that input values passed via the nearT and farT parameters are considered to specify a query interval.

This interval is intersected against the bounding box, returning the remaining interval using the nearT and farT parameters. Furthermore, the interval endpoints are also returned as 3D positions via the near and far parameters. Special care is taken to reduce round-off errors.

Remarks
In the Python bindings, this function has the signature (nearT, farT, near, far) = rayIntersect(ray, nearT, farT). It returns None when no intersection was found.
template<typename T>
void mitsuba::TAABB< T >::reset ( )
inline

Mark the bounding box as invalid.

This operation sets the components of the minimum and maximum position to \(\infty\) and \(-\infty\), respectively.

template<typename T>
void mitsuba::TAABB< T >::serialize ( Stream stream) const
inline

Serialize this bounding box to a binary data stream.

template<typename T>
Scalar mitsuba::TAABB< T >::squaredDistanceTo ( const PointType p) const
inline

Calculate the squared point-AABB distance.

template<typename T>
Scalar mitsuba::TAABB< T >::squaredDistanceTo ( const TAABB< T > &  aabb) const
inline

Calculate the minimum squared AABB-AABB distance.

template<typename T>
std::string mitsuba::TAABB< T >::toString ( ) const
inline

Return a string representation of the bounding box.

Member Data Documentation

template<typename T>
PointType mitsuba::TAABB< T >::max

Component-wise maximum.

template<typename T>
PointType mitsuba::TAABB< T >::min

Component-wise minimum.


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