Browse Source

Fixup some issues in libkimath

* Perform floating-point computations when needed
* Specify to use the default equality operator
merge-requests/53/merge
Ian McInerney 6 years ago
parent
commit
6e8f06e042
  1. 2
      libs/kimath/include/geometry/shape_circle.h
  2. 4
      libs/kimath/src/convert_basic_shapes_to_polygon.cpp
  3. 8
      libs/kimath/src/trigo.cpp

2
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 );

4
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();

8
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>( double( std::numeric_limits<int>::min() / 2 ),
center.x = KiROUND( Clamp<double>( double( std::numeric_limits<int>::min() / 2.0 ),
result,
double( std::numeric_limits<int>::max() / 2 ) ) );
double( std::numeric_limits<int>::max() / 2.0 ) ) );
result = ( ( ( aStart.x + aMid.x ) / 2.0 - center.x ) / aSlope +
( aStart.y + aMid.y ) / 2.0 );
center.y = KiROUND( Clamp<double>( double( std::numeric_limits<int>::min() / 2 ),
center.y = KiROUND( Clamp<double>( double( std::numeric_limits<int>::min() / 2.0 ),
result,
double( std::numeric_limits<int>::max() / 2 ) ) );
double( std::numeric_limits<int>::max() / 2.0 ) ) );
return center;
}
Loading…
Cancel
Save