From b4835c82085a074c0ee00247504055ee063da963 Mon Sep 17 00:00:00 2001 From: Roberto Fernandez Bautista Date: Mon, 13 Dec 2021 18:06:11 +0000 Subject: [PATCH] Add test case for SHAPE_ARC::Collide( seg ) + remove unneeded candidates Followup to commit 01068e0d416ddc6203d6b9e7f3b9c169f62c3d98 --- libs/kimath/src/geometry/shape_arc.cpp | 4 +--- qa/libs/kimath/geometry/test_shape_arc.cpp | 2 ++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libs/kimath/src/geometry/shape_arc.cpp b/libs/kimath/src/geometry/shape_arc.cpp index 90bcde7225..62608512e6 100644 --- a/libs/kimath/src/geometry/shape_arc.cpp +++ b/libs/kimath/src/geometry/shape_arc.cpp @@ -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 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 ) { diff --git a/qa/libs/kimath/geometry/test_shape_arc.cpp b/qa/libs/kimath/geometry/test_shape_arc.cpp index 67806c2827..7d200dc35d 100644 --- a/qa/libs/kimath/geometry/test_shape_arc.cpp +++ b/qa/libs/kimath/geometry/test_shape_arc.cpp @@ -648,6 +648,8 @@ static const std::vector 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 }, };