Go to the documentation of this file.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
00038 #ifndef FCL_GJK_LIBCCD_H
00039 #define FCL_GJK_LIBCCD_H
00040
00041 #include "fcl/shape/geometric_shapes.h"
00042 #include "fcl/math/transform.h"
00043
00044 #include <ccd/ccd.h>
00045 #include <ccd/quat.h>
00046
00047 namespace fcl
00048 {
00049
00050 namespace details
00051 {
00052
00054 typedef void (*GJKSupportFunction)(const void* obj, const ccd_vec3_t* dir_, ccd_vec3_t* v);
00055 typedef void (*GJKCenterFunction)(const void* obj, ccd_vec3_t* c);
00056
00058 template<typename T>
00059 class GJKInitializer
00060 {
00061 public:
00063 static GJKSupportFunction getSupportFunction() { return NULL; }
00064
00066 static GJKCenterFunction getCenterFunction() { return NULL; }
00067
00071 static void* createGJKObject(const T& s, const Transform3f& tf) { return NULL; }
00072
00074 static void deleteGJKObject(void* o) {}
00075 };
00076
00078 template<>
00079 class GJKInitializer<Cylinder>
00080 {
00081 public:
00082 static GJKSupportFunction getSupportFunction();
00083 static GJKCenterFunction getCenterFunction();
00084 static void* createGJKObject(const Cylinder& s, const Transform3f& tf);
00085 static void deleteGJKObject(void* o);
00086 };
00087
00089 template<>
00090 class GJKInitializer<Sphere>
00091 {
00092 public:
00093 static GJKSupportFunction getSupportFunction();
00094 static GJKCenterFunction getCenterFunction();
00095 static void* createGJKObject(const Sphere& s, const Transform3f& tf);
00096 static void deleteGJKObject(void* o);
00097 };
00098
00100 template<>
00101 class GJKInitializer<Box>
00102 {
00103 public:
00104 static GJKSupportFunction getSupportFunction();
00105 static GJKCenterFunction getCenterFunction();
00106 static void* createGJKObject(const Box& s, const Transform3f& tf);
00107 static void deleteGJKObject(void* o);
00108 };
00109
00111 template<>
00112 class GJKInitializer<Capsule>
00113 {
00114 public:
00115 static GJKSupportFunction getSupportFunction();
00116 static GJKCenterFunction getCenterFunction();
00117 static void* createGJKObject(const Capsule& s, const Transform3f& tf);
00118 static void deleteGJKObject(void* o);
00119 };
00120
00122 template<>
00123 class GJKInitializer<Cone>
00124 {
00125 public:
00126 static GJKSupportFunction getSupportFunction();
00127 static GJKCenterFunction getCenterFunction();
00128 static void* createGJKObject(const Cone& s, const Transform3f& tf);
00129 static void deleteGJKObject(void* o);
00130 };
00131
00133 template<>
00134 class GJKInitializer<Convex>
00135 {
00136 public:
00137 static GJKSupportFunction getSupportFunction();
00138 static GJKCenterFunction getCenterFunction();
00139 static void* createGJKObject(const Convex& s, const Transform3f& tf);
00140 static void deleteGJKObject(void* o);
00141 };
00142
00144 GJKSupportFunction triGetSupportFunction();
00145
00146 GJKCenterFunction triGetCenterFunction();
00147
00148 void* triCreateGJKObject(const Vec3f& P1, const Vec3f& P2, const Vec3f& P3);
00149
00150 void* triCreateGJKObject(const Vec3f& P1, const Vec3f& P2, const Vec3f& P3, const Transform3f& tf);
00151
00152 void triDeleteGJKObject(void* o);
00153
00155 bool GJKCollide(void* obj1, ccd_support_fn supp1, ccd_center_fn cen1,
00156 void* obj2, ccd_support_fn supp2, ccd_center_fn cen2,
00157 unsigned int max_iterations, FCL_REAL tolerance,
00158 Vec3f* contact_points, FCL_REAL* penetration_depth, Vec3f* normal);
00159
00160 bool GJKDistance(void* obj1, ccd_support_fn supp1,
00161 void* obj2, ccd_support_fn supp2,
00162 unsigned int max_iterations, FCL_REAL tolerance,
00163 FCL_REAL* dist);
00164
00165
00166 }
00167
00168
00169 }
00170
00171 #endif