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