53 { 90.0, 90.0, -270.0, 90.0, 90.0, 90.0 },
54 { -90.0, 270.0, -90.0, -90.0, -90.0, -90.0 },
55 { 135.0, 135.0, -225.0, -45.0, 135.0, 135.0 },
56 { -135.0, 225.0, -135.0, 45.0, -135.0, -135.0 },
57 { 180.0, 180.0, -180.0, 0.0, 180.0, 180.0 },
58 { -180.0, 180.0, -180.0, 0.0, 180.0, -180.0 },
59 { 360.0, 0.0, 0.0, 0.0, 0.0, 0.0 },
60 { -360.0, 0.0, 0.0, 0.0, 0.0, -360.0 },
61 { 390.0, 30.0, -330.0, 30.0, 30.0, 30.0 },
62 { -390.0, 330.0, -30.0, -30.0, -30.0, -30.0 },
63 { 720.0, 0.0, 0.0, 0.0, 0.0, 0.0 },
64 { -720.0, 0.0, 0.0, 0.0, 0.0, -360.0 },
72 BOOST_TEST_INFO_SCOPE(
"Original angle: " << c.m_Angle <<
" degrees" );
105 const std::vector<EDA_ANGLE_NORMALISE_CASE> cases = {
106 { 1e19, 280.0, -80.0, -80.0, -80.0, 280.0 },
107 { -1e19, 80.0, -280.0, 80.0, 80.0, -280.0 },
108 { INFINITY, 0.0, 0.0, 0.0, 0.0, 0.0 },
109 { -INFINITY, 0.0, 0.0, 0.0, 0.0, 0.0 },
110 { NAN, 0.0, 0.0, 0.0, 0.0, 0.0 },
113 for(
const auto& c : cases )
115 BOOST_TEST_INFO_SCOPE(
"Original angle: " << c.m_Angle <<
" degrees" );
119 c.m_ExpNormalizedNegative );
129 for(
double bad : { INFINITY, -INFINITY } )
191 std::vector<double> inputs;
193 for(
int i = -40; i <= 40; ++i )
195 double base = 45.0 * i;
196 inputs.insert( inputs.end(), { base, std::nextafter( base, -INFINITY ), std::nextafter( base, INFINITY ),
197 base - 1e-20, base + 1e-20 } );
200 for(
int i = -5000; i <= 5000; ++i )
201 inputs.push_back( i * 199.87654321 );
203 inputs.insert( inputs.end(), { 0.0, -0.0, 1e-300, -1e-300 } );
205 auto sameBits = [](
double a,
double b )
207 return a == b && std::signbit( a ) == std::signbit( b );
210 for(
double x : inputs )
212 BOOST_TEST_INFO_SCOPE(
"Original angle: " << std::setprecision( 17 ) << x <<
" degrees" );
215 refStep( x, 0.0,
true, 360.0,
false, 360.0 ) ) );
217 refStep( x, -360.0,
false, 0.0,
true, 360.0 ) ) );
219 refStep( x, -90.0,
true, 90.0,
true, 180.0 ) ) );
221 refStep( x, -180.0,
false, 180.0,
true, 360.0 ) ) );
223 refStep( x, -360.0,
true, 360.0,
false, 360.0 ) ) );
272 const auto checkReflect = [](
double aAngle,
double aAxis,
double aExpected )
274 BOOST_TEST_CONTEXT(
"Testing reflect( " << aAngle <<
" about " << aAxis <<
" ) -> " << aExpected )
300 checkReflect( 90, 0, 270.0 );
305 checkReflect( 45, 90, 135.0 );
314 checkReflect( -90, 45, 180.0 );
319 checkReflect( 45, 45, 45 );
static double refStep(double aValue, double aLow, bool aLowIncl, double aHigh, bool aHighIncl, double aPeriod)
Reference copy of the stepping loops that normalization used before exact folding.