| 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, Ns, )*(π, -atan(|y/x|) | if x < 0, | |
| 0 | if x = y = 0, or | |
| sign(y, Ns, )*π/2, Ta 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); ... := √(x2+y2) θ := 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.
| “ | The most horrifying thing about Unix is that, no matter how many times you hit yourself over the head with it, you never quite manage to lose consciousness. It just goes on and on. | ” |
| — Patrick Sobalvarro | ||