visual arrow follwoing motion of ball.

I have created plane as floor and sphere as ball. I used physics equations to it and ball falls under gravity. Now i want to attach visual arrow to this ball which moves with it according to velocity direction. If ball bounces then direction of velocity is changed so does arrow.
Thanks in advance for help.

I assume that you need the equation for velocity. It would be useful to show what equations you used for the motion of the ball. Say z is the vertical direction, and gravity is along -z, then
x1=x0+vx*dt, vx is constant
y1=y0+vy*dt, vy is constant
z1=z0+v0z*dt-0.5*az*dt*dt, az is the acceleration downward
Then v1z=v0z-az*dt. If z1<zplane, then, in the first approximation (dt is small) v1z=-v1z.

If you want the animation to be smooth, and dt is large, then, if collision occurs, you need to compute the collision time instead:
You choose the positive solution for dtplane, since it occurs after the ball is at z0
vplane=v0z-az*dtplane. Note that vplane is negative. Then reverse vplane in equations after collision

Also, for nice graphics, consider the bouncing to be at the bottom of the ball, not in the center
Last edited on
Topic archived. No new replies allowed.