Wm4IntrTriangle2Triangle2.h

Go to the documentation of this file.
00001 // Wild Magic Source Code
00002 // David Eberly
00003 // http://www.geometrictools.com
00004 // Copyright (c) 1998-2007
00005 //
00006 // This library is free software; you can redistribute it and/or modify it
00007 // under the terms of the GNU Lesser General Public License as published by
00008 // the Free Software Foundation; either version 2.1 of the License, or (at
00009 // your option) any later version.  The license is available for reading at
00010 // either of the locations:
00011 //     http://www.gnu.org/copyleft/lgpl.html
00012 //     http://www.geometrictools.com/License/WildMagicLicense.pdf
00013 // The license applies to versions 0 through 4 of Wild Magic.
00014 //
00015 // Version: 4.0.0 (2006/06/28)
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     // object access
00037     const Triangle2<Real>& GetTriangle0 () const;
00038     const Triangle2<Real>& GetTriangle1 () const;
00039 
00040     // static queries
00041     virtual bool Test ();
00042     virtual bool Find ();
00043 
00044     // dynamic queries
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     // information about the intersection set
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,  // 2 vertices map to min, 1 vertex maps to max
00066         M12,  // 1 vertex maps to min, 2 vertices map to max
00067         M11   // 1 vertex maps to min, 1 vertex maps to max
00068     };
00069 
00070     class Configuration
00071     {
00072     public:
00073         ProjectionMap Map;  // how vertices map to the projection interval
00074         int Index[3];       // the sorted indices of the vertices
00075         Real Min, Max;      // the interval is [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     // the objects to intersect
00095     const Triangle2<Real>& m_rkTriangle0;
00096     const Triangle2<Real>& m_rkTriangle1;
00097 
00098     // information about the intersection set
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

Generated on Wed Nov 23 19:01:04 2011 for FreeCAD by  doxygen 1.6.1