Visualization Library 2.0.0

A lightweight C++ OpenGL middleware for 2D/3D graphics

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
Public Member Functions | Protected Attributes | List of all members
vl::AABB Class Reference

The AABB class implements an axis-aligned bounding box using vl::real precision. More...

#include <AABB.hpp>

Public Member Functions

 AABB ()
 Constructs a null AABB. More...
 
 AABB (const vec3 &center, real radius)
 Constructs an AABB large enough to contain a sphere with the specified radius and center. More...
 
 AABB (const vec3 &pt1, const vec3 &pt2, real displace=0)
 Constructs an AABB large enough to contain the two specified points and enlarged by the amount specified by displace. More...
 
void setNull ()
 Sets ths AABB as null, that is, empty. More...
 
bool isNull () const
 Returns true if the AABB is null. More...
 
bool isPoint () const
 Returns true if the AABB contains a single point, that is, if the min and max corners of the AABB are equal. More...
 
void enlarge (real displace)
 Enlarges the AABB in all directions by displace amount. More...
 
bool intersects (const AABB &bb) const
 Returns true if an AABB intersects with the given AABB. More...
 
vec3 clip (const vec3 &p, bool clipx=true, bool clipy=true, bool clipz=true) const
 Clips the position of the given p point to be inside an AABB. More...
 
bool isInside (const vec3 &p, bool clipx, bool clipy, bool clipz) const
 Returns true if the given point is inside the AABB. More...
 
bool isInside (const vec3 &p) const
 Returns true if the given point is inside the AABB. More...
 
real width () const
 Returns the width of the AABB computed as max.x - min.x. More...
 
real height () const
 Returns the height of the AABB computed as max.y - min.y. More...
 
real depth () const
 Returns the depth of the AABB computed as max.z - min.z. More...
 
bool operator== (const AABB &aabb) const
 Returns true if two AABB are identical. More...
 
bool operator!= (const AABB &aabb) const
 Returns true if two AABB are not identical. More...
 
AABB operator+ (const AABB &aabb) const
 Returns an AABB which contains the two source AABB. More...
 
AABBoperator+= (const AABB &other)
 Enlarges (if necessary) an AABB so that it contains the given AABB. More...
 
AABB operator+ (const vec3 &p)
 Returns an AABB which contains the source AABB and the given point. More...
 
const AABBoperator+= (const vec3 &p)
 Enlarges (if necessary) an AABB to contain the given point. More...
 
vec3 center () const
 Returns the center of the AABB. More...
 
real longestSideLength () const
 Returns the longest dimension of the AABB. More...
 
void addPoint (const vec3 &p, real radius)
 Updates the AABB to contain the given point. More...
 
void addPoint (const vec3 &p)
 Updates the AABB to contain the given point. More...
 
void transformed (AABB &out, const mat4 &mat) const
 Transforms an AABB by the given matrix and returns it into the out parameter. More...
 
AABB transformed (const mat4 &mat) const
 Returns the AABB transformed by the given matrix. More...
 
const vec3minCorner () const
 Returns the corner of the AABB with the minimum x y z coordinates. More...
 
const vec3maxCorner () const
 Returns the corner of the AABB with the maximum x y z coordinates. More...
 
void setMinCorner (real x, real y, real z)
 Sets the corner of the AABB with the minimum x y z coordinates. More...
 
void setMinCorner (const vec3 &v)
 Sets the corner of the AABB with the minimum x y z coordinates. More...
 
void setMaxCorner (real x, real y, real z)
 Sets the corner of the AABB with the maximum x y z coordinates. More...
 
void setMaxCorner (const vec3 &v)
 Sets the corner of the AABB with the maximum x y z coordinates. More...
 
real volume () const
 Returns the volume of the AABB. More...
 

Protected Attributes

vec3 mMin
 
vec3 mMax
 

Detailed Description

The AABB class implements an axis-aligned bounding box using vl::real precision.

Definition at line 44 of file AABB.hpp.

Constructor & Destructor Documentation

◆ AABB() [1/3]

AABB::AABB ( )

Constructs a null AABB.

Definition at line 39 of file AABB.cpp.

