# Farseer: How can I calculate the needed velocity in this case?

I have two platforms and one ball. The ball should fly from the red platform to the blue platform. The ball should land somewhere in the purple rectangle of the blue platform.

How can I know how fast the linear velocity of the ball should be to accomplish the jump of the ball? Is there a mathematical formula to calculate the linear velocity(x,y) which should be added to the ball so that the ball can jump to the blue platform?

The ball should always land in the purple area.

Distance(width) from the ball to the target: 212 pixel

Distance(height) from the ball to the target: 52 pixel

The distances were measured from the center of the ball to the center of the purple rectangle.

The gravitation of my world is world(0,3).

Upadte I use the following formula for the impulse:

impulse = Vector2(distance.x / time * mass + gravity.x / 2 * time * mass, distance.y / time * mass + gravity.y / 2 * time * mass);

mass: mass of the ball

It's working with this formula, but only if the value of the time is not too low. time = 2.0f(or higher) is working but if I use time = 1.0f, then the ball is touching the left side of the blue platform.

Why is the formula not working with low time values? I don't understand that.

• Did you understand the explanation I gave for why picking too short of a time results in it flying straight into the side? I notice you accepted the answer but no upvote. – MickLH Jan 15 '14 at 17:46

impulse = (gravity * time*time + distance * 2.0) / (time * 2.0);


(or optimized for the specific numbers you asked for)

impulse = Vector2(212.0/time, 52.0/time + 1.5*time);


(although, I think maybe you wanted this one that accounts for gravity but can be used to calculate any possible jump)

impulse = Vector2(distance.x/time, distance.y/time + 1.5*time); Integrate to find that: Solving this for impulse yields: Which is our answer, notice that time is still unknown in this system. This means there are infinite trajectories that will land on the purple rectangle. You have to decide how long it should take.

• What is this "1.5*time"? Why do you use the value 1.5? – Homer_Simpson Jan 12 '14 at 18:40
• Half of your gravity. Did you read the equation? – MickLH Jan 12 '14 at 18:49
• Yes, I read the equation and I guess I understood it now. I have one more question. If my world's gravitation would be world(4,3), would the formula then be: impulse = Vector2(distance.x/time + 2*time, distance.y/time + 1.5*time); Is the formula correct? – Homer_Simpson Jan 12 '14 at 20:31
• I updated my question. I don't understand why the formula is not working with low time values. – Homer_Simpson Jan 12 '14 at 22:19
• You have to use some logic to figure out what a possible time is, of course if you make the time very low, it cannot fly up far enough to make it over the box because gravity would take too long to bring it back down. – MickLH Jan 13 '14 at 14:39