proj home

Files   Classes   Functions   Hierarchy  

d2simplexSeparateAxis.cpp

Go to the documentation of this file.
00001 #include <halfspaceD2.h>
00002 
00003 #include <d2simplexSeparateAxis.h>
00004 
00005 typedef point2<double> pt2;
00006 
00007 //template<>
00008 //double const halfspaceD2<point2<double>,double>::zero = 1E-15;
00009 
00010 bool const d2simplexSeparateAxis::intersects(d2simplex const & s2) const
00011 {
00012   if (sees(s2))
00013     return false;
00014 
00015   // Upcast - but unusual because only uses base classes data.
00016   //   The functionality was not put in the base class because
00017   //   it is specialized.
00018   d2simplexSeparateAxis * p = (d2simplexSeparateAxis*)(& s2);
00019 
00020   return ! p->sees(*this);
00021 }
00022 
00023 bool const d2simplexSeparateAxis::sees(d2simplex const & s2) const
00024 {
00025   bool flag;
00026   uint k;
00027 
00028   for (uint i=0; i<3; ++i)
00029   {
00030     halfspaceD2<pt2,double> h(v[i],v[(i+2)%3]);
00031     flag=true;
00032     k=0;
00033     for (; flag&&(k<3); ++k)
00034     {
00035       if (h.isInside(s2.v[k])==false)
00036         flag=false;
00037     
00038     }
00039     if (flag==true)
00040       return true;
00041   }
00042 
00043   return false;
00044 }
00045 
00046 
00047 

Generated on Fri Mar 4 00:49:27 2011 for Chelton Evans Source by  doxygen 1.5.8