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
(cherry picked from commit 1fda68099f
)
This commit is contained in:
parent
8619705e44
commit
6116eebbad
|
@ -46,6 +46,7 @@ int GetArcToSegmentCount( int aRadius, int aErrorMax, const EDA_ANGLE& aArcAngle
|
||||||
|
|
||||||
// avoid divide-by-zero
|
// avoid divide-by-zero
|
||||||
aRadius = std::max( 1, aRadius );
|
aRadius = std::max( 1, aRadius );
|
||||||
|
aErrorMax = std::max( 1, aErrorMax );
|
||||||
|
|
||||||
// error relative to the radius value:
|
// error relative to the radius value:
|
||||||
double rel_error = (double)aErrorMax / aRadius;
|
double rel_error = (double)aErrorMax / aRadius;
|
||||||
|
|
Loading…
Reference in New Issue