58 const int radius = 10;
61 CIRCLE circle( center, radius );
64 BOOST_CHECK_EQUAL( circle.
Radius, 10 );
72 BOOST_CHECK_EQUAL( circle.
Radius, 30 );
94 { { 100, 100 }, 200 },
100 { { 100, 100 }, 200 },
105 "0 deg, allowed tolerance pos",
106 { { 100, 100 }, 200 },
111 "0 deg, allowed tolerance neg",
112 { { 100, 100 }, 200 },
117 "0 deg, allowed tolerance pos + 1",
118 { { 100, 100 }, 200 },
123 "0 deg, allowed tolerance neg - 1",
124 { { 100, 100 }, 200 },
130 { { 100, 100 }, 200 },
135 "45 deg, allowed tolerance pos",
136 { { 100, 100 }, 200 },
141 "45 deg, allowed tolerance pos + 1",
142 { { 100, 100 }, 200 },
148 { { 100, 100 }, 200 },
154 { { 100, 100 }, 200 },
160 { { 100, 100 }, 200 },
172 BOOST_TEST_CONTEXT( c.m_case_name )
174 bool ret = c.m_circle.Contains( c.m_point );
175 BOOST_CHECK_EQUAL( ret, c.m_exp_result );
230 BOOST_TEST_CONTEXT( c.m_case_name )
232 VECTOR2I ret = c.m_circle.NearestPoint( c.m_point );
233 BOOST_CHECK_EQUAL( ret, c.m_exp_result );
274 "tangent aligned, external",
282 "tangent aligned, internal",
298 "KiROUND overflow 1",
299 { { 44798001, -94001999 }, 200001 },
300 { { 44797999, -94001999 }, 650001 },
306 "KiROUND overflow 2",
307 { { 50747999, -92402001 }, 650001 },
308 { { 50748001, -92402001 }, 200001 },
314 "KiROUND overflow 3",
315 { { 43947999, -92402001 }, 650001 },
316 { { 43948001, -92402001 }, 200001 },
322 "KiROUND overflow 4",
323 { { 46497999, -94001999 }, 200001 },
324 { { 46498001, -94001999 }, 650001 },
330 "Co-centered, same radius",
331 { { 205999999, 136367974 }, 3742026 },
332 { { 205999999, 136367974 }, 3742026 },
345 BOOST_TEST_CONTEXT( c.m_case_name +
" Case 1" )
347 std::vector<VECTOR2I> ret1 = c.m_circle1.Intersect( c.m_circle2 );
348 BOOST_CHECK_EQUAL( c.m_exp_result.size(), ret1.size() );
352 BOOST_TEST_CONTEXT( c.m_case_name +
" Case 2" )
355 std::vector<VECTOR2I> ret2 = c.m_circle2.Intersect( c.m_circle1 );
356 BOOST_CHECK_EQUAL( c.m_exp_result.size(), ret2.size() );
382 { { 10, -40 }, {10, 40} },
391 { { -20, -40 }, {20, 40} },
400 { { 20, 0 }, {20, 40} },
408 { { 25, 0 }, {25, 40} },
414 "no intersection: seg end points inside circle",
416 { { 0, 10 }, {0, -10} },
429 BOOST_TEST_CONTEXT( c.m_case_name )
431 std::vector<VECTOR2I> ret = c.m_circle.Intersect( c.m_seg );
432 BOOST_CHECK_EQUAL( c.m_exp_result.size(), ret.size() );
447 { { 10, 45 }, {10, 40} },
456 { { -20, -40 }, {20, 40} },
465 { { 20, 0 }, {20, 40} },
473 { { 25, 0 }, {25, 40} },
479 "intersection, seg end points inside circle",
481 { { 0, 10 }, {0, -10} },
495 BOOST_TEST_CONTEXT( c.m_case_name )
497 std::vector<VECTOR2I> ret = c.m_circle.IntersectLine( c.m_seg );
498 BOOST_CHECK_EQUAL( c.m_exp_result.size(), ret.size() );
524 "90 degree segs, point on seg",
525 { { 0, 0 }, { 0, 1000 } },
526 { { 0, 0 }, { 1000, 0 } },
528 { { 400, 400} , 400 },
531 "90 degree segs, point floating",
532 { { 0, 0 }, { 0, 1000 } },
533 { { 0, 0 }, { 1000, 0 } },
535 { { 500, 500} , 500 },
538 "45 degree segs, point on seg",
539 { { 0, 0 }, { 1000, 0 } },
540 { { 0, 0 }, { 1000, 1000 } },
542 { { 400, 166} , 166 },
545 "45 degree segs, point floating",
546 { { 0, 0 }, { 1000000, 0 } },
547 { { 0, 0 }, { 1000000, 1000000 } },
549 { { 332439, 137701} , 137701 },
552 "135 degree segs, point on seg",
553 { { 0, 0 }, { 1000000, 0 } },
554 { { 0, 0 }, { -1000000, 1000000 } },
556 { { 400009, 965709 } , 965709 },
560 "135 degree segs, point floating",
561 { { 0, 0 }, { 1000, 0 } },
562 { { 0, 0 }, { -1000, 1000 } },
564 { { 814, 1964} , 1964 },
568 "point on intersection",
569 { { 10, 0 }, { 1000, 0 } },
570 { { 10, 0 }, { -1000, 1000 } },
582 BOOST_TEST_CONTEXT( c.m_case_name )
587 "\nCenter point mismatch: "
588 <<
"\n Got: " << circle.
Center
589 <<
"\n Expected: " << c.m_exp_result.Center );
592 "\nRadius mismatch: "
593 <<
"\n Got: " << circle.
Radius
594 <<
"\n Expected: " << c.m_exp_result.Radius );
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Represent basic circle geometry with utility geometry functions.
VECTOR2I Center
Public to make access simpler.
int Radius
Public to make access simpler.
CIRCLE & ConstructFromTanTanPt(const SEG &aLineA, const SEG &aLineB, const VECTOR2I &aP)
Construct this circle such that it is tangent to the given segments and passes through the given poin...
static const int MIN_PRECISION_IU
This is the minimum precision for all the points in a shape.
void CheckUnorderedMatches(const EXP_CONT &aExpected, const FOUND_CONT &aFound, MATCH_PRED aMatchPredicate)
Check that a container of "found" objects matches a container of "expected" objects.
Struct to hold test cases for two circles, and an vector of points.
std::vector< VECTOR2I > m_exp_result
Struct to hold test cases for a given circle, a point and an expected return boolean.
Struct to hold test cases for a given circle, a point and an expected return point.
Struct to hold test cases for two lines, a point and an expected returned circle.
Struct to hold test cases for a circle, a line and an expected vector of points.
std::vector< VECTOR2I > m_exp_result
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
bool CompareLength(int aLengthA, int aLengthB)
static const std::vector< CIR_SEG_VECPT_CASE > construct_tan_tan_pt_cases
Test cases for #CIRCLE::Intersect( const SEG& aSeg )
BOOST_AUTO_TEST_CASE(ParameterCtorMod)
Checks whether the construction of a circle referencing external parameters works and that the parame...
bool CompareVector2I(const VECTOR2I &aVecA, const VECTOR2I &aVecB)
static const std::vector< CIR_PT_PT_CASE > nearest_point_cases
Test cases for CIRCLE::NearestPoint.
static const std::vector< CIR_CIR_VECPT_CASE > intersect_circle_cases
Test cases for #CIRCLE::Intersect( const CIRCLE& aCircle )
static const std::vector< SEG_SEG_VECPT_CASE > intersect_line_cases
Test cases for #CIRCLE::IntersectLine( const SEG& aSeg )
static const std::vector< SEG_SEG_VECPT_CASE > intersect_seg_cases
Test cases for #CIRCLE::Intersect( const SEG& aSeg )
const int MIN_PRECISION_45DEG
static const std::vector< CIR_PT_BOOL_CASE > contains_cases
Test cases for CIRCLE::Contains.
BOOST_AUTO_TEST_SUITE_END()
VECTOR2< int32_t > VECTOR2I