Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- #define DT 0.001
- #define G 9.81
- #define VELOCIDAD_INICIAL 20
- #define ANGULO_INICIAL 50
- #define PI 3.14159265358979
- double computar_velocidad(double vi,double a,double dt){
- return vi + a*dt;
- }
- double computar_posicion(double pi,double vi,double dt){
- return pi + vi*dt;
- }
- double grados_a_radianes(double g){
- return (g/180)*PI;
- }
- void tiro_oblicuo(void){
- double t=0,vx,vy,px=0,py=0,rad=grados_a_radianes(ANGULO_INICIAL);
- vx = VELOCIDAD_INICIAL*cos(rad);
- vy = VELOCIDAD_INICIAL*sin(rad);
- while (py >= 0){
- printf("%f,%f,%f\n",px,py,t);
- t+=DT;
- vy = computar_velocidad(vy,-G,DT);
- px = computar_posicion(px,vx,DT);
- py = computar_posicion(py,vy,DT);
- }
- }
- int main(void){
- tiro_oblicuo();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement