27 #include "../WAssert.h"
28 #include "../WLimits.h"
31 #include "linearAlgebra/WPosition.h"
32 #include "linearAlgebra/WVectorFixed.h"
39 double r1 = dot( normal, p1 - planePoint );
40 double r2 = dot( normal, p2 - planePoint );
41 double r3 = dot( normal, p3 - planePoint );
44 if( std::abs( ( ( r1 > 0 ) - ( r1 < 0 ) ) + ( ( r2 > 0 ) - ( r2 < 0 ) ) + ( ( r3 > 0 ) - ( r3 < 0 ) ) ) == 3 )
51 bool intersectPlaneSegment(
const WPlane& p,
54 std::shared_ptr< WPosition > pointOfIntersection )
58 WAssert( pointOfIntersection.get(),
"Place to store a point of intersection is not ready!" );
64 *pointOfIntersection = p1;
69 *pointOfIntersection = p2;
78 double const t = ( d - dot( normal, p2 ) ) / ( dot( normal, p1 - p2 ) );
80 *pointOfIntersection = p2 + t * ( p1 - p2 );
89 bool intersectPlaneLineNearCP(
const WPlane& p,
const WLine& l, std::shared_ptr< WPosition > cutPoint )
93 WAssert( cutPoint.get(),
"Place to store a point of intersection is not ready!" );
95 for(
size_t i = 1; i < l.
size(); ++i )
97 std::shared_ptr< WPosition > cP(
new WPosition( 0, 0, 0 ) );
98 if( intersectPlaneSegment( p, l[i-1], l[i], cP ) )
102 if( dist < minDistance )
A line is an ordered sequence of WPositions.
size_type size() const
Wrapper around std::vector member function.
Represents a plane with a normal vector and a position in space.
const WPosition & getPosition() const
Returns a point in that plane.
const WVector3d & getNormal() const
Returns the normal of the plane.
This only is a 3d double vector.
const double MAX_DOUBLE
Maximum double value.
const double DBL_EPS
Smallest double such: 1.0 + DBL_EPS == 1.0 is still true.