How to calculate this simple animation effect (physics engine)? -
i implementing simple animation effect game. scenario this:
there elastic rubber line, length 1 meter, when extended on 1 meter, elastic.
the line connects 2 dots , b this, distance s, s > 1 meter
a <------------- b
then prepare dot a, , releases b, line takes b direction of ai want know how calculate time t, b costs move x meters towards (x <= s).
any ideas? thanks!
i have been meaning larn how animate these kinds of images in sage (a python based platform math) while, used excuse. hope code snippet , image helpful.
a = 3 w = 0.5 # x = f(t) = cos(wt) within elastic part # x = displacement 1 meter mark # in below code, x displacement origin (x = cos(wt) + 1) # find speed when cross 1 meter mark # f'(t) = -aw sin(wt), max speed # ie f'(t @ 1 meter mark) = -aw speed_max = -a * w # time reach max speed + time cross lastly meter eta = float(pi/2 * 1/w + 1/abs(speed_max)) # function looking def time_left(x): if x < 1: homecoming x/abs(speed_max) else: homecoming 1/w * arccos((x-1)/a)
it may not clear in image within 1 meter of origin there no acceleration.
game-engine physics-engine
No comments:
Post a Comment