Bounce a ball from one point to another - Vector and Acceleration

748 views Asked by At

I have a ball which drops to a point, from which it should bounce and reach another point.

My ball starts with an acceleration towards the first point, hits the point and bounces off to the left side. What I want is the velocity & acceleration applied to the ball after hitting the first point, so it both has a bouncing effect, and reaches it's destination (doesn't go offside, like the bright trail).

I have the linear vector between points, coordinates of points and angle between them.

Explanation

2

There are 2 answers

0
stacker On

If you don't want a full blown physics simulation you could fake this by a linear interpolation (lerp) from the start point to end-point.

See Moving object from vector A to B in 2d environment with in increments of percents for lerp in java script.

Change the coordinate pointing upwards (y or z) depending on the coordinate system you use. While t is animated from 0..1:

 var relativeHeight = Math.Sin( t * Math.PI ) * curveAmplitude;
 posy = orgPosy + relativeHeight;
2
Ignacio Vazquez-Abrams On

First we figure out how long it will take to get from the higher point to the lower point by solving for t:

at2 + viyt = dy

Then we take t and use it for our lateral velocity:

vx = dx / t

Once you have the lateral velocity, just slice time up as finely as you like and move the ball to each calculated point in turn.