Prevent inf when presented with 0 errormax

acos(1) returns 0, so this implies infinite segements to get to 0 error.
This is not reasonable but might be encountered in bad arcs or circles
that have 0 radius.  Instead of returning infinite or std::max segments,
we limit the error to be at least 1 IU
This commit is contained in:
Seth Hillbrand 2023-03-02 10:17:46 -08:00
parent f41f04b301
commit 1fda68099f
1 changed files with 1 additions and 0 deletions

View File

@ -46,6 +46,7 @@ int GetArcToSegmentCount( int aRadius, int aErrorMax, const EDA_ANGLE& aArcAngle
// avoid divide-by-zero
aRadius = std::max( 1, aRadius );
aErrorMax = std::max( 1, aErrorMax );
// error relative to the radius value:
double rel_error = (double)aErrorMax / aRadius;