Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <math.h>
- #include <cstdio>
- #define _USE_MATH_DEFINES
- struct point
- {
- float x_pos;
- float y_pos;
- float _Hypot;
- float _Asin;
- float _Asin_Mod;
- };
- int main()
- {
- point a_point[4];
- a_point[0].x_pos = 300.0f;
- a_point[0].y_pos = 200.0f;
- a_point[1].x_pos = -200.0f;
- a_point[1].y_pos = 300.0f;
- a_point[2].x_pos = -300.0f;
- a_point[2].y_pos = -200.0f;
- a_point[3].x_pos = 200.0f;
- a_point[3].y_pos = -300.0f;
- int i;
- for( i = 0; i < 4; i++)
- {
- a_point[i]._Hypot = hypotf(a_point[i].y_pos, a_point[i].x_pos);
- a_point[i]._Asin = asinf(a_point[i].y_pos / a_point[i]._Hypot);
- // Here's the quadrant correction...
- if(a_point[i].x_pos >= 0.0f && a_point[i].y_pos >= 0.0f)
- {
- a_point[i]._Asin_Mod = asinf(a_point[i].y_pos / a_point[i]._Hypot);
- }
- if(a_point[i].x_pos < 0.0f && a_point[i].y_pos >= 0.0f)
- {
- a_point[i]._Asin_Mod = M_PI - asinf(a_point[i].y_pos / a_point[i]._Hypot);
- }
- if(a_point[i].x_pos < 0.0f && a_point[i].y_pos < 0.0f)
- {
- a_point[i]._Asin_Mod = M_PI + (asinf(a_point[i].y_pos / a_point[i]._Hypot) * -1);
- }
- if(a_point[i].x_pos >= 0.0f && a_point[i].y_pos < 0.0f)
- {
- a_point[i]._Asin_Mod = asinf(a_point[i].y_pos / a_point[i]._Hypot) + (M_PI * 2.0f);
- }
- printf("\nPOINT %d\n", i);
- printf("X Pos: %.1f\nY Pos: %.1f\nAsin : %.3f\nAsinMod: %.3f\n\n",
- a_point[i].x_pos, a_point[i].y_pos, a_point[i]._Asin, a_point[i]._Asin_Mod);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement