E.V.E
v2022.09.01

◆ atan2d

eve::atan2d = {}
inlineconstexpr

Callable object computing the arc tangent in degrees using the signs of arguments to determine the correct quadrant.

Defined in Header

#include <eve/module/math.hpp>

Callable Signatures

namespace eve
{
template< eve::floating_value T, eve::floating_value U >
T atan2d(T x, U y) noexcept;
}
constexpr callable_atan2d_ atan2d
Callable object computing the arc tangent in degrees using the signs of arguments to determine the co...
Definition: atan2d.hpp:86
Definition: all_of.hpp:22

Parameters

x, y: floating real values

Return value

the arc tangent of \(\frac{y}x\) in the range [-180 , +180] radians, is returned. The IEEE limiting values are almost all satisfied :

  • If x and y are both zero or infinites, Nan is returned (this is not standard conforming)
  • If y is \(\pm0\) and x is strictly negative or \(-0\), \(\pm180\) is returned
  • If y is \(\pm0\) and x is strictly positive or \(+0\), \(\pm0\) is returned
  • If y is \(\pm\infty\) and x is finite, \(\pm90\) is returned
  • If x is \(\pm0\) and y is strictly negative, \(-90\) is returned
  • If x is \(\pm0\) and y is strictly positive, \(+90\) is returned
  • If x is \(-\infty\) and y is finite and positive, \(+180\) is returned
  • If x is \(-\infty\) and y is finite and negative, \(-180\) is returned
  • If x is \(+\infty\) and y is finite and positive, \(+0\) is returned
  • If x is \(+\infty\) and y is finite and negative, \(-0\) is returned
  • If either x is Nan or y is Nan, Nan is returned

The call will return a NaN if x and y are both either null or infinite: this result is not IEEE conformant, but allows to simplify (and speed) the implementation. In all other cases, the result is standard conformant.

The result type is the common compatible type of the two parameters.

Example

#include <eve/module/math.hpp>
#include <eve/wide.hpp>
#include <iostream>
int main()
{
wide_ft pf = { 0.0f, 1.0f, 4.0f, -2.0f };
wide_ft qf = { 1.0f, -1.0f, 3.0f, -0.0f};
std::cout
<< "---- simd" << '\n'
<< "<- pf = " << pf << '\n'
<< "<- qf = " << qf << '\n'
<< "-> atan2d(pf, qf) = " << eve::atan2d(pf, qf) << '\n'
;
float xf = 2.0f;
float yf = 10.0f;
std::cout
<< "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "-> atan2d(xf, yf) = " << eve::atan2d(xf, yf) << '\n';
return 0;
}
Wrapper for SIMD registers.
Definition: wide.hpp:65

Semantic Modifiers

  • eve::pedantic

    The call pedantic(atan2d)(x,y) returns the same results as the regular call, but all IEEE limiting values are satisfied :

    • If y is \(\pm\infty\) and x is \(-\infty\), \(\pm135\) is returned
    • If y is \(\pm\infty\) and x is \(+\infty\), \(\pm45\) is returned
    • If x is \(\pm0\) and y is \(\pm-0\), \(-90\) is returned
    • If x is \(\pm0\) and y is \(\pm+0\), \(+90\) is returned