For a little programming project that should animate a billiards ball (without fraction and in a vacuum), I need to find out the
y coordinates of the ball at any point in time given its start and end coordinates and its speed.
Let's say, the ball starts from coordinate
x = 10.1 cm, y = 10.5 cm and will hit the hole at coordinate
x = 500 cm, y = 200 cm. The speed of the ball is
7.0 cm per second.
I want to show the ball at any point in time, where time starts at 0 seconds.
So far I thought of using Pythagoras somehow:
x^2 + y^2 = z^2
y are the current coordinates and
z being the distance that the ball rolled from its start location up to the current point in time.
Since I know that the total
x distance is
489.9 cm and the total y distance is
189.5 cm, I assume that I can write
y as a factor of
189.5 / 489.9 which results to
y_factor = 0.3868....
Now I need to figure out the
y coordinates at some point in time, say 3.5 seconds.
According to my Pythagoras thought:
x^2 + (0.3868*x)^2 = 3.5
I think that leaves me the following:
distance = speed * time_passed current_x = squareroot(distance) / squareroot(y_factor^2 + 1) current_y = current_x * y_factor;
To my astonishment, the animation gets slower and slower over time and I have no idea why.
Where am I wrong here?
As you can clearly see, my understanding of mathematics is more than dusty, so please try to write in laymans terms (or programming jargon)..