Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include<conio.h>
- #include<math.h>
- #define PI 3.1415926535897932384626433832795
- #define G -9.81
- double HEIGHT(float V, int A, float T);
- double HORIZONTAL(float V, int A, float T);
- float AIRTIME(float V, int A);
- int main()
- {
- double height_, horizontal_;
- float T, V, airtime_;
- int flagV = 0, flagA = 0, A;
- printf("please enter speed (0.0 - 100.0) and angle (0 - 90): ");
- scanf("%f %d", &V, &A);
- while (flagV = 0)
- {
- if (V < 100 && V > 0)
- {
- flagV = 1;
- }
- else
- {
- printf("\nincorrect input, speed must be between 0 to 100");
- scanf("%f", &V);
- }
- }
- while (flagA = 0)
- {
- if (A < 90 && A > 90)
- {
- flagA = 1;
- }
- else
- {
- printf("inccorect input, angle must be between 0 to 90");
- scanf("%d", &A);
- }
- }
- airtime_ = AIRTIME(V,A);
- for (T = 0; T <= airtime_; T = T + 0.1)
- {
- horizontal_ = HORIZONTAL(V, A, T);
- height_ = HEIGHT(V, A, T);
- printf("\ntime : %.1f .. S = %ld H = %ld", T, horizontal_, height_);
- }
- getch();
- return 0;
- }
- float AIRTIME(float V, int A)
- {
- float AIRTIME, Vy, halfway;
- Vy = V * sin(A * PI) / 180;
- halfway = ((Vy)* (-1)) / G;
- AIRTIME = halfway * 2;
- return AIRTIME;
- }
- double HEIGHT(float V, int A, float T)
- {
- double HEIGHT;
- HEIGHT = (V * sin(A * PI) / 180)*T + ((G *T*T) / 2);
- return HEIGHT;
- }
- double HORIZONTAL(float V, int A, float T)
- {
- double Vx, HORIZONTAL;
- HORIZONTAL = (V * cos(A * PI) / 180) * T;
- return HORIZONTAL;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement