Advertisement
KeithS

Trig_Blog_Sample_5

Aug 2nd, 2012
329
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.84 KB | None | 0 0
  1. #include <math.h>
  2. #include <cstdio>
  3. #define _USE_MATH_DEFINES
  4.  
  5.  
  6. struct point
  7. {
  8.     float x_pos;
  9.     float y_pos;
  10.     float _Hypot;
  11.     float _Asin;
  12. };
  13.  
  14.  
  15. int main()
  16. {
  17.     point a_point[4];
  18.  
  19.  
  20.     a_point[0].x_pos = 300.0f;
  21.     a_point[0].y_pos = 200.0f;
  22.     a_point[1].x_pos = -200.0f;
  23.     a_point[1].y_pos = 300.0f;
  24.     a_point[2].x_pos = -300.0f;
  25.     a_point[2].y_pos = -200.0f;
  26.     a_point[3].x_pos = 200.0f;
  27.     a_point[3].y_pos = -300.0f;
  28.  
  29.  
  30.     int i;
  31.     for( i = 0; i < 4; i++)
  32.     {
  33.         a_point[i]._Hypot = hypotf(a_point[i].y_pos, a_point[i].x_pos);
  34.         a_point[i]._Asin = asinf(a_point[i].y_pos / a_point[i]._Hypot);
  35.         printf("\nPOINT %d\n", i);
  36.         printf("X Pos: %.1f\nY Pos: %.1f\nAsin : %.3f\n\n",
  37.             a_point[i].x_pos, a_point[i].y_pos, a_point[i]._Asin);
  38.     }
  39.     return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement