Potential Energy and the Conservation Law

 < Day Day Up > 

Now that we've defined work and kinetic energy, there's one more type of energy to define before we can tackle another formula for modeling motion. That energy is called gravitational potential energy (GPE) . Basically, GPE is the energy stored in an object due to its height off the ground. If you picked up this book and held it in the air, it would have gravitational potential energy. How do you know that energy is stored in the book? Just let go. Did the book move? Sureit fell to the ground because of gravity. This tells you that potential energy was stored in the book until it was released.

How do you measure the amount of energy stored in that book? Well, it's based on the object's mass and, most importantly, its height above the ground. In fact, it's simply the product of the object's weight in Newtons and its height.

Gravitational Potential Energy

GPE = mgy

where m = mass, g = acceleration due to gravity, and y = height.


NOTE

There are other types of potential energy, but they are relatively insignificant in terms of motion in a video game, so it's safe to ignore them. From this point forward we'll just use PE to represent gravitational potential energy, because it's the only type we're concerned with.


Looking closer at the definition of gravitational potential energy, you might be curious about the units. If we stay consistent with previous chapters, metric units are the most convenient . If you measure the mass in kilograms, the acceleration due to gravity in m/s 2 , and the height in meters , the potential energy is measured in joules (J), just like kinetic energy. Also, it is important to note that potential energy is a scalar quantity as well; it's simply an amount of energy with no direction. This means that you can ignore the direction of g and just use a positive 9.8m/s 2 .

Example 12.6: Gravitational Potential Energy

Suppose this book weighs 1.5 pounds , and you raise it 2 meters off the ground. What is its gravitational potential energy?

Solution
  1. Notice that the definition is based on mass, not weight. So let's first use the weight to calculate the mass:

    graphics/12equ02.gif


    w = m g

    6.6726N = m (9.8m/s 2 )

    m = 0.6809kg

  2. Now you go to the definition:

    PE = mgy = 0.6809kg(9.8m/s 2 )(2m) = 13.35J

The calculation for potential energy is also fairly straightforward. Before using any calculations involving gravity, you should be sure to define how gravity will be used in your game. For most games this should suffice ( assuming metric units):

 #define GRAVITY 9.81 

With this definition in hand, let's look at how to calculate potential energy. This function will give us the value of potential energy in Joules:

 float calculatePotentialEnergy(float mass,float height)      {        float PE;        PE = mass*GRAVITY*height;        return PE;      } 

Now that we've defined kinetic and potential energy, you can use them to model certain types of motion. Have you ever wondered how a roller coaster works? Think about the last time you rode one.

After being towed up the first hill, do you recall any additional motors or brakes until you reached the very end? If it was a traditional roller coaster, there weren't any. The entire ride was governed by a conservation law known as the law of conservation of mechanical energy . This particular law says that energy cannot be created or destroyed . It can only switch forms. The two forms of energy we've discussed so far are kinetic and potential.

Conservation of Mechanical Energy (Simplified)

KE i + PE i = KE f + PE f

or

graphics/12equ05.gif



Remember from the definitions that the faster an object moves, the more kinetic energy it has, and the higher it is off the ground, the more potential energy it has. What's fascinating is that the total amount of energy always remains the same; it just shifts between the different forms. Picture the roller coaster at the top of the first hill. It's really high, so it has a lot of potential energy. However, it's moving pretty slowly, so it has only a little bit of kinetic energy. Then it starts down the first big drop, and as it loses height, the coaster picks up speed. The potential energy is converting to kinetic. By the time the coaster gets down to the bottom of the hill, almost all the potential energy has switched to kinetic, and now the coaster is at its maximum speed. Then, as it goes up the next hill, the kinetic switches back to potential. It's a constant trade-off so that the total amount stays the same. This is illustrated in Figure 12.2.

Figure 12.2. A traditional roller coaster.

graphics/12fig02.gif

Example 12.7: Conservation of Mechanical Energy

Suppose you're programming an Indiana Jones game and you get to the part where he jumps into the mining cart and rides the track up and down a series of hills. If the cart is at a height of 100m when Indy jumps in, and together he and the cart weigh 300 pounds, how fast should they be going when they reach the bottom of the first hill (ground level)?

