Go to the documentation of this file.
19 #define AABB_COMMON_METHODS \
20 AABB& Add(const AABB& aabb); \
21 float MakeCube(AABB& cube) const; \
22 void MakeSphere(Sphere& sphere) const; \
23 const sbyte* ComputeOutline(const Point& local_eye, sdword& num) const; \
24 float ComputeBoxArea(const Point& eye, const Matrix4x4& mat, float width, float height, sdword& num) const; \
25 bool IsInside(const AABB& box) const; \
26 bool ComputePlanes(Plane* planes) const; \
27 bool ComputePoints(Point* pts) const; \
28 const Point* GetVertexNormals() const; \
29 const udword* GetEdges() const; \
30 const Point* GetEdgeNormals() const; \
31 inline_ BOOL ContainsPoint(const Point& p) const \
33 if(p.x > GetMax(0) || p.x < GetMin(0)) return FALSE; \
34 if(p.y > GetMax(1) || p.y < GetMin(1)) return FALSE; \
35 if(p.z > GetMax(2) || p.z < GetMin(2)) return FALSE; \
81 void SetCenterExtents(
const Point&
c,
const Point& e) { mMin =
c - e; mMax =
c + e; }
95 void SetPoint(
const Point& pt) { mMin = mMax = pt; }
103 float GetSize()
const {
Point e; GetExtents(e);
return e.
Max(); }
111 void Extend(
const Point& p)
114 if(p.
x > mMax.x) mMax.x = p.
x;
115 if(p.
x < mMin.x) mMin.x = p.
x;
117 if(p.
y > mMax.y) mMax.y = p.
y;
118 if(p.
y < mMin.y) mMin.y = p.
y;
120 if(p.
z > mMax.z) mMax.z = p.
z;
121 if(p.
z < mMin.z) mMin.z = p.
z;
131 inline_ float GetMin(
udword axis)
const {
return mMin[axis]; }
133 inline_ float GetMax(
udword axis)
const {
return mMax[axis]; }
136 inline_ void GetCenter(
Point& center)
const { center = (mMax + mMin)*0.5
f; }
138 inline_ void GetExtents(
Point& extents)
const { extents = (mMax - mMin)*0.5
f; }
141 inline_ float GetCenter(
udword axis)
const {
return (mMax[axis] + mMin[axis])*0.5f; }
143 inline_ float GetExtents(
udword axis)
const {
return (mMax[axis] - mMin[axis])*0.5f; }
146 inline_ void GetDiagonal(
Point& diagonal)
const { diagonal = mMax - mMin; }
147 inline_ float GetWidth()
const {
return mMax.x - mMin.x; }
148 inline_ float GetHeight()
const {
return mMax.y - mMin.y; }
149 inline_ float GetDepth()
const {
return mMax.z - mMin.z; }
152 inline_ float GetVolume()
const {
return GetWidth() * GetHeight() * GetDepth(); }
168 ||
a.mMax.z < mMin.z)
return FALSE;
183 if(mMax[axis] <
a.mMin[axis] ||
a.mMax[axis] < mMin[axis])
return FALSE;
200 mtx.
GetRow(0, vx); vx *= (mMax.x - mMin.x);
201 mtx.
GetRow(1, vy); vy *= (mMax.y - mMin.y);
202 mtx.
GetRow(2, vz); vz *= (mMax.z - mMin.z);
205 aabb.mMin = aabb.mMax = mMin * mtx;
229 if(mMin.x > mMax.x)
return FALSE;
230 if(mMin.y > mMax.y)
return FALSE;
231 if(mMin.z > mMax.z)
return FALSE;
238 Point Center; GetCenter(Center);
239 Point Extents; GetExtents(Extents);
240 SetCenterExtents(Center, Extents * s);
247 Point Center; GetCenter(Center);
248 Point Extents; GetExtents(Extents);
249 SetCenterExtents(Center, Extents / s);
293 void SetCenterExtents(
const Point&
c,
const Point& e) { mCenter =
c; mExtents = e; }
307 void SetPoint(
const Point& pt) { mCenter = pt; mExtents.
Zero(); }
315 float GetSize()
const {
return mExtents.
Max(); }
323 void Extend(
const Point& p)
326 Point Max = mCenter + mExtents;
327 Point Min = mCenter - mExtents;
329 if(p.
x > Max.
x) Max.
x = p.
x;
330 if(p.
x < Min.
x) Min.
x = p.
x;
332 if(p.
y > Max.
y) Max.
y = p.
y;
333 if(p.
y < Min.
y) Min.
y = p.
y;
335 if(p.
z > Max.
z) Max.
z = p.
z;
336 if(p.
z < Min.
z) Min.
z = p.
z;
380 float tx = mCenter.x -
a.mCenter.x;
float ex =
a.mExtents.x + mExtents.x;
if(
AIR(tx) >
IR(ex))
return FALSE;
381 float ty = mCenter.y -
a.mCenter.y;
float ey =
a.mExtents.y + mExtents.y;
if(
AIR(ty) >
IR(ey))
return FALSE;
382 float tz = mCenter.z -
a.mCenter.z;
float ez =
a.mExtents.z + mExtents.z;
if(
AIR(tz) >
IR(ez))
return FALSE;
395 Point T = mCenter -
a.mCenter;
396 return ((fabsf(T.
x) <= (
a.mExtents.x + mExtents.x))
397 && (fabsf(T.
y) <= (
a.mExtents.y + mExtents.y))
398 && (fabsf(T.
z) <= (
a.mExtents.z + mExtents.z)));
411 float t = mCenter[axis] -
a.mCenter[axis];
412 float e =
a.mExtents[axis] + mExtents[axis];
430 Point Ex(mtx.m[0][0] * mExtents.x, mtx.m[0][1] * mExtents.x, mtx.m[0][2] * mExtents.x);
431 IR(Ex.x)&=0x7fffffff;
IR(Ex.y)&=0x7fffffff;
IR(Ex.z)&=0x7fffffff;
433 Point Ey(mtx.m[1][0] * mExtents.y, mtx.m[1][1] * mExtents.y, mtx.m[1][2] * mExtents.y);
434 IR(Ey.x)&=0x7fffffff;
IR(Ey.y)&=0x7fffffff;
IR(Ey.z)&=0x7fffffff;
436 Point Ez(mtx.m[2][0] * mExtents.z, mtx.m[2][1] * mExtents.z, mtx.m[2][2] * mExtents.z);
437 IR(Ez.x)&=0x7fffffff;
IR(Ez.y)&=0x7fffffff;
IR(Ez.z)&=0x7fffffff;
505 #endif // __ICEAABB_H__
inline_ void ComputeMinMax(const Point &p, Point &min, Point &max)
inline_ AABB & operator*=(float s)
Operator for AABB *= float. Scales the extents, keeps same center.
#define MIN_FLOAT
min possible loat value
inline_ float GetCenter(udword axis) const
Get component of the box's center along a given axis.
@ AABB_RENDER
AABB used for rendering. Not visible == not rendered.
inline_ void GetDiagonal(Point &diagonal) const
Get box diagonal.
#define IS_NEGATIVE_FLOAT(x)
inline_ float GetExtents(udword axis) const
Get component of the box's extents along a given axis.
Point mExtents
x, y and z extents
inline_ void GetRow(const udword r, HPoint &p) const
Returns a row.
unsigned int udword
sizeof(udword) must be 4
int BOOL
Another boolean type.
inline_ void GetCenter(Point ¢er) const
Get box center.
static int max(int a, int b)
#define IR(x)
Integer representation of a floating-point value.
inline_ float GetDepth() const
static int min(int a, int b)
@ AABB_UPDATE
AABB used for dynamic updates. Not visible == not updated.
#define AABB_COMMON_METHODS
Declarations of type-independent methods (most of them implemented in the .cpp)
inline_ ~AABB()
Destructor.
inline_ void ComputeAABB(AABB &aabb, const Point *list, udword nb_pts)
inline_ void GetExtents(Point &extents) const
Get box extents.
inline_ float GetMin(udword axis) const
Get component of the box's min point along a given axis.
void SetMinMax(const Point &min, const Point &max)
inline_ float GetHeight() const
Point mCenter
AABB Center.
inline_ Point & Set(float _x, float _y, float _z)
Assignment from values.
png_infop png_bytep * trans
inline_ BOOL Intersect(const AABB &a, const SAP_Box &b)
inline_ float GetVolume() const
Volume.
inline_ Point & Zero()
Clears the vector.
#define AIR(x)
Absolute integer representation of a floating-point value.
inline_ float Max() const
Returns MAX(x, y, z);.
inline_ AABB()
Constructor.
#define MAX_FLOAT
max possible float value
inline_ AABB & operator+=(const Point &trans)
Operator for AABB += Point. Translates the box.
AABB_COMMON_METHODS
Type-independent methods.
inline_ void GetMin(Point &min) const
Get min point of the box.
inline_ float GetMax(udword axis) const
Get component of the box's max point along a given axis.
inline_ void GetMax(Point &max) const
Get max point of the box.
inline_ AABB & operator/=(float s)
Operator for AABB /= float. Scales the extents, keeps same center.
inline_ float GetWidth() const
openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Wed Sep 7 2022 02:51:03