Wm4Distance.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef WM4DISTANCE_H
00018 #define WM4DISTANCE_H
00019
00020 #include "Wm4FoundationLIB.h"
00021 #include "Wm4Vector2.h"
00022 #include "Wm4Vector3.h"
00023
00024 namespace Wm4
00025 {
00026
00027 template <class Real, class TVector>
00028 class WM4_FOUNDATION_ITEM Distance
00029 {
00030 public:
00031
00032 virtual ~Distance ();
00033
00034
00035 virtual Real Get () = 0;
00036 virtual Real GetSquared () = 0;
00037
00038
00039 virtual Real Get (Real fT, const TVector& rkVelocity0,
00040 const TVector& rkVelocity1) = 0;
00041 virtual Real GetSquared (Real fT, const TVector& rkVelocity0,
00042 const TVector& rkVelocity1) = 0;
00043
00044
00045
00046
00047
00048
00049 virtual Real GetDerivative (Real fT, const TVector& rkVelocity0,
00050 const TVector& rkVelocity1);
00051 virtual Real GetDerivativeSquared (Real fT, const TVector& rkVelocity0,
00052 const TVector& rkVelocity1);
00053
00054
00055
00056 virtual Real Get (Real fTMin, Real fTMax, const TVector& rkVelocity0,
00057 const TVector& rkVelocity1);
00058 virtual Real GetSquared (Real fTMin, Real fTMax,
00059 const TVector& rkVelocity0, const TVector& rkVelocity1);
00060
00061
00062 int MaximumIterations;
00063 Real ZeroThreshold;
00064
00065
00066 void SetDifferenceStep (Real fDifferenceStep);
00067 Real GetDifferenceStep () const;
00068
00069
00070 Real GetContactTime () const;
00071
00072
00073
00074
00075
00076
00077 const TVector& GetClosestPoint0 () const;
00078 const TVector& GetClosestPoint1 () const;
00079 bool HasMultipleClosestPoints0 () const;
00080 bool HasMultipleClosestPoints1 () const;
00081
00082 protected:
00083 Distance ();
00084
00085 Real m_fContactTime;
00086 TVector m_kClosestPoint0;
00087 TVector m_kClosestPoint1;
00088 bool m_bHasMultipleClosestPoints0;
00089 bool m_bHasMultipleClosestPoints1;
00090 Real m_fDifferenceStep, m_fInvTwoDifferenceStep;
00091 };
00092
00093 typedef Distance<float,Vector2f> Distance2f;
00094 typedef Distance<float,Vector3f> Distance3f;
00095 typedef Distance<double,Vector2d> Distance2d;
00096 typedef Distance<double,Vector3d> Distance3d;
00097
00098 }
00099
00100 #endif