Previous Section  < Day Day Up >  Next Section

Visualization Experience

On the CD-ROM, you will find a demo named 1D Racer. Here's a brief description from the programmer, Kaveh Kahrizi:

1D Racer demonstrates the motion of an object with constant acceleration moving through space. First you choose the formula you want, and then you choose the unknown variable. After you have entered valid values for the three known parameters, the race begins. The formulas are clearly marked in the Game class's header (Game.h) by the large comment block. The workspace was created in Visual Studio 6.0, although the files can easily be added to any existing workspace without your having to change the project settings, as long as the compiler is configured to know where DirectX include and library files are located. The program's executable requires that DirectX 8.1 runtime or higher be installed on the machine. To compile the code yourself, you must have the DirectX 8.1 SDK (Software Developer's Kit) or higher. Both of these can be downloaded for free from Microsoft's website at www.Microsoft.com.

Go ahead and run the demo by double-clicking 1DRacer.exe. The first thing you'll see is four of the five equations listed on the screen. Choose the first one (vf = vi + at). Next the application asks you which variable you want to solve for; choose a. Then you can enter the three variables you know. Enter the following values:

vi = 0

vf = 50

t = 10

Press Enter to begin the race. The application tracks time, displacement, and current velocity as the race progresses. You can pause the car at any point by pressing the P key. Try repeating this process, and pause halfway through (t = 5) to see how fast the car is going compared to its speed at the very end. To repeat the race, press the Backspace key.

When you're done, press Backspace, and try using a different equation. You can repeat the examples to see the actual motion. Let's go back to Example 8.8. After the units were converted, you had the following list:

Given

Find

vi = 50mi/hr

 

= 22.35m/s

Dx = ?

vf = 0mi/hr

 

= 0m/s

 

a = –6.5m/s2

 

Start a new race using the last equation (graphics/08inl02.gif). You want to solve for Dx. Then enter the metric values from the table, and run the race. Did you get a displacement close to Dx = 38.425m?

You might want to use this demo to check your answers to the self-assessment questions. Also try making up your own questions, and see what you get. You might want to try pausing the car at different times to track the motion as the race progresses.

Next, you can view the source code by double-clicking 1DRacer_code.txt. If you scroll down far enough, you'll see the sections where the actual equations were coded. Notice that each equation had to be rewritten four times—once for each variable the user could ask for. You might want to consider attempting a text-based application that performs similar operations.

    Previous Section  < Day Day Up >  Next Section