MCPcopy Create free account
hub / github.com/RobTillaart/Arduino / atan2Fast

Function atan2Fast

libraries/FastTrig/FastTrig.cpp:401–426  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

399
400
401float atan2Fast(float y, float x)
402{
403 // catch singularity.
404 if ((x == 0) && (y == 0)) return NAN;
405
406 if (x >= 0)
407 {
408 if (y >= 0)
409 {
410 if (fabs(y) >= fabs(x)) return M_PI / 2 - atanFast(x / y);
411 return atanFast(y / x);
412 }
413 if (fabs(y) >= fabs(x)) return -M_PI / 2 - atanFast(x / y);
414 return atanFast(y / x);
415 }
416 else
417 {
418 if (y >= 0)
419 {
420 if (fabs(y) >= fabs(x)) return M_PI / 2 - atanFast(x / y);
421 return M_PI + atanFast(y / x);
422 }
423 if (fabs(y) >= fabs(x)) return -M_PI / 2 - atanFast(x / y);
424 return -M_PI + atanFast(y / x);
425 }
426}
427
428
429///////////////////////////////////////////////////////

Callers

nothing calls this directly

Calls 1

atanFastFunction · 0.85

Tested by

no test coverage detected