51 { 90.0, 90.0, -270.0, 90.0, 90.0, 90.0 },
52 { -90.0, 270.0, -90.0, -90.0, -90.0, -90.0 },
53 { 135.0, 135.0, -225.0, -45.0, 135.0, 135.0 },
54 { -135.0, 225.0, -135.0, 45.0, -135.0, -135.0 },
55 { 180.0, 180.0, -180.0, 0.0, 180.0, 180.0 },
56 { -180.0, 180.0, -180.0, 0.0, 180.0, -180.0 },
57 { 360.0, 0.0, 0.0, 0.0, 0.0, 0.0 },
58 { -360.0, 0.0, 0.0, 0.0, 0.0, -360.0 },
59 { 390.0, 30.0, -330.0, 30.0, 30.0, 30.0 },
60 { -390.0, 330.0, -30.0, -30.0, -30.0, -30.0 },
61 { 720.0, 0.0, 0.0, 0.0, 0.0, 0.0 },
62 { -720.0, 0.0, 0.0, 0.0, 0.0, -360.0 },
70 BOOST_TEST_INFO_SCOPE(
"Original angle: " << c.m_Angle <<
" degrees" );
103 const std::vector<EDA_ANGLE_NORMALISE_CASE> cases = {
104 { 1e19, 280.0, -80.0, -80.0, -80.0, 280.0 },
105 { -1e19, 80.0, -280.0, 80.0, 80.0, -280.0 },
106 { INFINITY, 0.0, 0.0, 0.0, 0.0, 0.0 },
107 { -INFINITY, 0.0, 0.0, 0.0, 0.0, 0.0 },
108 { NAN, 0.0, 0.0, 0.0, 0.0, 0.0 },
111 for(
const auto& c : cases )
113 BOOST_TEST_INFO_SCOPE(
"Original angle: " << c.m_Angle <<
" degrees" );
117 c.m_ExpNormalizedNegative );
127 for(
double bad : { INFINITY, -INFINITY } )
177 std::vector<double> inputs;
179 for(
int i = -40; i <= 40; ++i )
181 double base = 45.0 * i;
182 inputs.insert( inputs.end(), { base, std::nextafter( base, -INFINITY ), std::nextafter( base, INFINITY ),
183 base - 1e-20, base + 1e-20 } );
186 for(
int i = -5000; i <= 5000; ++i )
187 inputs.push_back( i * 199.87654321 );
189 inputs.insert( inputs.end(), { 0.0, -0.0, 1e-300, -1e-300 } );
191 auto sameBits = [](
double a,
double b )
193 return a == b && std::signbit( a ) == std::signbit( b );
196 for(
double x : inputs )
198 BOOST_TEST_INFO_SCOPE(
"Original angle: " << std::setprecision( 17 ) << x <<
" degrees" );
201 refStep( x, 0.0,
true, 360.0,
false, 360.0 ) ) );
203 refStep( x, -360.0,
false, 0.0,
true, 360.0 ) ) );
205 refStep( x, -90.0,
true, 90.0,
true, 180.0 ) ) );
207 refStep( x, -180.0,
false, 180.0,
true, 360.0 ) ) );
209 refStep( x, -360.0,
true, 360.0,
false, 360.0 ) ) );
261 auto orientation = [&](
double d ) {
return EDA_ORIENTATION( deg( d ) ); };
266 BOOST_CHECK( orientation( 370 ) == orientation( 10 ) );
280 BOOST_CHECK_EQUAL( ( orientation( 10 ) - deg( 350 ) ).GetAngle().AsDegrees(), 20.0 );
283 EDA_ANGLE diff = orientation( 10 ) - orientation( 350 );
287 BOOST_CHECK( !std::signbit( ( -orientation( 0 ) ).GetAngle().AsDegrees() ) );
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.
BOOST_CHECK_EQUAL(result, "25.4")