WPILibC++ 2023.4.3
atan2.hpp File Reference

Go to the source code of this file.

Namespaces

namespace  internal
 

Functions

template<typename T >
constexpr T internal::atan2_compute (const T y, const T x) noexcept
 
template<typename T1 , typename T2 , typename TC = common_return_t<T1,T2>>
constexpr TC internal::atan2_type_check (const T1 y, const T2 x) noexcept
 
template<typename T1 , typename T2 >
constexpr common_return_t< T1, T2 > atan2 (const T1 y, const T2 x) noexcept
 Compile-time two-argument arctangent function. More...
 

Function Documentation

◆ atan2()

template<typename T1 , typename T2 >
constexpr common_return_t< T1, T2 > atan2 ( const T1  y,
const T2  x 
)
constexprnoexcept

Compile-time two-argument arctangent function.

Parameters
ya real-valued input.
xa real-valued input.
Returns

\[ \text{atan2}(y,x) = \begin{cases} \text{atan}(y/x) & \text{ if } x > 0 \\ \text{atan}(y/x) + \pi & \text{ if } x < 0 \text{ and } y \geq 0 \\ \text{atan}(y/x) - \pi & \text{ if } x < 0 \text{ and } y < 0 \\ + \pi/2 & \text{ if } x = 0 \text{ and } y > 0 \\ - \pi/2 & \text{ if } x = 0 \text{ and } y < 0 \end{cases} \]

The function is undefined at the origin, however the following conventions are used.

\[ \text{atan2}(y,x) = \begin{cases} +0 & \text{ if } x = +0 \text{ and } y = +0 \\ -0 & \text{ if } x = +0 \text{ and } y = -0 \\ +\pi & \text{ if } x = -0 \text{ and } y = +0 \\ - \pi & \text{ if } x = -0 \text{ and } y = -0 \end{cases} \]