I have created a bouncing ball animation in x3d. I am just curious how I could make the ball slow down at the peak of its height to make it look more realistic. Thank you in
Use 'real' physics for that.
ball have parameters
a(ax,ay,az) [m/s^2]... this is sum of all forces driving ball divided by its massv(vx,vy,vz) [m/s]... actual speed = integration of acceleration v += a * dtp(x,y,z) [m]... actual position = integration of velocity p += v * dtr [m]m [kg]dt [s] ... iteration step (update time)init start a,v values to (0,0,0) and p to start position
apply gravity, friction, collision
g(gx=0,gy=-9.81,gz=0)f2 = -(|v|^2)*c2 * (v/|v|) ... in gasf3 = -(|v|^3)*c3 * (v/|v|) ... in liquidif position before and after cross collision border reflect velocity * collision coef <=1 by impact normal also you can reflect position if crossing border is not possible.
put it all together in some timer / updating code with dt interval
a =g+(f2+f3+(driving force))/m
v+=a*dt
p+=v*dt
test_collisions()
redraw()
for manual change of position
just set p(x,y,z) to new position and also can set v=(0,0,0) to stop the ball