From 6e8f06e0429d44b615e338ce0ff4a85d8141f802 Mon Sep 17 00:00:00 2001 From: Ian McInerney Date: Sat, 11 Jan 2020 21:27:38 +0000 Subject: [PATCH] Fixup some issues in libkimath * Perform floating-point computations when needed * Specify to use the default equality operator --- libs/kimath/include/geometry/shape_circle.h | 2 ++ libs/kimath/src/convert_basic_shapes_to_polygon.cpp | 4 ++-- libs/kimath/src/trigo.cpp | 8 ++++---- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/libs/kimath/include/geometry/shape_circle.h b/libs/kimath/include/geometry/shape_circle.h index c77aed1931..34450fc738 100644 --- a/libs/kimath/include/geometry/shape_circle.h +++ b/libs/kimath/include/geometry/shape_circle.h @@ -54,6 +54,8 @@ public: return new SHAPE_CIRCLE( *this ); } + SHAPE_CIRCLE& operator=( const SHAPE_CIRCLE& ) = default; + const BOX2I BBox( int aClearance = 0 ) const override { const VECTOR2I rc( m_radius + aClearance, m_radius + aClearance ); diff --git a/libs/kimath/src/convert_basic_shapes_to_polygon.cpp b/libs/kimath/src/convert_basic_shapes_to_polygon.cpp index e0ef8a2752..4ebad3922f 100644 --- a/libs/kimath/src/convert_basic_shapes_to_polygon.cpp +++ b/libs/kimath/src/convert_basic_shapes_to_polygon.cpp @@ -47,7 +47,7 @@ void TransformCircleToPolygon( SHAPE_LINE_CHAIN& aBuffer, int delta = 3600 / numSegs; // rotate angle in 0.1 degree double correction = GetCircletoPolyCorrectionFactor( numSegs ); int radius = aRadius * correction; // make segments outside the circles - double halfstep = delta/2; // the starting value for rot angles + double halfstep = delta/2.0; // the starting value for rot angles for( int ii = 0; ii < numSegs; ii++ ) { @@ -71,7 +71,7 @@ void TransformCircleToPolygon( SHAPE_POLY_SET& aCornerBuffer, wxPoint aCenter, i int delta = 3600 / numSegs; // rotate angle in 0.1 degree double correction = GetCircletoPolyCorrectionFactor( numSegs ); int radius = aRadius * correction; // make segments outside the circles - double halfstep = delta/2; // the starting value for rot angles + double halfstep = delta/2.0; // the starting value for rot angles aCornerBuffer.NewOutline(); diff --git a/libs/kimath/src/trigo.cpp b/libs/kimath/src/trigo.cpp index ef1a2f4793..f24942da9e 100644 --- a/libs/kimath/src/trigo.cpp +++ b/libs/kimath/src/trigo.cpp @@ -387,16 +387,16 @@ const VECTOR2I GetArcCenter( const VECTOR2I& aStart, const VECTOR2I& aMid, const bSlope * ( aStart.x + aMid.x ) - aSlope * ( aMid.x + aEnd.x ) ) / ( 2 * ( bSlope - aSlope ) ); - center.x = KiROUND( Clamp( double( std::numeric_limits::min() / 2 ), + center.x = KiROUND( Clamp( double( std::numeric_limits::min() / 2.0 ), result, - double( std::numeric_limits::max() / 2 ) ) ); + double( std::numeric_limits::max() / 2.0 ) ) ); result = ( ( ( aStart.x + aMid.x ) / 2.0 - center.x ) / aSlope + ( aStart.y + aMid.y ) / 2.0 ); - center.y = KiROUND( Clamp( double( std::numeric_limits::min() / 2 ), + center.y = KiROUND( Clamp( double( std::numeric_limits::min() / 2.0 ), result, - double( std::numeric_limits::max() / 2 ) ) ); + double( std::numeric_limits::max() / 2.0 ) ) ); return center; }