Advertisement
AsafBenShabat

Untitled

Dec 7th, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. #include <stdio.h>
  2. #include<conio.h>
  3. #include<math.h>
  4. #define PI 3.1415926535897932384626433832795
  5. #define G -9.81
  6. double HEIGHT(float V, int A, float T);
  7. double HORIZONTAL(float V, int A, float T);
  8. float AIRTIME(float V, int A);
  9. int main()
  10. {
  11. double height_, horizontal_;
  12. float T, V, airtime_;
  13. int flagV = 0, flagA = 0, A;
  14. printf("please enter speed (0.0 - 100.0) and angle (0 - 90): ");
  15. scanf("%f %d", &V, &A);
  16. while (flagV = 0)
  17. {
  18. if (V < 100 && V > 0)
  19. {
  20. flagV = 1;
  21. }
  22. else
  23. {
  24. printf("\nincorrect input, speed must be between 0 to 100");
  25. scanf("%f", &V);
  26. }
  27. }
  28. while (flagA = 0)
  29. {
  30. if (A < 90 && A > 90)
  31. {
  32. flagA = 1;
  33. }
  34. else
  35. {
  36. printf("inccorect input, angle must be between 0 to 90");
  37. scanf("%d", &A);
  38. }
  39. }
  40. airtime_ = AIRTIME(V,A);
  41. for (T = 0; T <= airtime_; T = T + 0.1)
  42. {
  43. horizontal_ = HORIZONTAL(V, A, T);
  44. height_ = HEIGHT(V, A, T);
  45. printf("\ntime : %.1f .. S = %ld H = %ld", T, horizontal_, height_);
  46.  
  47. }
  48. getch();
  49. return 0;
  50. }
  51.  
  52. float AIRTIME(float V, int A)
  53. {
  54. float AIRTIME, Vy, halfway;
  55. Vy = V * sin(A * PI) / 180;
  56. halfway = ((Vy)* (-1)) / G;
  57. AIRTIME = halfway * 2;
  58. return AIRTIME;
  59. }
  60.  
  61. double HEIGHT(float V, int A, float T)
  62. {
  63. double HEIGHT;
  64. HEIGHT = (V * sin(A * PI) / 180)*T + ((G *T*T) / 2);
  65. return HEIGHT;
  66. }
  67.  
  68. double HORIZONTAL(float V, int A, float T)
  69. {
  70. double Vx, HORIZONTAL;
  71. HORIZONTAL = (V * cos(A * PI) / 180) * T;
  72. return HORIZONTAL;
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement