27 #include "linearAlgebra/WLinearAlgebra.h"
28 #include "../WAssert.h"
29 #include "../WLimits.h"
36 double r1 = dot( normal, p1 - planePoint );
37 double r2 = dot( normal, p2 - planePoint );
38 double r3 = dot( normal, p3 - planePoint );
41 if( std::abs( ( ( r1 > 0 ) - ( r1 < 0 ) ) + ( ( r2 > 0) - ( r2 < 0 ) ) + ( ( r3 > 0 ) - ( r3 < 0 ) ) ) == 3 )
48 bool intersectPlaneSegment(
const WPlane& p,
51 boost::shared_ptr< WPosition > pointOfIntersection )
55 WAssert( pointOfIntersection.get(),
"Place to store a point of intersection is not ready!" );
61 *pointOfIntersection = p1;
66 *pointOfIntersection = p2;
75 double const t = ( d - dot( normal, p2 ) ) / ( dot( normal, p1 - p2 ) );
77 *pointOfIntersection = p2 + t * ( p1 - p2 );
86 bool intersectPlaneLineNearCP(
const WPlane& p,
const WLine& l, boost::shared_ptr< WPosition > cutPoint )
90 WAssert( cutPoint.get(),
"Place to store a point of intersection is not ready!" );
92 for(
size_t i = 1; i < l.
size(); ++i )
94 boost::shared_ptr< WPosition > cP(
new WPosition( 0, 0, 0 ) );
95 if( intersectPlaneSegment( p, l[i-1], l[i], cP ) )
99 if( dist < minDistance )