Commit 54f2f844 authored by Ulrich Kemloh's avatar Ulrich Kemloh

added failing testcases for IsInLineSegment. Must be a numerical issue.

parent e672edd3
......@@ -94,7 +94,17 @@ BOOST_AUTO_TEST_CASE(LINE_ISINLINESEGMENT_TEST)
for (int i = 0; i < 20; ++i)
BOOST_CHECK(!L1.IsInLineSegment(Point(i, i)));
Point P1 (30.1379, 124.485);
Point P2 (41.4647, 124.485);
Point P3 (38.4046,104.715);
Point P4 (33.7146,104.715);
Line L2(P1,P2);
Line L3(P3,P4);
BOOST_CHECK(L2.IsInLineSegment(P3)==false);
BOOST_CHECK(L2.IsInLineSegment(P4)==false);
BOOST_CHECK(L3.IsInLineSegment(P1)==false);
BOOST_CHECK(L3.IsInLineSegment(P2)==false);
BOOST_MESSAGE("Leaving is_in_linesegment test");
}
......@@ -148,4 +158,4 @@ BOOST_AUTO_TEST_CASE(LINE_LENGTH_TEST)
}
}
BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file
BOOST_AUTO_TEST_SUITE_END()
......@@ -241,7 +241,7 @@ Point Line::ShortestPoint(const Point &p) const {
* */
bool Line::IsInLineSegment(const Point &p) const
{
/*
Point differenceTwoAndOne = _point2 - _point1;
Point differencePAndOne = p - _point1;
......@@ -252,8 +252,8 @@ bool Line::IsInLineSegment(const Point &p) const
// dotproduct and distSquared to check if point is in segment and not just in line
double dotp = differencePAndOne.ScalarProduct(differenceTwoAndOne);
return !(dotp < 0 || (differenceTwoAndOne).NormSquare() < dotp);
*/
return fabs( (_point1-p ).Norm() + (_point2-p ).Norm() - (_point2-_point1 ).Norm() )<J_EPS;
//return fabs( (_point1-p ).Norm() + (_point2-p ).Norm() - (_point2-_point1 ).Norm() )<J_EPS;
}
/* Berechnet direkt den Abstand von p zum Segment l
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment