Trigonometric Functions

Last updated 2025 August 22

Corrected Arctangent

fatan2(x,y)f_ ext{atan2} left(, x, y , ight)

Compute the corrected arctangent of x,yx, y.

Arguments

ArgumentDescriptionTypeConstraintsNotes
xxR\mathbb{R}
yyR\mathbb{R}

Return

ValueDescriptionTypeConstraintsNotes
θ\thetadirection angleR\mathbb{R}π<θπ-\pi < \theta \leq \pi

Usage

f_{atan2}\left(x,\ y\right)=\left\{x>0:\tan^{-1}\left(\frac{y}{x}\right),\ x<0:\ \left\{y<0:\tan^{-1}\left(\frac{y}{x}\right)-\pi,\tan^{-1}\left(\frac{y}{x}\right)+\pi\right\},\ x=0:\ \left\{y>0:\ \frac{\pi}{2},\ y<0:\ -\frac{\pi}{2},\ 0\right\},\ 0\right\}
\phi=f_{atan2}\left(P.x,\ P.y\right)
\left(t\cos\phi,\ t\sin\phi\right)
P=\left(0.2,\ 0.2\right)

Implementation

fatan2(x,y)={x>0:tan1(yx), x<0: {y<0:tan1(yx)π,tan1(yx)+π}, x=0: {y>0: π2, y<0: π2, 0}, 0}f_ ext{atan2} left(, x, y , ight) = left{ x>0: an^{-1}left( rac{y}{x} ight), x<0: left{y<0: an^{-1}left( rac{y}{x} ight)-pi, an^{-1}left( rac{y}{x} ight)+pi ight}, x=0: left{y>0: rac{pi}{2}, y<0: - rac{pi}{2}, 0 ight}, 0 ight}

Dependencies

None

See an oversight or error? Drop an issue on GitHub.