Advertisement
Guest User

Untitled

a guest
Sep 26th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.07 KB | None | 0 0
  1. import math
  2.  
  3. distance = 1.8
  4. acceleration = 0.303
  5.  
  6. startSpeed = 0.5
  7.  
  8. decelerationTime = startSpeed/acceleration
  9.  
  10. decelerationDistance = startSpeed*decelerationTime + 0.5*(-acceleration)*(decelerationTime**2)
  11.  
  12. print "deceleration time =", decelerationTime
  13. print "deceleration distance =", decelerationDistance
  14.  
  15. activeDistance = distance-decelerationDistance
  16.  
  17. print "active distance =", activeDistance
  18.  
  19. currentDistance = 0.0
  20. currentTime = 0.0
  21. timeInterval = 5.0
  22.  
  23. while ((int)(currentDistance*10000) != ((int)(activeDistance*10000)/2)):
  24.     if ((int)(currentDistance*10000) < ((int)(activeDistance*10000)/2)):
  25.         currentTime = currentTime + timeInterval
  26.     if ((int)(currentDistance*10000) > ((int)(activeDistance*10000)/2)):
  27.         timeInterval = timeInterval/2.0
  28.         currentTime = currentTime - timeInterval    
  29.     currentDistance = startSpeed*currentTime + 0.5*acceleration*(currentTime**2.0)
  30.  
  31. halfWayTime = currentTime
  32.  
  33. time = halfWayTime * 2.0 + decelerationTime
  34.  
  35. if (time > math.floor(time)):
  36.     time = math.floor(time+1)
  37.  
  38. print "time =", time
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement