Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<math.h>
- #define g 9.81
- typedef struct punto{
- double x,y,z;
- }Punto;
- double calculo(double v,double t,double vrel,double tf,double t0,double M0,double R){
- double res,ln;
- ln=log(1 + (R*(tf-t0)/M0));
- res=v*t - (0.5)*g*t*t - vrel*((tf-t0) - (M0/R + (tf-t0))*ln);
- return res;
- }
- int main(){
- Punto d,v,final_rel,final,vrel;
- double t0,tf,t,h,M0,R;
- int n;
- printf("\t***Calculo de los puntos de trayectoria de un cohete de masa variable***\n");
- printf("Ingrese el tiempo inicial(s):\n");
- scanf("%lf",&t0);
- printf("Ingrese la posicion inicial(m):\n");
- printf("X: "); scanf("%lf",&d.x);
- printf("Y: "); scanf("%lf",&d.y);
- printf("Z: "); scanf("%lf",&d.z);
- printf("Ingrese la velocidad inicial(m/s):\n");
- printf("X: "); scanf("%lf",&v.x);
- printf("Y: "); scanf("%lf",&v.y);
- printf("Z: "); scanf("%lf",&v.z);
- printf("Ingrese la masa inicial (kg):\n");
- scanf("%lf",&M0);
- printf("ingrese el tiempo final(s):\n");
- scanf("%lf",&tf);
- printf("Ingrese la cantidad de puntos:\n");
- scanf("%d",&n);
- while(n==0){
- printf("ingrese otra cantidad:\n");
- scanf("%d",&n);
- }
- printf("Ingrese el valor de R(Kg/s) y R<0:\n");
- scanf("%lf",&R);
- printf("Ingrese la velocidad relativa(m/s):\n");
- printf("X: "); scanf("%lf",&vrel.x);
- printf("Y: "); scanf("%lf",&vrel.y);
- printf("Z: "); scanf("%lf",&vrel.z);
- h=(tf-t0)/n;
- for (t=t0; t<=tf; t+=h){
- final_rel.x= calculo(v.x,t,vrel.x,tf,t0,M0,R);
- final_rel.y= calculo(v.y,t,vrel.y,tf,t0,M0,R);
- final_rel.z= calculo(v.z,t,vrel.z,tf,t0,M0,R);
- printf("%lf\t %lf\t %lf \n",final_rel.x,final_rel.y,final_rel.z);
- }
- printf("\n");
- printf("La posicion final es: xf= %lf yf= %lf zf= %lf\n",final_rel.x,final_rel.y,final_rel.z);
- return 0;
- }
Add Comment
Please, Sign In to add comment