[444] | 1 | |
---|
| 2 | /* @(#)w_atan2.c 5.1 93/09/24 */ |
---|
| 3 | /* |
---|
| 4 | * ==================================================== |
---|
| 5 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
---|
| 6 | * |
---|
| 7 | * Developed at SunPro, a Sun Microsystems, Inc. business. |
---|
| 8 | * Permission to use, copy, modify, and distribute this |
---|
| 9 | * software is freely granted, provided that this notice |
---|
| 10 | * is preserved. |
---|
| 11 | * ==================================================== |
---|
| 12 | * |
---|
| 13 | */ |
---|
| 14 | |
---|
| 15 | /* |
---|
| 16 | FUNCTION |
---|
| 17 | <<atan2>>, <<atan2f>>---arc tangent of y/x |
---|
| 18 | |
---|
| 19 | INDEX |
---|
| 20 | atan2 |
---|
| 21 | INDEX |
---|
| 22 | atan2f |
---|
| 23 | |
---|
| 24 | SYNOPSIS |
---|
| 25 | #include <math.h> |
---|
| 26 | double atan2(double <[y]>,double <[x]>); |
---|
| 27 | float atan2f(float <[y]>,float <[x]>); |
---|
| 28 | |
---|
| 29 | DESCRIPTION |
---|
| 30 | |
---|
| 31 | <<atan2>> computes the inverse tangent (arc tangent) of <[y]>/<[x]>. |
---|
| 32 | <<atan2>> produces the correct result even for angles near |
---|
| 33 | @ifnottex |
---|
| 34 | pi/2 or -pi/2 |
---|
| 35 | @end ifnottex |
---|
| 36 | @tex |
---|
| 37 | $\pi/2$ or $-\pi/2$ |
---|
| 38 | @end tex |
---|
| 39 | (that is, when <[x]> is near 0). |
---|
| 40 | |
---|
| 41 | <<atan2f>> is identical to <<atan2>>, save that it takes and returns |
---|
| 42 | <<float>>. |
---|
| 43 | |
---|
| 44 | RETURNS |
---|
| 45 | <<atan2>> and <<atan2f>> return a value in radians, in the range of |
---|
| 46 | @ifnottex |
---|
| 47 | -pi to pi. |
---|
| 48 | @end ifnottex |
---|
| 49 | @tex |
---|
| 50 | $-\pi$ to $\pi$. |
---|
| 51 | @end tex |
---|
| 52 | |
---|
| 53 | You can modify error handling for these functions using <<matherr>>. |
---|
| 54 | |
---|
| 55 | PORTABILITY |
---|
| 56 | <<atan2>> is ANSI C. <<atan2f>> is an extension. |
---|
| 57 | |
---|
| 58 | |
---|
| 59 | */ |
---|
| 60 | |
---|
| 61 | /* |
---|
| 62 | * wrapper atan2(y,x) |
---|
| 63 | */ |
---|
| 64 | |
---|
| 65 | #include "fdlibm.h" |
---|
| 66 | #include <errno.h> |
---|
| 67 | |
---|
| 68 | #ifndef _DOUBLE_IS_32BITS |
---|
| 69 | |
---|
| 70 | #ifdef __STDC__ |
---|
| 71 | double atan2(double y, double x) /* wrapper atan2 */ |
---|
| 72 | #else |
---|
| 73 | double atan2(y,x) /* wrapper atan2 */ |
---|
| 74 | double y,x; |
---|
| 75 | #endif |
---|
| 76 | { |
---|
| 77 | return __ieee754_atan2(y,x); |
---|
| 78 | } |
---|
| 79 | |
---|
| 80 | #endif /* defined(_DOUBLE_IS_32BITS) */ |
---|