15BEGIN_MOOTOOLS_NAMESPACE
44 min.x = center.x-radius;
45 min.y = center.y-radius;
46 min.z = center.z-radius;
48 max.x = center.x+radius;
49 max.y = center.y+radius;
50 max.z = center.z+radius;
57 min.x = center.x - radiusx;
58 min.y = center.y - radiusy;
59 min.z = center.z - radiusz;
61 max.x = center.x + radiusx;
62 max.y = center.y + radiusy;
63 max.z = center.z + radiusz;
72 inline void InitDone()
79 XTRACE_IF(
anormal,
_T(
"C3DTBBox::InitDone: Invalid bounding box. An anormal coordinate (nan / -inf / inf was collected\n"))
117 if (min == bbox.min && max == bbox.max)
125 if (!IsValid() || IsNull())
174 inline double GetDiagonalLength()
const
180 return vector.Length();
185 return GetDiagonalLength()/2.0;
210 inline double GetMinLength()
const
222 inline double GetMaxLength()
const
244 double dx = __max(min.x -
pt.x, __max(0,
pt.x - max.x));
245 double dy = __max(min.y -
pt.y, __max(0,
pt.y - max.y));
246 double dz = __max(min.z -
pt.z, __max(0,
pt.z - max.z));
261 if (min.x -
pt.x > __max(0,
pt.x - max.x))
263 else if (
pt.x - max.x > 0)
266 if (min.y -
pt.y > __max(0,
pt.y - max.y))
268 else if (
pt.y - max.y > 0)
271 if (min.z -
pt.z > __max(0,
pt.z - max.z))
273 else if (
pt.z - max.z > 0)
285 unsigned char xyz = 0;
307 MOOTOOLS_PRIVATE_ASSERT(find);
316 center = (min + max) / 2.0;
332 inline bool IsNull()
const
339 return (init !=
false);
357 inline void Inflate(
TYPE value)
380 if (!IsValid() || !bbox.IsValid())
383 XTRACE_IF(!IsInitialized() || !bbox.IsInitialized(),
_T(
"C3DTBBox::SelfUnion called but bounding box has not been initialized.\nResults may be impredictable.\n"));
400 if (!IsValid() || !bbox.IsValid())
403 XTRACE_IF(!IsInitialized() || !bbox.IsInitialized(),
_T(
"C3DTBBox::SelfUnion called but bounding box has not been initialized.\nResults may be impredictable.\n"));
448 tmin = dir.x < 0 ? max.x : min.x;
450 tmax = dir.x < 0 ? min.x : max.x;
453 tymin = dir.y < 0 ? max.y : min.y;
455 tymax = dir.y < 0 ? min.y : max.y;
466 tzmin = dir.z < 0 ? max.z : min.z;
468 tzmax = dir.z < 0 ? min.z : max.z;
493 if (RayIntersect(
orig, dir, t))
507 XTRACE(
_T(
"Bounding box:\n"));
521END_MOOTOOLS_NAMESPACE
C3DTPoint template class definition for handling x, y, z 3D point coordinate.
The class defines a bounding box using int, float or double.
Definition 3DBBox.h:24
bool IsInBox(const C3DTPoint< TYPE > &pt, bool strictlyInside=false) const
<
Definition 3DBBox.h:123
double GetRadius() const
<
Definition 3DBBox.h:183
C3DTBBox< TYPE > GetGreaterUniformBBox() const
<
Definition 3DBBox.h:188
bool RayIntersect(const C3DTPoint< TYPE > &orig, const C3DTVector< TYPE > &dir, double &t)
Return true only if ray intersect the bbox which is in front (otherwise dist < 0).
Definition 3DBBox.h:442
bool IsValid() const
Invalid bounding box, means that min is greater than max.
Definition 3DBBox.h:345
C3DTPoint< TYPE > GetClosestCorner(const C3DTPoint< TYPE > &pt) const
<
Definition 3DBBox.h:279
bool IsInitialized() const
<
Definition 3DBBox.h:337
The class defines an x, y, z 3D point which can use int, float or double.
Definition 3DPoint.h:27
bool IsAnormal() const
either infinite or nan. Zero and denormalized value are allowed.
Definition 3DPoint.inl:177
void Offset(TYPE value)
Add value to x, y, z.
Definition 3DPoint.inl:169