2 * (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
3 * See the copyright notice in the ACK home directory, in the file "Copyright".
5 * Author: Ceriel J.H. Jacobs
11 #include "localmath.h"
14 atan2(double y
, double x
)
16 double absx
, absy
, val
;
18 if (x
== 0 && y
== 0) {
22 absy
= y
< 0 ? -y
: y
;
23 absx
= x
< 0 ? -x
: x
;
24 if (absy
- absx
== absy
) {
25 /* x negligible compared to y */
26 return y
< 0 ? -M_PI_2
: M_PI_2
;
28 if (absx
- absy
== absx
) {
29 /* y negligible compared to x */
34 /* first or fourth quadrant; already correct */