IceOBB.h
Go to the documentation of this file.
00001 
00002 
00008 
00009 
00011 // Include Guard
00012 #ifndef __ICEOBB_H__
00013 #define __ICEOBB_H__
00014 
00015         // Forward declarations
00016         class LSS;
00017 
00018         class ICEMATHS_API OBB
00019         {
00020                 public:
00022                 inline_                                         OBB()           {}
00024                 inline_                                         OBB(const Point& center, const Point& extents, const Matrix3x3& rot) : mCenter(center), mExtents(extents), mRot(rot)    {}
00026                 inline_                                         ~OBB()          {}
00027 
00029 
00032 
00033                                 void                            SetEmpty()
00034                                                                         {
00035                                                                                 mCenter.Zero();
00036                                                                                 mExtents.Set(MIN_FLOAT, MIN_FLOAT, MIN_FLOAT);
00037                                                                                 mRot.Identity();
00038                                                                         }
00039 
00041 
00046 
00047                                 bool                            ContainsPoint(const Point& p)   const;
00048 
00050 
00055 
00056                                 void                            Create(const AABB& aabb, const Matrix4x4& mat);
00057 
00059 
00064 
00065                 inline_ void                            Rotate(const Matrix4x4& mtx, OBB& obb)  const
00066                                                                         {
00067                                                                                 // The extents remain constant
00068                                                                                 obb.mExtents = mExtents;
00069                                                                                 // The center gets x-formed
00070                                                                                 obb.mCenter = mCenter * mtx;
00071                                                                                 // Combine rotations
00072                                                                                 obb.mRot = mRot * Matrix3x3(mtx);
00073                                                                         }
00074 
00076 
00080 
00081                 inline_ BOOL                            IsValid()       const
00082                                                                         {
00083                                                                                 // Consistency condition for (Center, Extents) boxes: Extents >= 0.0f
00084                                                                                 if(mExtents.x < 0.0f)   return FALSE;
00085                                                                                 if(mExtents.y < 0.0f)   return FALSE;
00086                                                                                 if(mExtents.z < 0.0f)   return FALSE;
00087                                                                                 return TRUE;
00088                                                                         }
00089 
00091 
00096 
00097                                 bool                            ComputePlanes(Plane* planes)    const;
00098 
00100 
00105 
00106                                 bool                            ComputePoints(Point* pts)       const;
00107 
00109 
00114 
00115                                 bool                            ComputeVertexNormals(Point* pts)        const;
00116 
00118 
00122 
00123                                 const udword*           GetEdges()      const;
00124 
00126 
00130 
00131                                 const Point*            GetLocalEdgeNormals()   const;
00132 
00134 
00139 
00140                                 void                            ComputeWorldEdgeNormal(udword edge_index, Point& world_normal)  const;
00141 
00143 
00147 
00148                                 void                            ComputeLSS(LSS& lss)    const;
00149 
00151 
00156 
00157                                 BOOL                            IsInside(const OBB& box)        const;
00158 
00159                 inline_ const Point&            GetCenter()             const   { return mCenter;       }
00160                 inline_ const Point&            GetExtents()    const   { return mExtents;      }
00161                 inline_ const Matrix3x3&        GetRot()                const   { return mRot;          }
00162 
00163                 inline_ void                            GetRotatedExtents(Matrix3x3& extents)   const
00164                                                                         {
00165                                                                                 extents = mRot;
00166                                                                                 extents.Scale(mExtents);
00167                                                                         }
00168 
00169                                 Point                           mCenter;                
00170                                 Point                           mExtents;               
00171                                 Matrix3x3                       mRot;                   
00172 
00173                                 // Orientation is stored in row-major format,
00174                                 // i.e. rows = eigen vectors of the covariance matrix
00175         };
00176 
00177 #endif  // __ICEOBB_H__


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Thu Apr 11 2019 03:30:16