]> git.lizzy.rs Git - plan9front.git/blob - sys/src/libc/port/atan2.c
libregexp: improve the transition to next available thread, instruction, and generation
[plan9front.git] / sys / src / libc / port / atan2.c
1 #include <u.h>
2 #include <libc.h>
3 /*
4         atan2 discovers what quadrant the angle
5         is in and calls atan.
6 */
7
8 double
9 atan2(double arg1, double arg2)
10 {
11
12         if(arg1+arg2 == arg1) {
13                 if(arg1 >= 0)
14                         return PIO2;
15                 return -PIO2;
16         }
17         arg1 = atan(arg1/arg2);
18         if(arg2 < 0) {
19                 if(arg1 <= 0)
20                         return arg1 + PI;
21                 return arg1 - PI;
22         }
23         return arg1;
24 }