forked from thradams/cake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cCode217.c
20 lines (18 loc) · 828 Bytes
/
cCode217.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
//en.cppreference.com/w/c/numeric/math/atan2.html
#include <math.h>
#include <stdio.h>
int main(void)
{
// normal usage: the signs of the two arguments determine the quadrant
// atan2(1,1) = +pi/4, Quad I
printf("(+1,+1) cartesian is (%f,%f) polar\n", hypot( 1, 1), atan2( 1, 1));
// atan2(1, -1) = +3pi/4, Quad II
printf("(+1,-1) cartesian is (%f,%f) polar\n", hypot( 1,-1), atan2( 1,-1));
// atan2(-1,-1) = -3pi/4, Quad III
printf("(-1,-1) cartesian is (%f,%f) polar\n", hypot(-1,-1), atan2(-1,-1));
// atan2(-1,-1) = -pi/4, Quad IV
printf("(-1,+1) cartesian is (%f,%f) polar\n", hypot(-1, 1), atan2(-1, 1));
// special values
printf("atan2(0, 0) = %f atan2(0, -0)=%f\n", atan2(0,0), atan2(0,-0.0));
printf("atan2(7, 0) = %f atan2(7, -0)=%f\n", atan2(7,0), atan2(7,-0.0));
}