this repo has no description
1.\" Copyright (c) 1991 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\" notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\" notice, this list of conditions and the following disclaimer in the
11.\" documentation and/or other materials provided with the distribution.
12.\" 3. All advertising materials mentioning features or use of this software
13.\" must display the following acknowledgement:
14.\" This product includes software developed by the University of
15.\" California, Berkeley and its contributors.
16.\" 4. Neither the name of the University nor the names of its contributors
17.\" may be used to endorse or promote products derived from this software
18.\" without specific prior written permission.
19.\"
20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30.\" SUCH DAMAGE.
31.\"
32.\" from: @(#)atan2.3 5.1 (Berkeley) 5/2/91
33.\" $Id: atan2.3,v 1.6 2006/06/13 18:55:19 scanon Exp $
34.\"
35.Dd December 11, 2006
36.Dt ATAN2 3
37.Os
38.Sh NAME
39.Nm atan2
40.Nd arc tangent function of two variables
41.Sh SYNOPSIS
42.Fd #include <math.h>
43.Ft double
44.Fn atan2 "double y" "double x"
45.Ft long double
46.Fn atan2l "long double y" "long double x"
47.Ft float
48.Fn atan2f "float y" "float x"
49.Sh DESCRIPTION
50The
51.Fn atan2
52function computes the principal value of the arc tangent of
53.Ar y/ Ns Ar x ,
54using the signs of both arguments to determine the quadrant of
55the return value.
56.Sh SPECIAL VALUES
57.Fn atan2 "�0, -0"
58returns �pi.
59.Pp
60.Fn atan2 "�0, +0"
61returns �0.
62.Pp
63.Fn atan2 "�0, x"
64returns �pi for x < 0.
65.Pp
66.Fn atan2 "�0, x"
67returns �0 for x > 0.
68.Pp
69.Fn atan2 "y, �0"
70returns +pi/2 for y > 0.
71.Pp
72.Fn atan2 "y, �0"
73returns -pi/2 for y < 0.
74.Pp
75.Fn atan2 "�y, -infinity"
76returns �pi for finite y > 0.
77.Pp
78.Fn atan2 "�y, +infinity"
79returns �0 for finite y > 0.
80.Pp
81.Fn atan2 "�infinity, x"
82returns �pi/2 for finite x.
83.Pp
84.Fn atan2 "�infinity, -infinity"
85returns �3*pi/4.
86.Pp
87.Fn atan2 "�infinity, +infinity"
88returns �pi/4.
89.Sh NOTES
90The
91.Fn atan2
92function is used mostly to convert from rectangular (x,y)
93to polar
94.if n\
95(r,theta)
96.if t\
97(r,\(*h)
98coordinates that must satisfy x =
99.if n\
100r\(**cos theta
101.if t\
102r\(**cos\(*h
103and y =
104.if n\
105r\(**sin theta.
106.if t\
107r\(**sin\(*h.
108In general, conversions to polar coordinates
109should be computed thus:
110.Bd -unfilled -offset indent
111.if n \{\
112r := hypot(x,y); ... := sqrt(x\(**x+y\(**y)
113theta := atan2(y,x).
114.\}
115.if t \{\
116r := hypot(x,y); ... := \(sr(x\u\s82\s10\d+y\u\s82\s10\d)
117\(*h := atan2(y,x).
118.\}
119.Ed
120.Sh SEE ALSO
121.Xr acos 3 ,
122.Xr asin 3 ,
123.Xr atan 3 ,
124.Xr cos 3 ,
125.Xr cosh 3 ,
126.Xr sin 3 ,
127.Xr sinh 3 ,
128.Xr tan 3 ,
129.Xr tanh 3 ,
130.Xr math 3 ,
131.Sh STANDARDS
132The
133.Fn atan2
134function conforms to ISO/IEC 9899:1999(E).