sstringer
06-27-2005, 08:10 PM
Hi all,
I am in pretty desperate need of some help with a simple math equation. I am working on an actionscript routine that handles a ball bouncing over words in a sentence as they are read aloud. The challenge is that I need the ball to bounce at specific beats in order to keep up with the words. The equation I need help with should be pretty simple for someone mathmatically inclined.
I have all of the physics worked out. The ball bounces and looks great. I just need to control the initial velocity. So, for simplicity's sake, let's take some shortcuts. 1) let's take all but the Y axis out of the equation. X-Velocity is fixed and is a solved problem. 2) gravity can be shorthanded as a decay rate applied each frame:
Vf = Vi * g
Where Vf is the final, or new, velocity for the current frame, Vi is the initial, or old, velocity from the previous frame, and g is the decay rate, or simplified gravity. This is pretty basic stuff.
The problem I'm having is applying this over time and in reverse in order to calculate the very first frame's initial velocity. I'm looking for a seed, or initial, velocity that, when applied in frame 1, will produce a final velocity of zero at time-x. For instance, let's say we want the ball to reach its zenith at frame 30 (1 second). What is the formula to calculate the initial velocity?
Vi = [???];
Where [???] produces equilibrium (velocity 0) after 30 frames. I assume it would be the sum of 30 increasingly decayed velocities, but I'm at a loss as to how I should calcualte those values. I'm also sure that distance over time plays a factor here, but I'm not sure how.
Any help would be most appreciated.
Many thanks,
Steve
I am in pretty desperate need of some help with a simple math equation. I am working on an actionscript routine that handles a ball bouncing over words in a sentence as they are read aloud. The challenge is that I need the ball to bounce at specific beats in order to keep up with the words. The equation I need help with should be pretty simple for someone mathmatically inclined.
I have all of the physics worked out. The ball bounces and looks great. I just need to control the initial velocity. So, for simplicity's sake, let's take some shortcuts. 1) let's take all but the Y axis out of the equation. X-Velocity is fixed and is a solved problem. 2) gravity can be shorthanded as a decay rate applied each frame:
Vf = Vi * g
Where Vf is the final, or new, velocity for the current frame, Vi is the initial, or old, velocity from the previous frame, and g is the decay rate, or simplified gravity. This is pretty basic stuff.
The problem I'm having is applying this over time and in reverse in order to calculate the very first frame's initial velocity. I'm looking for a seed, or initial, velocity that, when applied in frame 1, will produce a final velocity of zero at time-x. For instance, let's say we want the ball to reach its zenith at frame 30 (1 second). What is the formula to calculate the initial velocity?
Vi = [???];
Where [???] produces equilibrium (velocity 0) after 30 frames. I assume it would be the sum of 30 increasingly decayed velocities, but I'm at a loss as to how I should calcualte those values. I'm also sure that distance over time plays a factor here, but I'm not sure how.
Any help would be most appreciated.
Many thanks,
Steve