00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00037 #ifndef COLLISION_CHECKING_RSS_H
00038 #define COLLISION_CHECKING_RSS_H
00039
00040 #include "collision_checking/BVH_defs.h"
00041 #include "collision_checking/vec_3f.h"
00042
00043 namespace collision_checking
00044 {
00045
00046 class RSS
00047 {
00048 public:
00050 Vec3f axis[3];
00051
00053 Vec3f Tr;
00054
00056 BVH_REAL l[2];
00057
00059 BVH_REAL r;
00060
00061 RSS() {}
00062
00064 bool overlap(const RSS& other) const;
00065
00069 bool overlap(const RSS& other, RSS& overlap_part) const
00070 {
00071 return overlap(other);
00072 }
00073
00075 inline bool contain(const Vec3f& p) const;
00076
00078 RSS& operator += (const Vec3f& p);
00079
00081 inline RSS& operator += (const RSS& other)
00082 {
00083 *this = *this + other;
00084 return *this;
00085 }
00086
00088 RSS operator + (const RSS& other) const;
00089
00091 inline BVH_REAL width() const
00092 {
00093 return l[0] + 2 * r;
00094 }
00095
00097 inline BVH_REAL height() const
00098 {
00099 return l[1] + 2 * r;
00100 }
00101
00103 inline BVH_REAL depth() const
00104 {
00105 return 2 * r;
00106 }
00107
00109 inline BVH_REAL volume() const
00110 {
00111 return (l[0] * l[1] * 2 * r + 4 * 3.1415926 * r * r * r);
00112 }
00113
00115 inline BVH_REAL size() const
00116 {
00117 return (sqrt(l[0] * l[0] + l[1] * l[1]) + 2 * r);
00118 }
00119
00121 inline Vec3f center() const
00122 {
00123 return Tr;
00124 }
00125
00127 BVH_REAL distance(const RSS& other) const;
00128
00129 protected:
00130
00132 static void clipToRange(BVH_REAL& val, BVH_REAL a, BVH_REAL b);
00133
00143 static void segCoords(BVH_REAL& t, BVH_REAL& u, BVH_REAL a, BVH_REAL b, BVH_REAL A_dot_B, BVH_REAL A_dot_T, BVH_REAL B_dot_T);
00144
00153 static bool inVoronoi(BVH_REAL a, BVH_REAL b, BVH_REAL Anorm_dot_B, BVH_REAL Anorm_dot_T, BVH_REAL A_dot_B, BVH_REAL A_dot_T, BVH_REAL B_dot_T);
00154
00155 public:
00156
00160 static BVH_REAL rectDistance(const Vec3f Rab[3], Vec3f const& Tab, const BVH_REAL a[2], const BVH_REAL b[2], Vec3f* P = NULL, Vec3f* Q = NULL);
00161
00162 };
00163
00168 BVH_REAL distance(const Vec3f R0[3], const Vec3f& T0, const RSS& b1, const RSS& b2, Vec3f* P = NULL, Vec3f* Q = NULL);
00169
00170 bool overlap(const Vec3f R0[3], const Vec3f& T0, const RSS& b1, const RSS& b2);
00171
00172
00173 }
00174
00175
00176 #endif