47 #ifndef CCollisionAABBBoxH 48 #define CCollisionAABBBoxH 252 const int MIDDLE = 2;
260 double candidatePlane[3];
262 dir[0] = a_segmentPointB(0) - a_segmentPointA(0);
263 dir[1] = a_segmentPointB(1) - a_segmentPointA(1);
264 dir[2] = a_segmentPointB(2) - a_segmentPointA(2);
270 if(a_segmentPointA(i) <
m_min(i))
273 candidatePlane[i] =
m_min(i);
276 else if (a_segmentPointA(i) >
m_max(i))
279 candidatePlane[i] =
m_max(i);
284 quadrant[i] = MIDDLE;
297 if (quadrant[i] != MIDDLE && dir[i] !=0.)
298 maxT[i] = (candidatePlane[i]-a_segmentPointA(i)) / dir[i];
306 if (maxT[whichPlane] < maxT[i])
310 if (maxT[whichPlane] < 0.)
319 coord[i] = a_segmentPointA(i) + maxT[whichPlane] * dir[i];
320 if (coord[i] <
m_min(i) || coord[i] >
m_max(i))
327 coord[i] = candidatePlane[i];
353 if ((a_point(0) >
m_min(0)) && (a_point(1) >
m_min(1)) && (a_point(2) >
m_min(2)) &&
354 (a_point(0) <
m_max(0)) && (a_point(1) <
m_max(1)) && (a_point(2) <
m_max(2)))
455 const double C_INFINITY = 1.0e50;
458 m_min.
set( C_INFINITY, C_INFINITY, C_INFINITY);
459 m_max.
set(-C_INFINITY,-C_INFINITY,-C_INFINITY);
This class implements a 3D vector.
Definition: CVector3d.h:88
void enclose(const cCollisionAABBBox &a_boxA, const cCollisionAABBBox &a_boxB)
This method initializes the boundary box to bound two given boundary boxes passed as argument...
Definition: CCollisionAABBBox.h:379
Implements general math utility functions.
double getLowerX() const
This method returns the smallest coordinate along X axis.
Definition: CCollisionAABBBox.h:474
cVector3d getCenter() const
This method returns the center of the boundary box.
Definition: CCollisionAABBBox.h:123
bool contains(const cVector3d &a_point) const
This method tests whether this box contains a point passed as argument.
Definition: CCollisionAABBBox.h:350
void zero()
This method clears all vector components with zeros.
Definition: CVector3d.h:256
double getUpperZ() const
This method return the largest coordinate along Z axis.
Definition: CCollisionAABBBox.h:559
void enclose(const cVector3d &a_point)
This method resizes the boundary box to bound a new point passed as argument.
Definition: CCollisionAABBBox.h:410
Implements an abstract class for describing elements composed of vertices.
void cDrawWireBox(const double &a_xMin, const double &a_xMax, const double &a_yMin, const double &a_yMax, const double &a_zMin, const double &a_zMax)
This function draws a box using lines.
Definition: CDraw3D.cpp:327
cVector3d cAdd(const cVector3d &a_vector1, const cVector3d &a_vector2)
This function computes the addition of two vectors.
Definition: CMaths.h:708
cVector3d m_center
The center of the boundary box.
Definition: CCollisionAABBBox.h:617
double getLowerZ() const
This returns the smallest coordinate along Z axis.
Definition: CCollisionAABBBox.h:542
int getLongestAxis() const
This method returns the index of the longest axis of the boundary box.
Definition: CCollisionAABBBox.h:576
cCollisionAABBBox(const cVector3d &a_min, const cVector3d &a_max)
Constructor of cCollisionAABBBox.
Definition: CCollisionAABBBox.h:96
cVector3d cSub(const cVector3d &a_vector1, const cVector3d &a_vector2)
This function computes the subtraction of two vectors.
Definition: CMaths.h:769
double getLowerY() const
This method returns the smallest coordinate along Y axis.
Definition: CCollisionAABBBox.h:508
void setCenter(const cVector3d &a_center)
This method sets the center of the boundary box.
Definition: CCollisionAABBBox.h:157
bool intersect(const cVector3d &a_segmentPointA, const cVector3d &a_segmentPointB) const
This method determines whether the given ray intersects the boundary box.
Definition: CCollisionAABBBox.h:248
void set(const double &a_x, const double &a_y, const double &a_z)
This method initializes this vector with components x, y, and z passed as arguments.
Definition: CVector3d.h:298
double getUpperX() const
This method returns the largest coordinate along X axis.
Definition: CCollisionAABBBox.h:491
cCollisionAABBBox()
Default constructor of cCollisionAABBBox.
Definition: CCollisionAABBBox.h:93
cVector3d cMul(const double &a_value, const cVector3d &a_vector)
This function computes the multiplication of a vector by a scalar.
Definition: CMaths.h:824
void setEmpty()
This method empties this boundary box.
Definition: CCollisionAABBBox.h:453
cVector3d m_min
The minimum point (along each axis) of the boundary box.
Definition: CCollisionAABBBox.h:623
Implements OpenGL drawing macros.
virtual ~cCollisionAABBBox()
Destructor of cCollisionAABBBox.
Definition: CCollisionAABBBox.h:103
cVector3d m_max
The maximum point (along each axis) of the boundary box.
Definition: CCollisionAABBBox.h:626
cVector3d getExtent() const
This method returns the extent (half the width) of the boundary box.
Definition: CCollisionAABBBox.h:140
T cMin(const T &a_value1, const T &a_value2)
This function computes the minimum value between two values.
Definition: CMaths.h:242
This structure implements the boundary nodes of an axis-aligned bounding box.
Definition: CCollisionAABBBox.h:84
cVector3d m_extent
The extent (half the width) of the boundary box.
Definition: CCollisionAABBBox.h:620
double getUpperY() const
This method returns the largest coordinate along Y axis.
Definition: CCollisionAABBBox.h:525
Definition: CAudioBuffer.cpp:56
bool intersect(const cCollisionAABBBox &a_box) const
This method determines whether this box and an input box passed as argument intersect each other...
Definition: CCollisionAABBBox.h:218
void setValue(const cVector3d &a_min, const cVector3d &a_max)
This method initializes the boundary box by passing a minimum and maximum point.
Definition: CCollisionAABBBox.h:194
void setExtent(const cVector3d &a_extent)
This method sets the extent (half the width) of the boundary box.
Definition: CCollisionAABBBox.h:174
void enclose(const cCollisionAABBBox &a_box)
This method resizes the boundary box to bound a new point passed as argument.
Definition: CCollisionAABBBox.h:438
void render()
This method renders graphically the edges of the boundary box.
Definition: CCollisionAABBBox.h:604
T cMax(const T &a_value1, const T &a_value2)
This function computes the maximum value between two values.
Definition: CMaths.h:220