30 #include <cxxtest/TestSuite.h>
33 #include "../../WLimits.h"
34 #include "WPositionTraits.h"
81 boost::shared_ptr< WPosition > cutPoint(
new WPosition( 0, 0, 0 ) );
82 bool actual = intersectPlaneSegment( p,
WPosition( 3, 0, 1 ),
WPosition( 1, 0, -1 ), cutPoint );
83 TS_ASSERT_EQUALS( actual,
true );
84 TS_ASSERT_EQUALS( *cutPoint,
WPosition( 2, 0, 0 ) );
85 actual = intersectPlaneSegment( p,
WPosition( 1, 0, -1 ),
WPosition( 3, 0, 1 ), cutPoint );
86 TS_ASSERT_EQUALS( actual,
true );
87 TS_ASSERT_EQUALS( *cutPoint,
WPosition( 2, 0, 0 ) );
97 boost::shared_ptr< WPosition > cutPoint(
new WPosition( 0, 0, 0 ) );
98 bool actual = intersectPlaneSegment( p,
101 TS_ASSERT_EQUALS( actual,
false );
102 TS_ASSERT_EQUALS( *cutPoint,
WPosition( 0, 0, 0 ) );
112 boost::shared_ptr< WPosition > cutPoint(
new WPosition( 0, 0, 0 ) );
114 TS_ASSERT_EQUALS( actual,
true );
119 TS_ASSERT_EQUALS( actual,
true );
133 boost::shared_ptr< WPosition > cutPoint(
new WPosition( 0, 0, 0 ) );
134 bool actual = intersectPlaneSegment( p,
WPosition( 3, 0, 0 ),
WPosition( 1, 0, 0 ), cutPoint );
135 TS_ASSERT_EQUALS( actual,
true );
136 TS_ASSERT_EQUALS( *cutPoint,
WPosition( 3, 0, 0 ) );
137 actual = intersectPlaneSegment( p,
WPosition( 1, 0, 0 ),
WPosition( 3, 0, 0 ), cutPoint );
138 TS_ASSERT_EQUALS( actual,
true );
139 TS_ASSERT_EQUALS( *cutPoint,
WPosition( 1, 0, 0 ) );
155 boost::shared_ptr< WPosition > cutPoint(
new WPosition( 0, 0, 0 ) );
156 bool actual = intersectPlaneLineNearCP( p, l, cutPoint );
176 boost::shared_ptr< WPosition > cutPoint(
new WPosition( 0, 0, 0 ) );
177 bool actual = intersectPlaneLineNearCP( p, l, cutPoint );
178 TS_ASSERT( !actual );
180 actual = intersectPlaneLineNearCP( q, l, cutPoint );
181 TS_ASSERT( !actual );
197 boost::shared_ptr< WPosition > cutPoint(
new WPosition( 0, 0, 0 ) );
198 bool actual = intersectPlaneLineNearCP( p, l, cutPoint );
218 boost::shared_ptr< WPosition > cutPoint(
new WPosition( 0, 0, 0 ) );
219 bool actual = intersectPlaneLineNearCP( p, l, cutPoint );
238 boost::shared_ptr< WPosition > cutPoint(
new WPosition( 0, 0, 0 ) );
239 bool actual = intersectPlaneLineNearCP( p, l, cutPoint );
245 actual = intersectPlaneLineNearCP( q, l, cutPoint );
258 TS_ASSERT_EQUALS( factorial( 0 ), 1 );
259 TS_ASSERT_EQUALS( factorial( 1 ), 1 );
260 TS_ASSERT_EQUALS( factorial( 2 ), 2 );
261 TS_ASSERT_EQUALS( factorial( 3 ), 6 );
262 TS_ASSERT_EQUALS( factorial( 4 ), 24 );
263 TS_ASSERT_EQUALS( factorial( 5 ), 120 );
264 TS_ASSERT_EQUALS( factorial( 6 ), 720 );
265 TS_ASSERT_EQUALS( factorial( 7 ), 5040 );
266 TS_ASSERT_EQUALS( factorial( 8 ), 40320 );
274 TS_ASSERT_EQUALS( areEqual( 1.0, 1.0 ),
true );
275 TS_ASSERT_EQUALS( areEqual( 1.0, 1.0, 1e-3 ),
true );
276 TS_ASSERT_EQUALS( areEqual( 1.0, 1.0+1e-3, 1e-3 ),
true );
277 TS_ASSERT_EQUALS( areEqual( 1.0, 1.0+2e-3, 1e-3 ),
false );
278 TS_ASSERT_EQUALS( areEqual( 1.0, 1.0+1e-3 ),
false );
282 #endif // WMATH_TEST_H
A line is an ordered sequence of WPositions.
void testNoIntersectionOfPlaneWithSegment(void)
If there is no intersection at all the position 0,0,0 should be written into the point of intersectio...
Unit tests wmath's helper functions.
void push_back(const value_type &value)
Wrapper around std::vector member function.
void testTrianglePlaneIntersectionWithNoPointInPlane(void)
If no point is in plane but at not all are on one side the trinagle intersects.
void testIntersectionOfPlaneWithLine(void)
If a set of consecutive segements (aka line) is tested again intersection with that plane...
This only is a 3d double vector.
Represents a plane with a normal vector and a position in space.
const double DBL_EPS
Smallest double such: 1.0 + DBL_EPS == 1.0 is still true.
void testIntersectionOfPlaneWithSegmentInPlane(void)
If the segment is totally inside of the plane, the first point must be returned which is actually one...
void testMultipleIntersectionPlaneLine(void)
If many points of intersection occurs the closest to the base point should be selected and return tru...
void testIntersectionOfPlaneWithSegment(void)
The intersection of a plane plane with a segment, having a starting and an endpoint.
void testNoIntersectionOfPlaneWithLine(void)
If none of the segments of the line intersects with the plane, false and 0,0,0 should be returned...
void testIntersectionPlaneLineWithJustOnePoint(void)
If an endpoint of a line intersects with the plane, this point should be returned and ofcourse true...
void testFactorials(void)
Test the factorial calculation.
void testIntersectionPlaneLineWithSegmentInPlane(void)
If a whole segment of the line is insisde that plane the first point should be returned along with tr...
void testTrianglePlaneIntersectionWithPointsInPlane(void)
If some points are inside the plane the triangle is considered to intersect with that plane...
void testAreEqual(void)
Test the areEqual function.
void testTrianglePlaneIntersectionWithAllPointsOnOneSide(void)
If all point are on one side of the plane no intersection can take place.
void testIntersectionOfPlaneWithSegmentHavingOnePointInPlane(void)
If an endpoint is inside of the plane then a point of intersection must exists and true must be retur...