Wednesday, June 24, 2015

physics - How do I change the speed of an object without changing path travelled?


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.



Answer



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.


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...