<< Chapter < Page Chapter >> Page >

Measuring variable velocity in the real world

Measuring variable velocity in the real world can be difficult. What you need to do is to measure the displacement of an object in as short a time interval aspossible and then divide the displacement by the value of the time interval. Ifyou can do this at enough points in time, you can construct curves that represent the variable velocity to which the object is being subjected.

Estimating variable velocity graphically

Assuming that you are able to create a plot of displacement versus time at closely-spaced points, you can estimate the variable velocity curve byconnecting each pair of points with a straight line and measuring the slope of each such straight line segment. An estimate of the velocity during the intervaldefined by a pair of points is the slope of the line that connects those points. The closer the points are, the better will be the estimate of thevelocity at a point half way between those two points.

In the situation where you are able to collect enough data to draw a smooth curve of displacement versus time, the instantaneous velocity at any point onthat curve is the slope of a line that is tangent to the curve at that point. Note, however, that the construction of such a tangent line is difficult.

Units of velocity

If may recall from your high school geometry course that the slope of a line is given by the "rise over run." In other words, the slope ofthe line is the ratio of the height to the base of a right triangle for which the hypotenuse is on or parallel to the line.

Estimate some variable velocity values

At this point, I encourage you to use an object with a straight edge, place it firmly on two points that define a time interval on your graph,estimate the slope of the edge, and record that slope as your estimate of the velocity at the center of that time interval. We will do something similar in our script.

Explanation of the code

The code in Listing 1 begins by declaring and initializing values to contain the parameters of the problem:

  • The acceleration of gravity in feet/sec^2. Note that this value is negative indicating that the gravitational attraction is toward the centerof the earth (down).
  • The initial velocity of the arrow in feet/sec. This value is positive because the direction of velocity is away from the center of the earth (up).
  • The height of the arrow when it is released, positive values meaning up from the ground.
  • The time interval at which successive estimates of the height of the arrow will be computed.

Working variables

Following that, the code in Listing 1 declares and initializes two working variables for time and distance that will change as the program progresses.

Then Listing 1 declares and initializes a variable named sp that is used solely to insert spaces between the columns in the output display.

A while loop

A while loop is used to evaluate the equation given earlier , to compute and display the height of the arrow every 0.25 seconds for as long as the arrow is above theground (height is positive). The loop continues to iterate and display time and height values in two separate columns (see Figure 2 ) until the computation produces one negative height value.

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Game 2302 - mathematical applications for game development. OpenStax CNX. Jan 09, 2016 Download for free at https://legacy.cnx.org/content/col11450/1.33
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Game 2302 - mathematical applications for game development' conversation and receive update notifications?

Ask