1 .\" Copyright (c) 1991 The Regents of the University of California.
2 .\" All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
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.
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
32 .\" from: @(#)atan2.3 5.1 (Berkeley) 5/2/91
33 .\" $FreeBSD: src/lib/msun/man/atan2.3,v 1.6.2.4 2001/12/17 10:08:36 ru Exp $
34 .\" $DragonFly: src/lib/msun/man/Attic/atan2.3,v 1.2 2003/06/17 04:26:52 dillon Exp $
42 .Nd arc tangent functions of two variables
48 .Fn atan2 "double y" "double x"
50 .Fn atan2f "float y" "float x"
56 functions compute the principal value of the arc tangent of
58 using the signs of both arguments to determine the quadrant of
65 functions, if successful,
66 return the arc tangent of
70 .Bq \&- Ns \*(Pi , \&+ Ns \*(Pi
77 are zero, the global variable
83 .Bl -column atan_(y,x)_:=____ sign(y)_(Pi_atan2(Xy_xX))___
84 .It Fn atan2 y x No := Ta
89 .It Ta sign( Ns Ar y Ns )*(\*(Pi -
90 .Fn atan "\\*(Bay/x\\*(Ba" ) Ta
98 .Pf sign( Ar y Ns )*\\*(Pi/2 Ta
111 despite that previously
113 may have generated an error message.
114 The reasons for assigning a value to
117 .Bl -enum -offset indent
119 Programs that test arguments to avoid computing
121 must be indifferent to its value.
122 Programs that require it to be invalid are vulnerable
123 to diverse reactions to that invalidity on diverse computer systems.
127 function is used mostly to convert from rectangular (x,y)
133 coordinates that must satisfy x =
143 These equations are satisfied when (x=0,y=0)
149 on a VAX. In general, conversions to polar coordinates
150 should be computed thus:
151 .Bd -unfilled -offset indent
153 r := hypot(x,y); ... := sqrt(x\(**x+y\(**y)
157 r := hypot(x,y); ... := \(sr(x\u\s82\s10\d+y\u\s82\s10\d)
162 The foregoing formulas need not be altered to cope in a
163 reasonable way with signed zeros and infinities
164 on a machine that conforms to
171 such a machine are designed to handle all cases.
176 In general the formulas above are equivalent to these:
177 .Bd -unfilled -offset indent
179 r := sqrt(x\(**x+y\(**y); if r = 0 then x := copysign(1,x);
181 r := \(sr(x\(**x+y\(**y);\0\0if r = 0 then x := copysign(1,x);