Solution
  1. Notice that both definitions require mass instead of weight, so first convert the weight to mass:

    graphics/12equ03.gif


    w = m g

    1334.52N = m (9.8m/s 2 )

    m = 136.18kg

  2. Now you can plug everything you know into the conservation law and solve for v f :

    graphics/12equ05.gif


    (136.18kg)(0) 2 + (136.18kg)(9.8m/s 2 )(100m) = (136.18kg)( v f ) 2 + (136.18kg)(9.8m/s 2 )(0m)

    0 + (136.18kg)(9.8m/s 2 )(100m) = (136.18kg)( v f ) 2 + 0

    (136.18kg)(9.8m/s 2 )(100m) = (136.18kg)( v f ) 2

    133451.96J = 68.09kg( v f ) 2

    graphics/12equ07.gif


    v f = 44.27m/s

NOTE

When you're working with this conservation law, remember that it holds true for any two points on the roller coaster, not just the top and bottom of the hill.

Also note that there is an m in each term of the conservation law. If you divide both sides of the equation by m , it cancels out, so the mass really is irrelevant.


Also note that this law is not limited to roller coasters. It holds true for any type of motion as long as no outside forces interfere. A roller coaster is a good example because it's an isolated scenario with no major outside forces. I say no "major" outside forces because you can take into account a few small forces such as friction and air resistance if you want to add a little more realism to the motion. In real life, some energy is lost to heat and sound because of friction and air resistance, but calculating the precise amount can be quite expensive in terms of processing power. However, there is a simple way to work this into your model. As time goes on, energy is lost. Adding an extra term that represents heat and sound energy to the left side of the conservation law forces a reduction in kinetic and potential energy, which produces a more realistic result. As time progresses, the vehicle never goes quite as high or quite as fast as it did in the beginning because of the slight loss of energy.

Conservation of Mechanical Energy (Modified)

KE i + PE i = KE f + PE f + E o

or

graphics/12equ08.gif


where E o represents other energy (heat/sound).


When you use this modified form, just make sure your extra term for heat and sound energy is relatively small compared to the other two forms of energy. This is a simple (and fast) cheat for modeling more realistic motion.

Example 12.8: Modified Conservation of Mechanical Energy

Suppose you go back to the Indiana Jones game, and you get to the part where he jumps in the mining cart and rides the track up and down a series of hills. This time you want to make it a little more realistic. If the cart is at a height of 100m when Indy jumps in, and together he and the cart weigh 300 pounds, and about 2000J of energy is lost to heat and sound, how fast should they be going when they reach the bottom of the first hill (ground level)?

Solution
  1. Notice that both definitions require mass instead of weight, so first convert the weight to mass:

    graphics/12equ04.gif


    w = m g

    1334.52N = m (9.8m/s 2 )

    m = 136.18kg

  2. Now you can plug everything you know into the modified conservation law and solve for v f :

    graphics/12equ09.gif


    (136.18kg)(0) 2 + (136.18kg)(9.8m/s 2 )(100m) = (136.18kg)( v f ) 2 + (136.18kg)(9.8m/s 2 )(0m) + 2000J

    0 + (136.18kg)(9.8m/s 2 )(100m) = (136.18kg)( v f ) 2 + 0 + 2000J

    (136.18kg)(9.8m/s 2 )(100m) = (136.18kg)( v f ) 2 + 2000J

    133451.96J = 68.09kg( v f ) 2 + 2000J

    131451.96J = 68.09kg( v f ) 2

    graphics/12equ10.gif


    v f = 43.94m/s

Notice that with the modified version of the conservation law, the final speed is slightly lower because some energy is lost. If this doesn't seem noticeable, you might want to bump up the amount of lost energy. If the vehicle were a sled going down an icy hill, you might even choose to use a smaller value for the energy loss. After you experiment a little, you'll get a feel for how large or small to make E o .

NOTE

This ( E o ) is one variable you might be wise to expose to your designers to allow them to tune it for feel.


At this point, you have several choices for modeling an object's motion. You can always go back to Newton's Second Law and the five equations of motion. However, in some cases you might find this energy approach to be more efficient, because there might be fewer calculations. It all depends on the situation you are modeling, so it's great to have options.

Self-Assessment

1.

If a 50-kg boulder is teetering on the edge of a cliff 300 meters high, what is its gravitational potential energy?

2.

If the boulder described in question 1 falls , how fast is it going when it hits the ground?

3.

A couple of troublemakers set up a slingshot on the ground to launch water balloons. If the slingshot gives the balloons an initial speed of 20m/s, find the maximum height the balloons should reach.

4.

Find the speed of the water balloons described in question 3 when they get halfway up to the maximum height.


 < Day Day Up > 


Beginning Math and Physics for Game Programmers
Beginning Math and Physics for Game Programmers
ISBN: 0735713901
EAN: 2147483647
Year: 2004
Pages: 143
Authors: Wendy Stahler

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net