Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- distance = 1.8
- acceleration = 0.303
- startSpeed = 0.5
- decelerationTime = startSpeed/acceleration
- decelerationDistance = startSpeed*decelerationTime + 0.5*(-acceleration)*(decelerationTime**2)
- print "deceleration time =", decelerationTime
- print "deceleration distance =", decelerationDistance
- activeDistance = distance-decelerationDistance
- print "active distance =", activeDistance
- currentDistance = 0.0
- currentTime = 0.0
- timeInterval = 5.0
- while ((int)(currentDistance*10000) != ((int)(activeDistance*10000)/2)):
- if ((int)(currentDistance*10000) < ((int)(activeDistance*10000)/2)):
- currentTime = currentTime + timeInterval
- if ((int)(currentDistance*10000) > ((int)(activeDistance*10000)/2)):
- timeInterval = timeInterval/2.0
- currentTime = currentTime - timeInterval
- currentDistance = startSpeed*currentTime + 0.5*acceleration*(currentTime**2.0)
- halfWayTime = currentTime
- time = halfWayTime * 2.0 + decelerationTime
- if (time > math.floor(time)):
- time = math.floor(time+1)
- print "time =", time
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement