OPC_Common.h
Go to the documentation of this file.
1 /*
3  * OPCODE - Optimized Collision Detection
4  * Copyright (C) 2001 Pierre Terdiman
5  * Homepage: http://www.codercorner.com/Opcode.htm
6  */
8 
10 
16 
19 // Include Guard
20 #ifndef __OPC_COMMON_H__
21 #define __OPC_COMMON_H__
22 
23 // [GOTTFRIED]: Just a small change for readability.
24 #ifdef OPC_CPU_COMPARE
25  #define GREATER(x, y) AIR(x) > IR(y)
26 #else
27  #define GREATER(x, y) fabsf(x) > (y)
28 #endif
29 
31  {
32  public:
36  inline_ CollisionAABB(const AABB& b) { b.GetCenter(mCenter); b.GetExtents(mExtents); }
39 
41  inline_ void GetMin(Point& min) const { min = mCenter - mExtents; }
43  inline_ void GetMax(Point& max) const { max = mCenter + mExtents; }
44 
46  inline_ float GetMin(udword axis) const { return mCenter[axis] - mExtents[axis]; }
48  inline_ float GetMax(udword axis) const { return mCenter[axis] + mExtents[axis]; }
49 
51 
56  inline_ void SetMinMax(const Point& min, const Point& max) { mCenter = (max + min)*0.5f; mExtents = (max - min)*0.5f; }
58 
60 
65  inline_ BOOL IsInside(const CollisionAABB& box) const
67  {
68  if(box.GetMin(0)>GetMin(0)) return FALSE;
69  if(box.GetMin(1)>GetMin(1)) return FALSE;
70  if(box.GetMin(2)>GetMin(2)) return FALSE;
71  if(box.GetMax(0)<GetMax(0)) return FALSE;
72  if(box.GetMax(1)<GetMax(1)) return FALSE;
73  if(box.GetMax(2)<GetMax(2)) return FALSE;
74  return TRUE;
75  }
76 
79 #if 1 // Added by AIST
80  typedef enum {SSV_PSS, SSV_LSS} ssv_type;
82  float mRadius;
83  Point mPoint0, mPoint1;
84  void CreateSSV(){
85  PointComponent maxAxis, minAxis;
86  maxAxis = mExtents.LargestAxis();
87  minAxis = mExtents.SmallestAxis();
88  if (mExtents[minAxis] > 0 && mExtents[maxAxis]/mExtents[minAxis] > 2){
89  mType = SSV_LSS;
90  mPoint0 = mCenter;
91  mPoint0[maxAxis] -= mExtents[maxAxis];
92  mPoint1 = mCenter;
93  mPoint1[maxAxis] += mExtents[maxAxis];
94  Point p = mExtents;
95  p[maxAxis] = 0;
96  mRadius = p.Magnitude();
97  }else{
98  mType = SSV_PSS;
99  mRadius = mExtents.Magnitude();
100  }
101  }
102 #endif
103  };
104 
106  {
107  public:
112 
113  sword mCenter[3];
114  uword mExtents[3];
115  };
116 
118  inline_ void TransformPoint(Point& dest, const Point& source, const Matrix3x3& rot, const Point& trans)
119  {
120  dest.x = trans.x + source.x * rot.m[0][0] + source.y * rot.m[1][0] + source.z * rot.m[2][0];
121  dest.y = trans.y + source.x * rot.m[0][1] + source.y * rot.m[1][1] + source.z * rot.m[2][1];
122  dest.z = trans.z + source.x * rot.m[0][2] + source.y * rot.m[1][2] + source.z * rot.m[2][2];
123  }
124 
125 #endif //__OPC_COMMON_H__
CollisionAABB::GetMax
inline_ float GetMax(udword axis) const
Get component of the box's max point along a given axis.
Definition: OPC_Common.h:48
Point::z
float z
Definition: IcePoint.h:524
CollisionAABB::GetMin
inline_ void GetMin(Point &min) const
Get min point of the box.
Definition: OPC_Common.h:41
box
Definition: jquant2.c:258
udword
unsigned int udword
sizeof(udword) must be 4
Definition: IceTypes.h:65
BOOL
int BOOL
Another boolean type.
Definition: IceTypes.h:102
swingTest.f
f
Definition: swingTest.py:6
b
long b
Definition: jpegint.h:371
hrp::max
static int max(int a, int b)
Definition: MatrixSolvers.cpp:54
Point::Magnitude
inline_ float Magnitude() const
Computes magnitude.
Definition: IcePoint.h:219
Point::x
float x
Definition: IcePoint.h:524
QuantizedAABB::~QuantizedAABB
inline_ ~QuantizedAABB()
Destructor.
Definition: OPC_Common.h:111
hrp::min
static int min(int a, int b)
Definition: MatrixSolvers.cpp:55
Point::LargestAxis
inline_ PointComponent LargestAxis() const
Returns largest axis.
Definition: IcePoint.h:341
Matrix3x3::m
float m[3][3]
Definition: IceMatrix3x3.h:492
CollisionAABB
Definition: OPC_Common.h:30
CollisionAABB::CollisionAABB
inline_ CollisionAABB()
Constructor.
Definition: OPC_Common.h:34
CollisionAABB::~CollisionAABB
inline_ ~CollisionAABB()
Destructor.
Definition: OPC_Common.h:38
CollisionAABB::mType
ssv_type mType
Type of SSV.
Definition: OPC_Common.h:81
trans
png_infop png_bytep * trans
Definition: png.h:2432
CollisionAABB::ssv_type
ssv_type
Definition: OPC_Common.h:80
CollisionAABB::GetMax
inline_ void GetMax(Point &max) const
Get max point of the box.
Definition: OPC_Common.h:43
TRUE
#define TRUE
Definition: OPC_IceHook.h:13
sword
signed short sword
sizeof(sword) must be 2
Definition: IceTypes.h:62
TransformPoint
inline_ void TransformPoint(Point &dest, const Point &source, const Matrix3x3 &rot, const Point &trans)
Quickly rotates & translates a vector.
Definition: OPC_Common.h:118
Point::SmallestAxis
inline_ PointComponent SmallestAxis() const
Returns smallest axis.
Definition: IcePoint.h:362
QuantizedAABB
Definition: OPC_Common.h:105
FALSE
#define FALSE
Definition: OPC_IceHook.h:9
OPCODE_API
#define OPCODE_API
Definition: Opcode.h:68
QuantizedAABB::QuantizedAABB
inline_ QuantizedAABB()
Constructor.
Definition: OPC_Common.h:109
Point
Definition: IcePoint.h:25
CollisionAABB::mPoint1
Point mPoint1
End points of line segment.
Definition: OPC_Common.h:83
Point::y
float y
Definition: IcePoint.h:524
CollisionAABB::GetMin
inline_ float GetMin(udword axis) const
Get component of the box's min point along a given axis.
Definition: OPC_Common.h:46
PointComponent
PointComponent
Definition: IceAxes.h:15
Matrix3x3
Definition: IceMatrix3x3.h:20
CollisionAABB::mRadius
float mRadius
Definition: OPC_Common.h:82
CollisionAABB::CreateSSV
void CreateSSV()
Definition: OPC_Common.h:84
CollisionAABB::CollisionAABB
inline_ CollisionAABB(const AABB &b)
Constructor.
Definition: OPC_Common.h:36
CollisionAABB::mCenter
Point mCenter
Box center.
Definition: OPC_Common.h:77
inline_
#define inline_
Definition: IcePreprocessor.h:103
CollisionAABB::mExtents
Point mExtents
Box extents.
Definition: OPC_Common.h:78
AABB
Definition: IceAABB.h:267
uword
unsigned short uword
sizeof(uword) must be 2
Definition: IceTypes.h:63


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