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
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00061
00062 #ifndef DistanceCalculator_h
00063 #define DistanceCalculator_h
00064
00065 #ifdef _MSC_VER
00066 #pragma warning (disable: 4786)
00067 #endif //_MSC_VER
00068
00069 #include "DistanceResults.hpp"
00070 #include "Node.hpp"
00071 #include "GeometricFunctions.hpp"
00072 #include "Cylisphere.hpp"
00073 #include "Sphere.hpp"
00074 #include "Plane.hpp"
00075 #include "Cone.hpp"
00076 #include "Box.hpp"
00077 #include "Polytope.h"
00078
00079 #include "ForwardKinematics/FKAcceleration.h"
00080 #include <set>
00081
00082 namespace OSCAR {
00083
00084 class DistanceResults;
00085
00095 class DistanceCalculator : public Base {
00096 public:
00097
00107 DistanceCalculator(const String& name= String(), OSCARError& err=DUMMY_ERROR(noError));
00108
00109 virtual ~DistanceCalculator();
00110
00111
00119 virtual bool CalcDist(const Node& from, const Node& to,
00120 DistanceResults& results, bool checkSelf = false,
00121 const std::set<const ModelingObject*>& ignoreSet = std::set<const ModelingObject*>());
00122
00134 bool CalcDist(const Primitive& from, const Primitive& to,
00135 Vector3& fromWit, Vector3& toWit,
00136 Vector3& unitVec, double& dist);
00137
00141
00156 virtual bool CalcGFunctions(const Node& from, const Node& to,
00157 DistanceResults& results, FKVelocity* fromFK, bool checkSelf = false,
00158 const std::set<const ModelingObject*>& ignoreSet = std::set<const ModelingObject*>());
00159
00176 virtual bool CalcHFunctions(const Node& from, const Node& to,
00177 DistanceResults& results, FKAcceleration* fromFK, bool checkSelf = false,
00178 const std::set<const ModelingObject*>& ignoreSet = std::set<const ModelingObject*>());
00179
00193 bool CalcGFunction(const Primitive& from, const Primitive& to,
00194 DistanceResults& results, FKVelocity* fromFK, unsigned int fromFrame);
00195
00210 bool CalcHFunction(const Primitive& from, const Primitive& to,
00211 DistanceResults& results, FKVelocity* fromFK, unsigned int fromFrame);
00212
00213 protected:
00214
00215 unsigned int frameNumber; Matrix tempMat;
00216
00217 Vector3 wit0, wit1, dHat;
00218 Vector3 tempVec3; Vector3 secTempVec3;
00219
00220 double sphereSphereDist(const Sphere& from, const Sphere& to,
00221 Vector3& fromWit, Vector3& toWit,
00222 Vector3& unitVec, double& dist);
00223
00224 double spherePlaneDist(const Sphere& from, const Plane& to,
00225 Vector3& fromWit, Vector3& toWit,
00226 Vector3& unitVec, double& dist);
00227
00228 double cylisphereCylisphereDist(const Cylisphere& from, const Cylisphere& to,
00229 Vector3& fromWit, Vector3& toWit,
00230 Vector3& unitVec, double& dist);
00231
00232 double cylisphereSphereDist(const Cylisphere& from, const Sphere& to,
00233 Vector3& fromWit, Vector3& toWit,
00234 Vector3& unitVec, double& dist);
00235
00236 double cylispherePlaneDist (const Cylisphere& from, const Plane& to,
00237 Vector3& fromWit, Vector3& toWit,
00238 Vector3& unitVec, double& dist,
00239 double& t1, double& t2);
00240
00241
00242
00243 bool pointPointH(Vector3& robPt, Vector3& obstPt, const Primitive& robPrim, const Primitive& obstPrim,
00244 DistanceResults& results, double robRadius, double obstRadius, FKAcceleration* fromFK, unsigned int robotFrameNumber);
00245
00246 bool linePointH(Vector3& robPt, Vector3& obstPt, const Primitive& robPrim, const Primitive& obstPrim,
00247 DistanceResults& results, double robRadius, double obstRadius, FKAcceleration* fromFK, unsigned int robotFrameNumber);
00248
00249 bool lineLineH(Vector3& robPt, Vector3& obstPt, const Primitive& robPrim, const Primitive& obstPrim,
00250 DistanceResults& results, double robRadius, double obstRadius, FKAcceleration* fromFK, unsigned int robotFrameNumber);
00251
00252 bool LinePlaneH();
00253
00254 };
00255
00256 }
00257 #endif //DistanceCalculator_h