Home Contents Forum Links Tip Jar
Animation Math in Lingo       

Surface Gravity

Near the surface of the earth, acceleration due to gravity is constant and downward.

What this means in terms of the variables of the physics model is that yAccel will be a positive number (downward on the screen), and that it will not change throughout the animation (remains constant).

  property sp
property y, yVelo, yAccel --y pos,vel,acc 
property yGrav            --y gravity

on beginsprite(me)
  sp = sprite(me.spritenum)
  y = sp.locv --initialize position
  
yVelo = 0   --object starts at rest
 
yGrav = .2  --constant downward
end

on exitframe()
  --acceleration, velocity, position
  yAccel = yGrav
  yVelo = yVelo + yAccel  
  y = y + yVelo  

  
--check and react to condition
  
if y > 450 then yVelo = -yVelo

  --set sprite position
 
sp.locv = y
end

Surface gravity - source movie   - To restart, right-click and select "restart"

•How is this demo different than the acceleration demo?

Reacting to the "floor" (similar to the Checking for Conditions demo) creates a bouncing ball.

Try giving the ball a horizontal velocity and keeping it on the stage by either wrapping the horizontal position or bouncing it off the sides. Should the gravity affect horizontal acceleration? Why not? Since surface gravity acts only vertically, it has no effect on horizontal acceleration (gravity's horizontal component is zero).

Note that the ball is always undergoing acceleration, even when it is slowing down toward the top of its path. In physics, acceleration means change in velocity rather than "speeding up."

The statement yAccel=yGrav makes it appear that acceleration and force are equivalent to each other. Though this isn't the case, they are closely related. This is explained further in Mass.

So why does the ball keep bouncing lower? See Troubleshooting Quirks.

 
 


Copyright © 2003 JM Harward 
 jmckell~at~jmckell~dot~com
All lingo provided on this site may be used freely for educational purposes. Not for redistribution as uncompiled code. Instructional materials may not be reproduced without permission.