mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-09-14 02:03:12 +02:00
QA: Fix angle-equality predicate
This was sometimes accepting a wrong value on the "other side" of the correct value. Only actually affected one test, which is fixed.
This commit is contained in:
parent
d8a935be1c
commit
1ad03f5717
@ -39,14 +39,18 @@ namespace KI_TEST
|
||||
*
|
||||
* @return value is in [( aNominal - aError ) % aWrap, ( aNominal + aError ) % aWrap]
|
||||
*/
|
||||
template <typename T> bool IsWithinWrapped( T aValue, T aNominal, T aWrap, T aError )
|
||||
template <typename T>
|
||||
bool IsWithinWrapped( T aValue, T aNominal, T aWrap, T aError )
|
||||
{
|
||||
double diff = std::fmod( aNominal - aValue + aWrap / 2.0, aWrap );
|
||||
// Compute shortest signed distance on a ring
|
||||
double diff = std::fmod( static_cast<double>( aValue - aNominal ), static_cast<double>( aWrap ) );
|
||||
|
||||
if( diff < 0 )
|
||||
if( diff > aWrap / 2.0 )
|
||||
diff -= aWrap;
|
||||
else if( diff < -aWrap / 2.0 )
|
||||
diff += aWrap;
|
||||
|
||||
return diff - aWrap / 2.0 <= aError;
|
||||
return std::abs( diff ) <= aError;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -62,7 +62,7 @@ static void CheckArcGeom( const SHAPE_ARC& aArc, const ARC_PROPERTIES& aProps, c
|
||||
{
|
||||
// Angular error - note this can get quite large for very small arcs,
|
||||
// as the integral position rounding has a relatively greater effect
|
||||
const double angle_tol_deg = 1.0;
|
||||
const double angle_tol_deg = 2.0;
|
||||
|
||||
// Position error - rounding to nearest integer
|
||||
const int pos_tol = 1;
|
||||
@ -401,7 +401,7 @@ static const std::vector<ARC_TTR_CASE> arc_ttr_cases = {
|
||||
{ 1707, 1707 }, //end on second segment
|
||||
135, //positive angle due to start/end
|
||||
180,
|
||||
225,
|
||||
315,
|
||||
1000,
|
||||
{ { 0, 1414 }, { 1707, 1000 } },
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user