From 819bdf4372c53930b2e068af3c509a1ef688a35f Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Tue, 21 May 2024 16:25:44 -0700 Subject: [PATCH] Fix qa failure --- libs/kimath/src/geometry/shape_arc.cpp | 4 +++- qa/tests/libs/kimath/geometry/test_shape_arc.cpp | 8 +++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/libs/kimath/src/geometry/shape_arc.cpp b/libs/kimath/src/geometry/shape_arc.cpp index 81dd605397..531972bbe1 100644 --- a/libs/kimath/src/geometry/shape_arc.cpp +++ b/libs/kimath/src/geometry/shape_arc.cpp @@ -444,7 +444,9 @@ bool SHAPE_ARC::Collide( const VECTOR2I& aP, int aClearance, int* aActual, if( !dist ) { - dist = radius - ( aP - center ).EuclideanNorm(); + // Be sure to keep the sqrt of the squared distance instead of allowing a EuclideanNorm + // because this trucates the distance to an integer before subtracting + dist = KiROUND( radius - sqrt( ( aP - center ).SquaredEuclideanNorm() ) ); nearestPt = center + VECTOR2I( radius, 0 ); RotatePoint( nearestPt, center, angleToPt ); } diff --git a/qa/tests/libs/kimath/geometry/test_shape_arc.cpp b/qa/tests/libs/kimath/geometry/test_shape_arc.cpp index f1b8c373d4..7fe4a7565c 100644 --- a/qa/tests/libs/kimath/geometry/test_shape_arc.cpp +++ b/qa/tests/libs/kimath/geometry/test_shape_arc.cpp @@ -597,12 +597,18 @@ static const std::vector arc_pt_collide_cases = { { " -90deg, 0 cl, 90 deg ", { { 0, 0 }, { 71, 71 }, -90.0 }, 0, { 71, 71 }, true, 0 }, { " -90deg, 0 cl, 135 deg ", { { 0, 0 }, { 71, 71 }, -90.0 }, 0, { 0, -100 }, false, -1 }, { " -90deg, 0 cl, -45 deg ", { { 0, 0 }, { 71, 71 }, -90.0 }, 0, { 0, 100 }, false, -1 }, - { "issue 11358", + { "issue 11358 collide", { { 119888000, 60452000 }, { 120904000, 60452000 }, 360.0 }, 0, { 120395500, 59571830 }, true, 0 }, + { "issue 11358 dist", + { { 119888000, 60452000 }, { 120904000, 60452000 }, 360.0 }, + 100, + { 118872050, 60452000 }, + true, + 50 }, };