References setNull().

◆ AABB() [2/3]

AABB::AABB ( const vec3 center,
real  radius 
)

Constructs an AABB large enough to contain a sphere with the specified radius and center.

Definition at line 44 of file AABB.cpp.

References mMax, and mMin.

◆ AABB() [3/3]

AABB::AABB ( const vec3 pt1,
const vec3 pt2,
real  displace = 0 
)

Constructs an AABB large enough to contain the two specified points and enlarged by the amount specified by displace.

Definition at line 50 of file AABB.cpp.

References mMax, mMin, vl::Vector3< T_Scalar >::x(), vl::Vector3< T_Scalar >::y(), and vl::Vector3< T_Scalar >::z().

Member Function Documentation

◆ addPoint() [1/2]

void AABB::addPoint ( const vec3 p,
real  radius 
)

◆ addPoint() [2/2]

void vl::AABB::addPoint ( const vec3 p)
inline

Updates the AABB to contain the given point.

Definition at line 147 of file AABB.hpp.

References vl::Vector3< T_Scalar >::x(), vl::Vector3< T_Scalar >::y(), and vl::Vector3< T_Scalar >::z().

◆ center()

vec3 AABB::center ( ) const

◆ clip()

vec3 AABB::clip ( const vec3 p,
bool  clipx = true,
bool  clipy = true,
bool  clipz = true 
) const

Clips the position of the given p point to be inside an AABB.

Definition at line 92 of file AABB.cpp.

References isNull(), mMax, mMin, vl::Vector3< T_Scalar >::x(), vl::Vector3< T_Scalar >::y(), and vl::Vector3< T_Scalar >::z().

Referenced by isInside().

◆ depth()

real AABB::depth ( ) const

Returns the depth of the AABB computed as max.z - min.z.

Definition at line 165 of file AABB.cpp.

References isNull(), mMax, mMin, and vl::Vector3< T_Scalar >::z().

◆ enlarge()

void AABB::enlarge ( real  displace)

Enlarges the AABB in all directions by displace amount.

As a result every edge of the AABB will be displace*2 longer.

Definition at line 64 of file AABB.cpp.

References isNull(), mMax, and mMin.

◆ height()

real AABB::height ( ) const

Returns the height of the AABB computed as max.y - min.y.

Definition at line 158 of file AABB.cpp.

References isNull(), mMax, mMin, and vl::Vector3< T_Scalar >::y().

Referenced by vl::Text::boundingRect(), vl::CoreText::boundingRect(), vl::PixelLODEvaluator::evaluate(), and vl::VectorGraphics::popScissor().

◆ intersects()

bool AABB::intersects ( const AABB bb) const

Returns true if an AABB intersects with the given AABB.

Definition at line 72 of file AABB.cpp.

References isNull(), mMax, mMin, vl::Vector3< T_Scalar >::x(), and vl::Vector3< T_Scalar >::z().

◆ isInside() [1/2]

bool AABB::isInside ( const vec3 p,
bool  clipx,
bool  clipy,
bool  clipz 
) const

Returns true if the given point is inside the AABB.

This method allows you to restrict the test to any of the x, y, z axes.

Definition at line 122 of file AABB.cpp.

References clip().

Referenced by vl::OcclusionCullRenderer::render_pass2().

◆ isInside() [2/2]

bool AABB::isInside ( const vec3 p) const

Returns true if the given point is inside the AABB.

Definition at line 128 of file AABB.cpp.

References maxCorner(), minCorner(), vl::Vector3< T_Scalar >::x(), vl::Vector3< T_Scalar >::y(), and vl::Vector3< T_Scalar >::z().

◆ isNull()

bool vl::AABB::isNull ( ) const
inline

◆ isPoint()

bool vl::AABB::isPoint ( ) const
inline

Returns true if the AABB contains a single point, that is, if the min and max corners of the AABB are equal.

Definition at line 63 of file AABB.hpp.

◆ longestSideLength()

real vl::AABB::longestSideLength ( ) const
inline

Returns the longest dimension of the AABB.

Definition at line 132 of file AABB.hpp.

