Advertisement
luizaspan

Partícula em queda livre

May 22nd, 2015
346
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.82 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. #define v0 20
  5. #define theta0 60 //graus
  6. #define y0 60
  7. #define g 9.8
  8.  
  9. #define pi M_PI
  10.  
  11. int main (void)
  12. {
  13. double rad,tv1,tv2,y,x,t,v0x,v0y;
  14.  
  15. rad = 180*theta0/pi;
  16.  
  17. v0x=v0*cos(rad);
  18. v0y=v0*sin(rad);
  19.  
  20. tv1=(v0y+sqrt(pow(v0y,2)+2*g*y0))/g;    //ver o maior dos valores para tv
  21. tv2=(v0y-sqrt(pow(v0y,2)+2*g*y0))/g;
  22.  
  23.  
  24.  
  25. if (tv1==tv2)
  26. {
  27. for (t=0.0;t<=tv1;t+=0.1)
  28. {
  29. x=v0x*t;
  30. y=y0+tan(rad)*x-(g*pow(x,2)/(2*pow(v0x,2)));
  31. printf("%lf\t %lf\t %lf\n",t,x,y);
  32. }
  33. }
  34.  
  35. if (tv1>tv2)
  36. {
  37. for (t=0.0;t<tv1;t+=0.1)
  38. {
  39. x=v0x*t;
  40. y=y0+tan(rad)*x-(g*pow(x,2)/(2*pow(v0x,2)));
  41. printf("%lf\t %lf\t %lf\n",t,x,y);
  42. }
  43. }
  44.  
  45. if (tv2>tv1)
  46. {
  47. for (t=0.0;t<=tv2;t+=0.1)
  48. {
  49. x=v0x*t;
  50. y=y0+tan(rad)*x-(g*pow(x,2)/(2*pow(v0x,2)));
  51. printf("%lf\t %lf\t %lf\t %lf\t %lf\n",t,x,y);
  52. }
  53.  
  54. }
  55.  
  56.  
  57. return 0;
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement