Hello,
If you actually want the physics of this, it's basically velocity change over time (acceleration) and distance change over time (velocity). If someone is jumping in place up and down, their legs give them a certain acceleration. Once they leave the ground, this acceleration is translated into velocity. Since we're mostly interested in what is happening when they leave the ground (the actual jump) we don't have to concentrate too much on the acceleration before the jump because we really only want that initial velocity when they leave the ground. If it is important to find out how much acceleration their legs applied to affect the velocity, we'd have to have a time interval for that buildup.
I'll skip that and assume the time interval is 1 so our initial velocity will equal our acceleration.
Now that we have our initial velocity, it is going to decrease because of gravity as the jumper goes up. They will continue to rise and slowdown at a deceleration rate = to gravity (-9.8) until their jumping velocity = 0. Once it equals zero, it will increase in the opposite direction at a rate = gravity (-9.8) until they hit the ground.
I put together an example of a perpetually bouncing ball. What I wrote above applies. I also included a bunch of general motion physics equations in the form of functions. They are variations of each other and can be applied according to what the situation calls for and what elements need to be solved for.
`**************************************
`* Title : bouncing ball - physics functions
`* Author : Latch Grapple
`* Date : 10/7/2006
`* Version: 0.1
`**************************************
rem ------ Set Up Display -------------
autocam off
set display mode 800,600,16
sync on
rem ------ make matrix ------
make matrix 1,1000,1000,50,50
rem ------ make ball --------
make object sphere 1,25
position object 1,500,get ground height(1,500,500)+25,500
rem ------ position camera ------
position camera 500,50,400
do
rem ----- set up our initials and constants ---------
mass#=10
force#=400
accel#=accel_2(force#,mass#)
ivel#=vel_2(0.0,accel#,1.0)
fvel#=0
time#=0
x#=object position x(1)
y#=object position y(1)
z#=object position z(1)
rem ------ the actual "bounce" loop change in velocity and distance ----
rem ------ affected by gravity
while fvel# >= 0
inc time#,.05
fvel#=vel_2(ivel#,-9.8,time#)
distance#=distance(fvel#,time#,-9.8)
set cursor 0,0
print "final velocity : ";fvel#;
print " distance : ";distance#
if distance# < 0 then distance# = 0
position object 1,x#,y#+distance#,z#
sync
endwhile
loop
end
rem ------------------- Force, Acceleration, Velocity equations ----------------
function vel_2(ivelocity#,acceleration#,time#)
v#=ivelocity#+(acceleration#*time#)
endfunction v#
function vel_1(distance#,time#)
v#=distance/time#
endfunction v#
function force(mass#,acceleration#)
f#=mass#*acceleration#
endfunction f#
function accel_1(vel1#,vel2#,time#)
a#=(vel2#-vel1#)/time#
endfunction a#
function accel_2(force#,mass#)
a#=force#/mass#
endfunction a#
function distance(ivelocity#,time#,acceleration#)
s#=(ivelocity#*time#)+(acceleration#*(time^2))/2
endfunction s#
I calculate the acceleration and initial velocity based on the mass and the force I want to apply to the ball. Since I'm not building up speed, I set the time value equal to one when I calculate the initial velocity.
Then I take this velocity and plug it into the loop and calculate the new velocity (slowing down) due to gravity. I control time with the time# variable - the iterations of the loop are based on the values of the final velocity instead of time, so in a sense, time# is calculated based on what the final state of the object is instead of the other way around.
If you pick apart my loop, you will be able to tell how this sim isn't quite "real life". That's one good thing about computer sims, you only have to make it look like it's right!
Enjoy your day.