◆ maxCorner()

const vec3& vl::AABB::maxCorner ( ) const
inline

◆ minCorner()

const vec3& vl::AABB::minCorner ( ) const
inline

◆ operator!=()

bool vl::AABB::operator!= ( const AABB aabb) const
inline

Returns true if two AABB are not identical.

Definition at line 98 of file AABB.hpp.

References vl::operator+(), and vl::operator==().

◆ operator+() [1/2]

AABB AABB::operator+ ( const AABB aabb) const

Returns an AABB which contains the two source AABB.

Definition at line 172 of file AABB.cpp.

References addPoint(), isNull(), mMax, and mMin.

◆ operator+() [2/2]

AABB vl::AABB::operator+ ( const vec3 p)
inline

Returns an AABB which contains the source AABB and the given point.

Definition at line 114 of file AABB.hpp.

◆ operator+=() [1/2]

AABB& vl::AABB::operator+= ( const AABB other)
inline

Enlarges (if necessary) an AABB so that it contains the given AABB.

Definition at line 107 of file AABB.hpp.

◆ operator+=() [2/2]

const AABB& vl::AABB::operator+= ( const vec3 p)
inline

Enlarges (if necessary) an AABB to contain the given point.

Definition at line 122 of file AABB.hpp.

◆ operator==()

bool vl::AABB::operator== ( const AABB aabb) const
inline

Returns true if two AABB are identical.

Definition at line 92 of file AABB.hpp.

References mMax, and mMin.

◆ setMaxCorner() [1/2]

void vl::AABB::setMaxCorner ( real  x,
real  y,
real  z 
)
inline

Sets the corner of the AABB with the maximum x y z coordinates.

Definition at line 202 of file AABB.hpp.

Referenced by vl::Text::boundingRect(), vl::CoreText::boundingRect(), vlX::import_AABB(), vl::Terrain::init(), and vl::CoreText::renderText().

◆ setMaxCorner() [2/2]

void vl::AABB::setMaxCorner ( const vec3 v)
inline

Sets the corner of the AABB with the maximum x y z coordinates.

Definition at line 205 of file AABB.hpp.

◆ setMinCorner() [1/2]

void vl::AABB::setMinCorner ( real  x,
real  y,
real  z 
)
inline

Sets the corner of the AABB with the minimum x y z coordinates.

Definition at line 196 of file AABB.hpp.

Referenced by vl::Text::boundingRect(), vl::CoreText::boundingRect(), vlX::import_AABB(), and vl::Terrain::init().

◆ setMinCorner() [2/2]

void vl::AABB::setMinCorner ( const vec3 v)
inline

Sets the corner of the AABB with the minimum x y z coordinates.

Definition at line 199 of file AABB.hpp.

◆ setNull()

void vl::AABB::setNull ( )
inline

◆ transformed() [1/2]

void vl::AABB::transformed ( AABB out,
const mat4 mat 
) const
inline

Transforms an AABB by the given matrix and returns it into the out parameter.

Definition at line 165 of file AABB.hpp.

References addPoint(), and setNull().

Referenced by vl::Actor::computeBounds(), and vl::PixelLODEvaluator::evaluate().

◆ transformed() [2/2]

AABB vl::AABB::transformed ( const mat4 mat) const
inline

Returns the AABB transformed by the given matrix.

Definition at line 182 of file AABB.hpp.

◆ volume()

real vl::AABB::volume ( ) const
inline

Returns the volume of the AABB.

Definition at line 208 of file AABB.hpp.

Referenced by vl::ActorKdTree::rebuildKdTree().

◆ width()

real AABB::width ( ) const

Member Data Documentation

◆ mMax

vec3 vl::AABB::mMax
protected

Definition at line 212 of file AABB.hpp.

Referenced by AABB(), addPoint(), clip(), depth(), enlarge(), height(), intersects(), operator+(), operator==(), and width().

◆ mMin

vec3 vl::AABB::mMin
protected

Definition at line 211 of file AABB.hpp.

Referenced by AABB(), addPoint(), clip(), depth(), enlarge(), height(), intersects(), operator+(), operator==(), and width().


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