Wm4IntrTriangle2Triangle2.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 WM4INTRTRIANGLE2TRIANGLE2_H
00018 #define WM4INTRTRIANGLE2TRIANGLE2_H
00019
00020 #include "Wm4FoundationLIB.h"
00021 #include "Wm4Intersector.h"
00022 #include "Wm4Intersector1.h"
00023 #include "Wm4Triangle2.h"
00024
00025 namespace Wm4
00026 {
00027
00028 template <class Real>
00029 class WM4_FOUNDATION_ITEM IntrTriangle2Triangle2
00030 : public Intersector<Real,Vector2<Real> >
00031 {
00032 public:
00033 IntrTriangle2Triangle2 (const Triangle2<Real>& rkTriangle0,
00034 const Triangle2<Real>& rkTriangle1);
00035
00036
00037 const Triangle2<Real>& GetTriangle0 () const;
00038 const Triangle2<Real>& GetTriangle1 () const;
00039
00040
00041 virtual bool Test ();
00042 virtual bool Find ();
00043
00044
00045 virtual bool Test (Real fTMax, const Vector2<Real>& rkVelocity0,
00046 const Vector2<Real>& rkVelocity1);
00047 virtual bool Find (Real fTMax, const Vector2<Real>& rkVelocity0,
00048 const Vector2<Real>& rkVelocity1);
00049
00050
00051 int GetQuantity () const;
00052 const Vector2<Real>& GetPoint (int i) const;
00053
00054 private:
00055 using Intersector<Real,Vector2<Real> >::m_fContactTime;
00056
00057 static int WhichSide (const Vector2<Real> akV[3],
00058 const Vector2<Real>& rkP, const Vector2<Real>& rkD);
00059
00060 static void ClipConvexPolygonAgainstLine (const Vector2<Real>& rkN,
00061 Real fC, int& riQuantity, Vector2<Real> akV[6]);
00062
00063 enum ProjectionMap
00064 {
00065 M21,
00066 M12,
00067 M11
00068 };
00069
00070 class Configuration
00071 {
00072 public:
00073 ProjectionMap Map;
00074 int Index[3];
00075 Real Min, Max;
00076 };
00077
00078 void ComputeTwo (Configuration& rkCfg, const Vector2<Real> akV[3],
00079 const Vector2<Real>& rkD, int iI0, int iI1, int iI2);
00080
00081 void ComputeThree (Configuration& rkCfg, const Vector2<Real> akV[3],
00082 const Vector2<Real>& rkD, const Vector2<Real>& rkP);
00083
00084 static bool NoIntersect (const Configuration& rkCfg0,
00085 const Configuration& rkCfg1, Real fTMax, Real fSpeed, int& riSide,
00086 Configuration& rkTCfg0, Configuration& rkTCfg1, Real& rfTFirst,
00087 Real& rfTLast);
00088
00089 static void GetIntersection (const Configuration& rkCfg0,
00090 const Configuration& rkCfg1, int iSide, const Vector2<Real> akV0[3],
00091 const Vector2<Real> akV1[3], int& riQuantity,
00092 Vector2<Real> akVertex[6]);
00093
00094
00095 const Triangle2<Real>& m_rkTriangle0;
00096 const Triangle2<Real>& m_rkTriangle1;
00097
00098
00099 int m_iQuantity;
00100 Vector2<Real> m_akPoint[6];
00101 };
00102
00103 typedef IntrTriangle2Triangle2<float> IntrTriangle2Triangle2f;
00104 typedef IntrTriangle2Triangle2<double> IntrTriangle2Triangle2d;
00105
00106 }
00107
00108 #endif