Add test case for SHAPE_ARC::Collide( seg ) + remove unneeded candidates

Followup to commit 01068e0d41
This commit is contained in:
Roberto Fernandez Bautista 2021-12-13 18:06:11 +00:00
parent 007b3bdbcc
commit b4835c8208
2 changed files with 3 additions and 3 deletions

View File

@ -237,15 +237,13 @@ bool SHAPE_ARC::Collide( const SEG& aSeg, int aClearance, int* aActual, VECTOR2I
// Possible points of the collision are:
// 1. Intersetion of the segment with the full circle
// 2. Closest point on the segment to the center of the circle
// 3. End points of the segment
// 3. Closest point on the segment to the end points of the arc
std::vector<VECTOR2I> candidatePts = circle.Intersect( aSeg );
candidatePts.push_back( aSeg.NearestPoint( center ) );
candidatePts.push_back( aSeg.NearestPoint( m_start ) );
candidatePts.push_back( aSeg.NearestPoint( m_end ) );
candidatePts.push_back( aSeg.A );
candidatePts.push_back( aSeg.B );
for( const VECTOR2I& candidate : candidatePts )
{

View File

@ -648,6 +648,8 @@ static const std::vector<ARC_SEG_COLLIDE_CASE> arc_seg_collide_cases = {
{ "270 deg ", { { 0, 0 }, { 100, 0 }, 270.0 }, 0, { { 0, -100 }, { 0, -50 } }, true, 0 },
{ "45 deg ", { { 0, 0 }, { 100, 0 }, 270.0 }, 0, { { 71, 71 }, { 35, 35 } }, true, 0 },
{ "-45 deg ", { { 0, 0 }, { 100, 0 }, 270.0 }, 0, { { 71, -71 }, { 35, -35 } }, false, -1 },
{ "edge case - large diameter arc", { { 172367922, 82282076 }, { 162530000, 92120000 }, -45.0 },
433300, { { 162096732, 92331236 }, { 162096732, 78253268 } }, true, 433268 },
};