SHARE
TWEET

Untitled

a guest Nov 15th, 2019 80 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. x0=-5;
  2. y0=0;
  3. z0=200;
  4. v0x=2;
  5. v0y=4;
  6. v0z=0;
  7.  
  8. m=1;
  9. k=0.8;
  10. g=10;
  11.  
  12. p0=[x0, y0, z0];
  13.  
  14. points=[];
  15. points=[points ; p0];
  16.  
  17. pointsToDraw=[];
  18. pointsToDraw=[pointsToDraw ; p0];
  19.  
  20. tS=0.001;
  21. t =0;
  22.  
  23. for i=1:1:5
  24.     a=-v0x^2 - v0y^2 - 0.5 * g;
  25.     b=-2*x0*v0x - 2*y0*v0y + v0z;
  26.     c=-x0^2 - y0^2 + z0;
  27.    
  28.     delta=b^2-4*a*c;
  29.    
  30.     if(delta>=0)
  31.         t1=(-b - sqrt(delta))/(2*a);
  32.         t2=(-b + sqrt(delta))/(2*a);
  33.        
  34.         t=max(t1,t2);
  35.            
  36.         x1=x0+v0x*t;
  37.         y1=y0+v0y+t;
  38.         z1=z0+v0z+t - 0.5*g*t^2;
  39.         points = [points; x1 y1 z1];
  40.         pointsToDraw=[pointsToDraw; x1 y1 z1];
  41.                  
  42.         x0=x1;
  43.         y0=y1;
  44.         z0=z1;
  45.  
  46.  
  47.         N = [-2*x1,-2*y1, 1];
  48.        
  49.         n = N/norm(N);
  50.         vb = [v0x v0y v0z-g*t];
  51.         va = sqrt(k) * (vb - (2 * (dot(vb, n) * n)));
  52.      
  53.         v0x = va(1);
  54.         v0y = va(2);
  55.         v0z = va(3);
  56.        
  57.         display(t);
  58.     end
  59. end
  60.  
  61. % points;
  62. % velocities;
  63. % [X,Y] = meshgrid(-20:1:25);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top