MCPcopy Create free account
hub / github.com/FastLED/FastLED / measure_atan2

Function measure_atan2

tests/fl/math/fixed_point.cpp:1442–1469  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1440}
1441
1442AccuracyResult measure_atan2() {
1443 AccuracyResult r = {};
1444 const int N = 5; // Spot testing: 5×5 = 25 samples (was 20×20 = 400)
1445 const float lo = -7.0f;
1446 const float hi = 7.0f;
1447 float sumErr = 0;
1448 int count = 0;
1449 for (int iy = 0; iy < N; ++iy) {
1450 float y = lo + (hi - lo) * iy / (N - 1);
1451 for (int ix = 0; ix < N; ++ix) {
1452 float x = lo + (hi - lo) * ix / (N - 1);
1453 if (fl::fabsf(x) < 0.1f && fl::fabsf(y) < 0.1f) continue;
1454 float ref = fl::atan2f(y, x);
1455 float got = s16x16::atan2(s16x16(y), s16x16(x)).to_float();
1456 float err = fl::fabsf(got - ref);
1457 sumErr += err;
1458 ++count;
1459 if (err > r.maxErr) {
1460 r.maxErr = err;
1461 r.worstInput = y;
1462 r.worstInput2 = x;
1463 }
1464 }
1465 }
1466 r.avgErr = count > 0 ? sumErr / count : 0;
1467 r.nSamples = count;
1468 return r;
1469}
1470
1471AccuracyResult measure_asin() {
1472 AccuracyResult r = {};

Callers 1

FL_TEST_FILEFunction · 0.85

Calls 5

fabsfFunction · 0.85
atan2fFunction · 0.85
atan2Function · 0.50
s16x16Class · 0.50
to_floatMethod · 0.45

Tested by

no test coverage detected