atan2 man page on 4.4BSD

 Man page or keyword search:   man All Sections 1 - General Commands 2 - System Calls 3 - Subroutines, Functions 4 - Special Files 5 - File Formats 6 - Games and Screensavers 7 - Macros and Conventions 8 - Maintenence Commands 9 - Kernel Interface New Commands Server 4.4BSD AIX Alpinelinux Archlinux Aros BSDOS BSDi Bifrost CentOS Cygwin Darwin Debian DigitalUNIX DragonFly ElementaryOS Fedora FreeBSD Gentoo GhostBSD HP-UX Haiku Hurd IRIX Inferno JazzOS Kali Knoppix LinuxMint MacOSX Mageia Mandriva Manjaro Minix MirBSD NeXTSTEP NetBSD OPENSTEP OSF1 OpenBSD OpenDarwin OpenIndiana OpenMandriva OpenServer OpenSuSE OpenVMS Oracle PC-BSD Peanut Pidora Plan9 QNX Raspbian RedHat Scientific Slackware SmartOS Solaris SuSE SunOS Syllable Tru64 UNIXv7 Ubuntu Ultrix UnixWare Xenix YellowDog aLinux   1065 pages apropos Keyword Search (all sections) Output format html ascii pdf view pdf save postscript
[printable version]

```ATAN2(3)		 BSD Library Functions Manual		      ATAN2(3)

NAME
atan2 — arc tangent function of two variables

SYNOPSIS
#include <math.h>

double
atan2(double y, double x);

DESCRIPTION
The atan2 function computes the principal value of the arc tangent of
y/x, using the signs of both arguments to determine the quadrant of the
return value.

RETURN VALUES
The atan2 function, if successful, returns the arc tangent of y/x in the
range [-π, +π] radians.  If both x and y are zero, the global variable
errno is set to EDOM.  On the VAX:

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.

NOTES
The function atan2() defines "if x > 0," atan2(0, 0) = 0 on a VAX despite
that previously atan2(0, 0) may have generated an error message.  The
reasons for assigning a value to atan2(0, 0) are these:

1.	Programs that test arguments to avoid computing atan2(0, 0)
must be indifferent to its value.  Programs that require it to
be invalid are vulnerable to diverse reactions to that inva‐
lidity on diverse computer systems.

2.	The atan2() function is used mostly to convert from rectangu‐
lar (x,y) to polar (r,theta) coordinates that must satisfy x =
r∗cos theta and y = r∗sin theta.  These equations are satis‐
fied when (x=0,y=0) is mapped to (r=0,theta=0) on a VAX.  In
general, conversions to polar coordinates should be computed
thus:

r	   := hypot(x,y);  ... := sqrt(x∗x+y∗y)
theta	:= atan2(y,x).

3.	The foregoing formulas need not be altered to cope in a rea‐
sonable way with signed zeros and infinities on a machine that
conforms to IEEE 754; the versions of hypot(3) and atan2()
provided for such a machine are designed to handle all cases.
That is why atan2(±0, -0) = ±π for instance.  In general the
formulas above are equivalent to these:

r := sqrt(x∗x+y∗y); if r = 0 then x := copysign(1,x);

acos(3), asin(3), atan(3), cos(3), cosh(3), sin(3), sinh(3), tan(3),
tanh(3), math(3),

STANDARDS
The atan2() function conforms to ANSI X3.159-1989 (“ANSI C89”).

BSD				 June 4, 1993				   BSD
```
[top]

List of man pages available for 4.4BSD

Copyright (c) for man pages and the logo by the respective OS vendor.

For those who want to learn more, the polarhome community provides shell access and support.