Main index | Section 3 | Options |
#include <math.h>
#include <complex.h>
The carg(), cargf(), and cargl() functions compute the complex argument (or phase angle) of z. The complex argument is the number theta such that z = r * e^(I * theta), where r = cabs(z). The call carg(z) is equivalent to atan2(cimag(z), creal(z)), and similarly for cargf() and cargl().
atan2(y, x) := | atan(y/x) | if x > 0, |
sign(y)*(π -atan(|y/x|) | if x < 0, | |
0 | if x = y = 0, or | |
sign( y)*π/2 | if x = 0 != y. |
(r=0,θ=0). In general, conversions to polar coordinates should be computed thus:
r := hypot(x,y); ... := sqrt(x*x+y*y) theta := atan2(y,x). r := hypot(x,y); ... := √(x^{}^{2}^{}+y^{}^{2}^{}) θ := atan2(y,x).
r := sqrt(x*x+y*y); if r = 0 then x := copysign(1,x);r := √(x*x+y*y); if r = 0 then x := copysign(1,x);
ATAN2 (3) | July 31, 2008 |
Main index | Section 3 | Options |
Please direct any comments about this manual page service to Ben Bullock. Privacy policy.
“ | C isn't that hard: void (*(*f[])())() defines f as an array of unspecified size, of pointers to functions that return pointers to functions that return void | ” |