diff --git a/libs/kimath/src/geometry/circle.cpp b/libs/kimath/src/geometry/circle.cpp index c4cf7e5f52..eb0bd2a4ac 100644 --- a/libs/kimath/src/geometry/circle.cpp +++ b/libs/kimath/src/geometry/circle.cpp @@ -149,7 +149,7 @@ CIRCLE& CIRCLE::ConstructFromTanTanPt( const SEG& aLineA, const SEG& aLineB, con VECTOR2I hTanLineB = aLineB.LineProject( hSolution.Center ); // To minimise errors, use the furthest away tangent point from aP - if( ( hTanLineA - aP ).EuclideanNorm() > ( hTanLineB - aP ).EuclideanNorm() ) + if( ( hTanLineA - aP ).SquaredEuclideanNorm() > ( hTanLineB - aP ).SquaredEuclideanNorm() ) { // Find the tangent at line A by homothetic inversion SEG hT( hTanLineA, hSelected ); @@ -187,7 +187,7 @@ CIRCLE& CIRCLE::ConstructFromTanTanPt( const SEG& aLineA, const SEG& aLineB, con bool CIRCLE::Contains( const VECTOR2I& aP ) const { - int distance = ( aP - Center ).EuclideanNorm(); + int64_t distance = VECTOR2L( aP - Center ).EuclideanNorm(); return distance <= ( (int64_t) Radius + SHAPE::MIN_PRECISION_IU ) && distance >= ( (int64_t) Radius - SHAPE::MIN_PRECISION_IU ); @@ -244,7 +244,7 @@ std::vector CIRCLE::Intersect( const CIRCLE& aCircle ) const std::vector retval; VECTOR2I vecCtoC = aCircle.Center - Center; - int64_t d = vecCtoC.EuclideanNorm(); + int64_t d = VECTOR2L( vecCtoC ).EuclideanNorm(); int64_t r1 = Radius; int64_t r2 = aCircle.Radius; @@ -324,7 +324,7 @@ std::vector CIRCLE::IntersectLine( const SEG& aLine ) const // VECTOR2I m = aLine.LineProject( Center ); // O projected perpendicularly to the line - int64_t omDist = ( m - Center ).EuclideanNorm(); + int64_t omDist = VECTOR2L( m - Center ).EuclideanNorm(); if( omDist > ( (int64_t) Radius + SHAPE::MIN_PRECISION_IU ) ) { diff --git a/libs/kimath/src/geometry/shape_arc.cpp b/libs/kimath/src/geometry/shape_arc.cpp index 267466efb3..3a95723a27 100644 --- a/libs/kimath/src/geometry/shape_arc.cpp +++ b/libs/kimath/src/geometry/shape_arc.cpp @@ -244,7 +244,7 @@ SHAPE_ARC& SHAPE_ARC::ConstructFromStartEndCenter( const VECTOR2I& aStart, const bool SHAPE_ARC::Collide( const SEG& aSeg, int aClearance, int* aActual, VECTOR2I* aLocation ) const { VECTOR2I center = GetCenter(); - double radius = ( center - m_start ).EuclideanNorm(); + double radius = VECTOR2D( center - m_start ).EuclideanNorm(); SHAPE_CIRCLE circle( center, radius ); ecoord clearance_sq = SEG::Square( aClearance ); @@ -430,7 +430,7 @@ bool SHAPE_ARC::Collide( const VECTOR2I& aP, int aClearance, int* aActual, return false; VECTOR2L center = GetCenter(); - double radius = ( center - m_start ).EuclideanNorm(); + double radius = VECTOR2D( center - m_start ).EuclideanNorm(); CIRCLE fullCircle( center, radius ); VECTOR2D nearestPt = fullCircle.NearestPoint( VECTOR2D( aP ) ); int dist = KiROUND( nearestPt.Distance( aP ) );