Space Comps
 All Classes Files Functions Variables
Public Member Functions | List of all members
BoundingBox Class Reference

The BoundingBox class represents a square or cube that fits perfectly around a particle. More...

#include <boundingbox.h>

Public Member Functions

 BoundingBox (Particle *p)
 Constructs a BoundingBox around the given Particle. More...
 
ParticlegetParticle ()
 Returns the Particle this BouningBox is tracks the endpoints of. More...
 
void update ()
 Updates the position of the BouningBox to reflect the Particle. More...
 
double getMax (int dimension)
 Returns the minimum of the desired dimension. More...
 
double getMin (int dimension)
 Returns the maximum of the desired dimension. More...
 
double getXMin ()
 Returns the minimum x dimension coordinate of this BoundingBox. More...
 
double getXMax ()
 Returns the maximum x dimension coordinate of this BouningBox. More...
 
double getYMin ()
 Returns the minimum y dimension coordinate of this BoundingBox. More...
 
double getYMax ()
 Returns the maximum y dimension coordinate of this BouningBox. More...
 
double getZMin ()
 Returns the minimum z dimension coordinate of this BoundingBox. More...
 
double getZMax ()
 Returns the maximum z dimension coordinate of this BouningBox. More...
 
bool pointContained3D (double point[3])
 Returns whether a point in 3-space falls within this BoundingBox. More...
 
bool boxOverlap3D (BoundingBox *other)
 Returns whether or not 2 bouning boxes overlap (in 3-space) More...
 
bool pointContained2D (double point[2])
 Returns whether a point in 2-space falls within this BoundingBox. More...
 
bool boxOverlap2D (BoundingBox *other)
 Returns whether or not 2 bouning boxes overlap (in 3-space) More...
 

Detailed Description

The BoundingBox class represents a square or cube that fits perfectly around a particle.

This class is mostly a convenient way of tracking the endpoints or extreemes of a Particle in each dimentsion.

Constructor & Destructor Documentation

BoundingBox::BoundingBox ( Particle p)

Constructs a BoundingBox around the given Particle.

This tells the BoundingBox what Particle it is responsible for, and sets the appropriate minimum and maximum values for each dimension.

Parameters
pthe Particle this BoundingBox is responsible for.

Member Function Documentation

bool BoundingBox::boxOverlap2D ( BoundingBox other)

Returns whether or not 2 bouning boxes overlap (in 3-space)

If any corner of either of the BoundingBoxes lies within the other BoundingBox, then they overlap, if this is true for no corners, then they do not overlap. This requires us to check all 16 corners.

Parameters
otherthe BouningBox to check against this one for overlap.
Returns
True if the BoundingBoxes overlap, false otherwise.
bool BoundingBox::boxOverlap3D ( BoundingBox other)

Returns whether or not 2 bouning boxes overlap (in 3-space)

If any corner of either of the BoundingBoxes lies within the other BoundingBox, then they overlap, if this is true for no corners, then they do not overlap. This requires us to check all 16 corners.

Parameters
otherthe BouningBox to check against this one for overlap.
Returns
True if the BoundingBoxes overlap, false otherwise.
double BoundingBox::getMax ( int  dimension)

Returns the minimum of the desired dimension.

This returns the minimum coordinate of this BoundingBox in the desired dimension. This is mostly a glorified and generalized getter.

Parameters
dimensionthe desired from: X_DIMENSION, Y_DIMENSION, Z_DIMENSION
Returns
double BoundingBox::getMin ( int  dimension)

Returns the maximum of the desired dimension.

This returns the maximum coordinate of this BoundingBox in the desired dimension. This is mostly a glorified and generalized getter.

Parameters
dimensionthe desired from: X_DIMENSION, Y_DIMENSION, Z_DIMENSION
Returns
Particle * BoundingBox::getParticle ( )

Returns the Particle this BouningBox is tracks the endpoints of.

Returns
The Particle this BoundingBox tracks the endpoinst of.
double BoundingBox::getXMax ( )

Returns the maximum x dimension coordinate of this BouningBox.

Returns
The maximum x coordinate this BouningBox's Particle touches.
double BoundingBox::getXMin ( )

Returns the minimum x dimension coordinate of this BoundingBox.

Returns
The minimum x coordinate this BoundingBox's Particle touches.
double BoundingBox::getYMax ( )

Returns the maximum y dimension coordinate of this BouningBox.

Returns
The maximum y coordinate this BouningBox's Particle touches.
double BoundingBox::getYMin ( )

Returns the minimum y dimension coordinate of this BoundingBox.

Returns
The minimum y coordinate this BoundingBox's Particle touches.
double BoundingBox::getZMax ( )

Returns the maximum z dimension coordinate of this BouningBox.

Returns
The maximum z coordinate this BouningBox's Particle touches.
double BoundingBox::getZMin ( )

Returns the minimum z dimension coordinate of this BoundingBox.

Returns
The minimum z coordinate this BoundingBox's Particle touches.
bool BoundingBox::pointContained2D ( double  point[2])

Returns whether a point in 2-space falls within this BoundingBox.

Ensures the x coordinate of the point lies between this BouningBox's x minimum and x maximum, and does the same for the y dimension.

Parameters
pointa point in 2-space
Returns
True if the point lies in this BoundingBox, false otherwise.
bool BoundingBox::pointContained3D ( double  point[3])

Returns whether a point in 3-space falls within this BoundingBox.

Ensures the x coordinate of the point lies between this BouningBox's x minimum and x maximum, and does the same for the y and z dimensions.

Parameters
pointa point in 3-space
Returns
True if the point lies in this BoundingBox, false otherwise.
void BoundingBox::update ( )

Updates the position of the BouningBox to reflect the Particle.

This sets the minimum and maximum for each dimension to be the appropriate value given the current Position of the Particle this BouningBox is keeping track of.


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