I have a ball which is being thrown from one side of a 2D space to the other. The formula I am using for calculating the ball's position at any one point in time is:

x = x0 + vx0*t
y = y0 + vy0*t - 0.5*g*t*t

where g is gravity, t is time, x0 is the initial x position, vx0 is the initial x velocity.

What I would like to do is change the speed of this ball, without changing how far it travels. Let's say the ball starts in the lower left corner, moves upwards and rightwards in an arc, and finishes in the lower right corner, and this takes 5s. What I would like to do is change it so the ball still follows the same curve and finishes in the same position, but takes 10s or 20s to do so.

How can I achieve this? All I can think of is manipulating t but I don't think that's a good idea. I'm sure it's something simple, but my maths are pretty shaky.


1 Answer 1


Actually, you're correct -- without switching equations, the only way you have of altering speed without altering the path is to manipulate t.

For the given x0 and y0, you need to record t0. Then:

rate = 0.25 // run path at one-quarter speed

t' = (t - t0) * rate

x = x0 + vx0*t'
y = y0 + vy0*t' - 0.5*g*t'*t'

Essentially what you are doing is slowing down time for the ball's path, without slowing down anything else.

  • \$\begingroup\$ Hmmm, ok - so now the tricky part. Say I have 10 balls, and vx0 and vy0 are randomly selected for each ball (within certain constraints). What I want to do is have all the balls moving at roughly the same speed. How do I determine rate based on vx0 and vy0? Or should I be looking at a different set of equations? \$\endgroup\$ Feb 1, 2011 at 2:35
  • \$\begingroup\$ You won't ever get them all moving at the same speed -- indeed, the function for y ensures, via 0.5*g*t'*t', that all balls are constantly accelerating toward the ground. If all you want to do is to match apparent starting velocities, while, say, allowing some balls to travel higher, you need to modulate rate based on the magnitude of (vx0, vy0); in other words, sqrt(vx0*vx0 + vy0*vy0) * rate = <desired global speed>. \$\endgroup\$ Feb 1, 2011 at 3:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .