| 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.
| “ | Ken Thompson has an automobile which he helped design. Unlike most automobiles, it has neither speedometer, nor gas gauge, nor any of the other numerous idiot lights which plague the modern driver. Rather, if the driver makes a mistake, a giant “?” lights up in the center of the dashboard. “The experienced driver,” says Thompson, “will usually know what's wrong.” | ” |