Jafar
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Intersection2DImpl.hpp
00001 /* $ Id: $ */
00002 
00003 namespace jafar {
00004   namespace geom {
00005     template<>
00006     inline bool intersection( const Line<2>& l1, const Line<2>& l2, Atom<2>::HomogenousVecD& _vec )
00007     {
00008       typedef Atom<2>::HomogenousVecD HomogenousVec;
00009       HomogenousVec v1 = l1.pointAt(0.0); double x1 = v1(0); double y1 = v1(1);
00010       HomogenousVec v2 = l1.pointAt(1.0); double x2 = v2(0); double y2 = v2(1);
00011       HomogenousVec v3 = l2.pointAt(0.0); double x3 = v3(0); double y3 = v3(1);
00012       HomogenousVec v4 = l2.pointAt(1.0); double x4 = v4(0); double y4 = v4(1);
00013       double d = (x1 - x2)*(y3 - y4) - (y1 - y2)*(x3 - x4);
00014       if(fabs(d) < 1e-6) return false;
00015       _vec(2) = 1.0;
00016       double x1y2my1x2 = ( x1 * y2 - y1 * x2 );
00017       double x3y4my3x4 = ( x3 * y4 - y3 * x4 );
00018       _vec(0) = ( x1y2my1x2 * ( x3 - x4 ) - ( x1 - x2 ) * x3y4my3x4 ) / d;
00019       _vec(1) = ( x1y2my1x2 * ( y3 - y4 ) - ( y1 - y2 ) * x3y4my3x4 ) / d;
00020       return false;
00021     } 
00022 
00023   }
00024 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on Wed Oct 15 2014 00:37:19 for Jafar by doxygen 1.7.6.1
LAAS-CNRS