# Visualization Library

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

[Home] [Tutorials] [All Classes] [Grouped Classes]

Public Member Functions | Protected Attributes

# vl::AABB Class Reference

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

`#include <AABB.hpp>`

List of all members.

## Public Member Functions

| AABB ()
| Constructs a null AABB.
| AABB (const vec3 &center, Real radius)
| Constructs an AABB large enough to contain a sphere with the specified `radius` and `center`.
| 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`.
void | setNull ()
| Sets ths AABB as null, that is, empty.
bool | isNull () const
| Returns true if the AABB is null.
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.
void | enlarge (Real displace)
| Enlarges the AABB in all directions by `displace` amount.
bool | intersects (const AABB &bb) const
| Returns true if an AABB intersects with the given AABB.
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.
bool | isInside (const vec3 &p, bool clipx, bool clipy, bool clipz) const
| Returns true if the given point is inside the AABB.
bool | isInside (const vec3 &p) const
| Returns true if the given point is inside the AABB.
Real | width () const
| Returns the width of the AABB computed as max.x - min.x.
Real | height () const
| Returns the height of the AABB computed as max.y - min.y.
Real | depth () const
| Returns the depth of the AABB computed as max.z - min.z.
bool | operator== (const AABB &aabb) const
| Returns true if two AABB are identical.
bool | operator!= (const AABB &aabb) const
| Returns true if two AABB are not identical.
AABB | operator+ (const AABB &aabb) const
| Returns an AABB which contains the two source AABB.
AABB & | operator+= (const AABB &other)
| Enlarges (if necessary) an AABB so that it contains the given AABB.
AABB | operator+ (const vec3 &p)
| Returns an AABB which contains the source AABB and the given point.
const AABB & | operator+= (const vec3 &p)
| Enlarges (if necessary) an AABB to contain the given point.
vec3 | center () const
| Returns the center of the AABB.
Real | longestSideLength () const
| Returns the longest dimension of the AABB.
void | addPoint (const vec3 &p, Real radius)
| Updates the AABB to contain the given point.
void | addPoint (const vec3 &p)
| Updates the AABB to contain the given point.
void | transformed (AABB &out, const mat4 &mat) const
| Transforms an AABB by the given matrix and returns it into the `out` parameter.
AABB | transformed (const mat4 &mat) const
| Returns the AABB transformed by the given matrix.
const vec3 & | minCorner () const
| Returns the corner of the AABB with the minimum x y z coordinates.
const vec3 & | maxCorner () const
| Returns the corner of the AABB with the maximum x y z coordinates.
void | setMinCorner (Real x, Real y, Real z)
| Sets the corner of the AABB with the minimum x y z coordinates.
void | setMinCorner (const vec3 &v)
| Sets the corner of the AABB with the minimum x y z coordinates.
void | setMaxCorner (Real x, Real y, Real z)
| Sets the corner of the AABB with the maximum x y z coordinates.
void | setMaxCorner (const vec3 &v)
| Sets the corner of the AABB with the maximum x y z coordinates.
Real | volume () const
| Returns the volume of the AABB.

## 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::AABB | ( | ) |

Constructs a null AABB.

Definition at line 39 of file AABB.cpp.

References setNull().

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::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

void vl::AABB::setNull | ( | ) | `[inline]`

Sets ths AABB as null, that is, empty.

Definition at line 57 of file AABB.hpp.

Referenced by AABB(), vl::Text::boundingRectTransformed(), vl::SceneManager::computeBounds(), vl::PixelLODEvaluator::evaluate(), and transformed().

bool vl::AABB::isNull | ( | ) | const`[inline]`

Returns true if the AABB is null.

Definition at line 60 of file AABB.hpp.

Referenced by addPoint(), clip(), vl::Actor::computeBounds(), vl::Frustum::cull(), depth(), enlarge(), height(), intersects(), operator+(), vl::Sphere::operator=(), vl::RenderQueue::sort(), and width().

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.

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.

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().

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().

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().

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().

Real AABB::width | ( | ) | const

Returns the width of the AABB computed as max.x - min.x.

Definition at line 151 of file AABB.cpp.

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

Referenced by vl::Text::boundingRect(), vl::PixelLODEvaluator::evaluate(), and vl::Text::renderText().

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(), and vl::PixelLODEvaluator::evaluate().

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().

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.

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==().

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.

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.

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.

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.

vec3 AABB::center | ( | ) | const

Returns the center of the AABB.

Definition at line 184 of file AABB.cpp.

References maxCorner(), and minCorner().

Referenced by vl::TrackballManipulator::adjustView(), vl::Camera::adjustView(), vl::Array< T_VectorType, T_Scalar, T_GL_Size, T_GL_Type >::computeBoundingSphere(), vl::SceneManager::computeBounds(), vl::Geometry::computeBounds_Implementation(), vl::Molecule::generateRings(), vl::RingExtractor::keepPlanarCycles(), vl::Sphere::operator=(), and vl::RenderQueue::sort().

Real vl::AABB::longestSideLength | ( | ) | const`[inline]`

Returns the longest dimension of the AABB.

Definition at line 132 of file AABB.hpp.

void AABB::addPoint | ( | const vec3 & | p,
|  | Real | radius
| ) |  |

Updates the AABB to contain the given point.

The point can represent a sphere if `radius` > 0.

Definition at line 135 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 vl::Text::boundingRectTransformed(), vl::PixelLODEvaluator::evaluate(), operator+(), vl::Text::rawboundingRect(), and transformed().

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().

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().

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.

const vec3& vl::AABB::minCorner | ( | ) | const`[inline]`

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

Definition at line 190 of file AABB.hpp.

Referenced by vl::Text::boundingRect(), vl::Text::boundingRectTransformed(), center(), vl::Plane::classify(), vl::PixelLODEvaluator::evaluate(), isInside(), vl::Plane::isOutside(), vl::makeBox(), vl::Sphere::operator=(), vl::OcclusionCullRenderer::render_pass2(), vl::Text::renderText(), and vl::RaycastVolume::setBox().

const vec3& vl::AABB::maxCorner | ( | ) | const`[inline]`

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

Definition at line 193 of file AABB.hpp.

Referenced by vl::Text::boundingRect(), vl::Text::boundingRectTransformed(), center(), vl::Plane::classify(), vl::PixelLODEvaluator::evaluate(), isInside(), vl::Plane::isOutside(), vl::makeBox(), vl::Sphere::operator=(), vl::OcclusionCullRenderer::render_pass2(), vl::Text::renderText(), and vl::RaycastVolume::setBox().

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(), and vl::Terrain::init().

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.

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(), and vl::Terrain::init().

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.

Real vl::AABB::volume | ( | ) | const`[inline]`

Returns the volume of the AABB.

Definition at line 208 of file AABB.hpp.

## Member Data Documentation

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().

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().

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

- D:/VL/BuildSystem/VL_DISTRO/Visualization_Library_SDK/src/vlCore/AABB.hpp
- D:/VL/BuildSystem/VL_DISTRO/Visualization_Library_SDK/src/vlCore/AABB.cpp

Visualization Library v2011.05.1142 Reference Documentation
Copyright 2005-2011 Michele Bosi. All rights reserved.
Updated on Thu May 26 2011 22:51:32.
Permission is granted to use this page to write and publish articles regarding Visualization Library.