• API
• FAQ
• Tools
• Trends
• Archive
SHARE
TWEET

# Trig_Blog_Sample_1

KeithS Aug 2nd, 2012 141 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. #include <math.h>
2. #include <cstdio>
3.
4. int main()
5. {
6.     struct point
7.     {
8.         float x_pos;
9.         float y_pos;
10.     };
11.
12.     point points[8];
13.     points[0].x_pos = -200.0f;
14.     points[0].y_pos = -200.0f;
15.     points[1].x_pos = 0.0f;
16.     points[1].y_pos = -200.0f;
17.     points[2].x_pos = 200.0f;
18.     points[2].y_pos = -200.0f;
19.     points[3].x_pos = 200.0f;
20.     points[3].y_pos = 0.0f;
21.     points[4].x_pos = 200.0f;
22.     points[4].y_pos = 200.0f;
23.     points[5].x_pos = 0.0f;
24.     points[5].y_pos = 200.0f;
25.     points[6].x_pos = -200.0f;
26.     points[6].y_pos = 200.0f;
27.     points[7].x_pos = -200.0f;
28.     points[7].y_pos = 0.0f;
29.
30.     float store_atan[8];
31.     float store_atan2f[8];
32.
33.     int i;
34.     for(i = 0; i < 8; i++)
35.     {
36.         store_atan[i] = atanf(points[i].y_pos / points[i].x_pos);
37.         store_atan2f[i] = atan2f(points[i].y_pos, points[i].x_pos);
38.     }
39.
40.     for(i = 0; i < 8; i++)
41.     {
42.         printf("store_atan[%d]   = %.4f\n", i, store_atan[i]);
43.         printf("store_atan2f[%d] = %.4f\n\n", i, store_atan2f[i]);
44.     }
45.
46.     return 0;
47. }
RAW Paste Data
Top