Skip to content Skip to navigation Skip to collection information

OpenStax_CNX

You are here: Home » Content » GAME 2302 - Mathematical Applications for Game Development » GAME 2302-0380 Motion -- Variable Velocity and Acceleration

Navigation

Recently Viewed

This feature requires Javascript to be enabled.
Download
x

Download collection as:

  • PDF
  • EPUB (what's this?)

    What is an EPUB file?

    EPUB is an electronic book format that can be read on a variety of mobile devices.

    Downloading to a reading device

    For detailed instructions on how to download this content's EPUB to your specific device, click the "(what's this?)" link.

  • More downloads ...

Download module as:

  • PDF
  • EPUB (what's this?)

    What is an EPUB file?

    EPUB is an electronic book format that can be read on a variety of mobile devices.

    Downloading to a reading device

    For detailed instructions on how to download this content's EPUB to your specific device, click the "(what's this?)" link.

  • More downloads ...
Reuse / Edit
x

Collection:

Module:

Add to a lens
x

Add collection to:

Add module to:

Add to Favorites
x

Add collection to:

Add module to:

 

GAME 2302-0380 Motion -- Variable Velocity and Acceleration

Module by: R.G. (Dick) Baldwin. E-mail the author

Summary: The purpose of this module is to explain variable velocity and acceleration.

Preface

General

This module is part of a series of modules designed for teaching the physics component of GAME2302 Mathematical Applications for Game Development at Austin Community College in Austin, TX. (See GAME 2302-0100: Introduction for the first module in the course along with a description of the course, course resources, homework assignments, etc.)

The purpose of this module is to explain variable velocity and acceleration.

Viewing tip

I recommend that you open another copy of this document in a separate browser window and use the following links to easily find and view the Images and Listings while you are reading about them.

Images

  • Image 1 . Graph for variable velocity exercise #1.
  • Image 2 . Screen output for Listing #1.
  • Image 3 . Displacement versus time for first five time intervals.
  • Image 4 . Screen output for Listing #2.
  • Image 5 . Screen output for Listing #3.
  • Image 6 . Screen output for Listing #4 at 45 degrees.
  • Image 7 . Trajectory for two different firing angles.
  • Image 8 . Screen output for Listing #4 at 60 degrees.
  • Image 9 . Screen output for Listing #5.
  • Image 10 . Screen output for Listing #6.
  • Image 11 . Screen output for Listing #7.

Listings

General background information

I will provide an introduction to variable velocity, acceleration, and the acceleration of gravity in this section. I will provide exercises on those topics in the next section.

Variable velocity

What is velocity?

To review, you learned in an earlier module that velocity is the rate of change of position. Since displacement is a change in position, velocity is also the rate of displacement.

Uniform versus variable velocity

Previous modules have dealt exclusively with uniform velocity. However, many situations in life involve variable velocity and acceleration. For example, the simple act of stopping an automobile at a traffic light and then resuming the trip once the light turns green involves variable velocity and acceleration.

Three equations

I will explain both of these topics in this module using three well-known physics equations that deal with the displacement of a projectile in a vacuum under the influence of gravity .

The equation that we will spend the most time on is

h = v0*t + 0.5*g*t^2

where

  • h is the distance of the projectile above the surface of the earth
  • v0 is the initial velocity of the projectile
  • t is time in seconds
  • g is the acceleration of gravity, approximately 9.8 meters per second squared, or approximately 32.2 feet per second squared at the surface of the earth. (We will also do an exercise involving the acceleration of gravity on the moon.)

(I will provide the other two equations later .)

Acceleration

Everyone is familiar with the acceleration that occurs when a motor vehicle speeds up or slows down. When the vehicle speeds up very rapidly, the positive acceleration forces us against the back of the seat. (This involves the relationship among force, mass, and acceleration, which will be the subject of a future module.)

If the vehicle slows down very rapidly or stops suddenly, the negative acceleration may cause us to crash into the windshield, the dashboard, or a deployed airbag.

The accelerator pedal

A common name for the pedal that causes gasoline to be fed to the engine is often called the accelerator pedal because it causes the vehicle to speed up. (However, I have never heard anyone refer to the pedal that causes the vehicle to slow down as the deceleration pedal. Instead, it is commonly called the brake pedal.)

Definitions

Displacement is a change in position.

Velocity is the rate of change of position or the rate of displacement .

Acceleration is the rate of change of velocity .

Jerk is the rate of change of acceleration (not covered in this module).

According to this author , there is no universally accepted name for the rate of change of jerk .

The algebraic sign of acceleration

When the velocity of a moving object increases, that is viewed as positive acceleration. When the velocity of the object decreases, that is viewed as negative acceleration.

Uniform or variable acceleration

Acceleration may be uniform or variable. It is uniform only if equal changes in velocity occur in equal intervals of time.

A vector quantity

Acceleration has both direction and magnitude. Therefore, acceleration is a vector quantity.

The units for acceleration

The above definition for acceleration leads to some interesting units for acceleration. For example, consider a situation in which the velocity of an object changes by 5 feet/second in a one-second time interval. Writing this as an algebraic expression gives us

(5 feet/second)/second

Multiplying the numerator and the denominator of the fraction by 1/second gives us

5 feet/(second*second)

This is often written as

5 feet/second^2

which is pronounced five feet per second squared.

The acceleration of gravity

The exercises in the remainder of this module are based on the following two assumptions:

  • For practical purposes, the effect of the acceleration of gravity is the same regardless of the height of an object above the surface of the earth, provided that the distance above the surface of the earth is small relative to the radius of the earth.
  • In the absence of an atmosphere, all objects fall toward the earth with the same acceleration regardless of their masses.

Let's examine the validity of these two assumptions.

Newton's law of universal gravitation

This law states that every point mass in the universe attracts every other point mass with a force that is directly proportional to the product of their masses and inversely proportional to the square of the distance between them. (Separately it has been shown that large spherically symmetrical masses attract and are attracted as if all their mass were concentrated at their centers.)

Effect of gravity versus altitude

An object at the surface of the earth is approximately 3963 miles from the center of the earth. An object that is six miles above the surface of the earth (typical flying altitude for a passenger plane) is approximately 3969 miles from the center of the earth.

Therefore, (if I didn't make an arithmetic error) the gravitational attraction between the earth and that object changes by less than 0.5 percent when the object is transported from the surface of the earth to a position that is six miles above the surface of the earth.

For practical purposes, therefore, we can assume that the acceleration of gravity is constant up to at least 32000 feet above the surface of the earth.

Acceleration is independent of mass

Newton's law, as applied to the gravitational attraction of the earth, expressed in algebraic terms, looks something like the following :

f =E*m/d^2

where

  • f is the attractive force between the earth and another object
  • E is the mass of the earth
  • m is the mass of the other object
  • d is the distance between the center of mass of the earth and the center of mass of the other object

Force equals mass times acceleration

It is a well-known principle of physics that an object that is free to move will move and will accelerate when subjected to a force. The acceleration of the object will be proportional to the force and inversely proportional to its mass. In other words,

a = f/m

where

  • a is the acceleration in units such as meters/sec^2
  • f is force in units such as kilograms*meters/sec^2 (newtons)
  • m is mass in units such as kilograms

By multiplying both sides of the equation by m, we get a more common presentation of this relationship, which is

f = m*a

where the symbols mean the same as listed above .

A ratio of two different forces of gravity

Now let's use the equation from above to form a ratio of the forces exerted on two different masses by the earth, assuming that both masses are the same distance from the center of the earth.

f1/f2 =(E*m1/d^2)/(E*m2/d^2)

Cancel like terms to simplify

If we cancel like terms from the numerator and denominator of the expression on the right, we can simplify the ratio to

f1/f2 = m1/m2

Replacing the forces on the left by the expression from above , we get

m1*a1/m2*a2 = m1/m2

Multiplying both sides by m2/m1 we get

a1/a2 = 1

or

a1 = a2

This shows that the acceleration resulting from the gravitational force exerted on two objects that are equally distant from the center of mass of the earth is the same regardless of the differences in mass of the two objects.

Discussion and sample code

I will present and explain several different scenarios based on the above assumptions in this section.

Variable velocity exercise #1

An archer that is six feet tall shoots an arrow directly upward with a velocity of 100 feet per second. Assume the arrow is at a height of 6 feet when it leaves the bow. Also ignore the effects of air resistance.

Plot height versus time

Use your graph paper and plot the height of the arrow on the vertical axis versus time on the horizontal axis. Plot one point each 0.25 seconds. Allow for a maximum time value of about 7 seconds and a maximum height value of about 165 feet.

Your plot should look something like the curve in Image 1 .

1
Image 1: Graph for variable velocity exercise #1.
Missing image.

Create a script

Let's analyze this situation using a script. Copy the code shown in Listing 1 into an html file and open the file in your browser.

2
Listing 1: Variable velocity exercise #1.
<!---------------- File JavaScript01.html --------------------->
<html><body>
<script language="JavaScript1.3">

document.write("Start Script <br/>");

//Declare and initialize constants
var g = -32.2;//acceleration of gravity in ft/(sec*sec)
var v0 = 100;//initial velocity in ft/sec
var h0 = 6;//initial height in feet
var tInc = 0.25;//calculation interval in seconds

//Declare and initialize working variables
var t = .0001;//current time in seconds
var h = h0;//current height in feet

//The following variable is used to insert spaces in
// the output display.
var sp = "&nbsp;&nbsp;&nbsp;&nbsp;"

//Compute and display various values for as long as the
// height of the projectile is above the ground.
while(h > 0){
  //This is the general equation for the height of a
  // projectile under the influence of gravity in a
  // vacuum.
  h = h0 + v0*t +0.5*g*t*t;

  //Display the information for this iteration
  document.write(
      "t = " + t.toFixed(2) + " seconds" + sp +
      " h = " + h.toFixed(1) + " feet" + sp +
      "<br/>");

  //Increment the time for the next iteration.
  t = t + tInc;
}//end while loop

document.write("End Script");

</script>
</body></html>

Screen output

The text shown in Image 2 should appear in your browser window when you open the html file in your browser.

3
Image 2: Screen output for Listing #1.
Start Script
t = 0.00 seconds     h = 6.0 feet    
t = 0.25 seconds     h = 30.0 feet    
t = 0.50 seconds     h = 52.0 feet    
t = 0.75 seconds     h = 72.0 feet    
t = 1.00 seconds     h = 89.9 feet    
t = 1.25 seconds     h = 105.8 feet    
t = 1.50 seconds     h = 119.8 feet    
t = 1.75 seconds     h = 131.7 feet    
t = 2.00 seconds     h = 141.6 feet    
t = 2.25 seconds     h = 149.5 feet    
t = 2.50 seconds     h = 155.4 feet    
t = 2.75 seconds     h = 159.2 feet    
t = 3.00 seconds     h = 161.1 feet    
t = 3.25 seconds     h = 160.9 feet    
t = 3.50 seconds     h = 158.8 feet    
t = 3.75 seconds     h = 154.6 feet    
t = 4.00 seconds     h = 148.4 feet    
t = 4.25 seconds     h = 140.2 feet    
t = 4.50 seconds     h = 130.0 feet    
t = 4.75 seconds     h = 117.7 feet    
t = 5.00 seconds     h = 103.5 feet    
t = 5.25 seconds     h = 87.2 feet    
t = 5.50 seconds     h = 69.0 feet    
t = 5.75 seconds     h = 48.7 feet    
t = 6.00 seconds     h = 26.4 feet    
t = 6.25 seconds     h = 2.1 feet    
t = 6.50 seconds     h = -24.2 feet    
End Script  

Analysis of the output

Your curve should begin at a height of 6 feet and the height should increase on a point-by-point basis out to about 3 seconds. The maximum height should occur around 3 seconds and should then start decreasing. The height should go to zero between 6.25 seconds and 6.5 seconds.

Not a trip to outer space

As you are probably aware, shooting an arrow upward does not cause the arrow to go into outer space, unless the arrow is self-propelled and manages to reach a velocity commonly known as the "escape velocity."

Instead, for any practical value of initial velocity (neglecting air resistance), gravitational attraction will eventually cause the arrow to slow down, reverse course, and fall back to earth with continually increasing velocity until it strikes the earth and stops. That is the message conveyed by the plot of height in Image 1 and the output from the script shown in Image 2 .

The maximum height

At about 3 seconds and a height of about 161 feet, the kinetic energy provided by the initial velocity will have been dissipated by the gravitational attraction of the earth. At that point, the arrow won't go any higher. Instead, it will start falling back toward the earth. Somewhere around 6.25 seconds, it will strike the earth.

The shape of the curve

The shape of this curve is controlled by only two factors: the initial velocity of the arrow and the gravitational attraction of the earth. The archer has some degree of control over the initial velocity, but has no control over the gravitational attraction of the earth.

In theory, in the absence of an atmosphere, if the arrow is shot straight up, the arrow should land in the same place from which it was shot. In practice in the real world, wind and other factors would probably prevent that from happening.

Variable velocity

We learned in an earlier module that if velocity is uniform, the displacement should be the same during each successive equal interval of time. However, we can see from Image 2 that is not true in this case. For example, Image 3 shows the displacement versus time for the first five time intervals and we can see that it is anything but uniform.

4
Image 3: Displacement versus time for first five time intervals.

Interval Displacement
   1          24
   2          22
   3          20
   4          17.9
   5          15.9

Successively decreasing or increasing displacement

Referring back to Image 2 (along with Image 3 ), we see that the displacement during the first 0.25 second time interval was 24 feet, but the displacement between 2.75 seconds and 3.0 seconds was only 1.9 feet, Furthermore, the displacement was -0.2 feet during the interval between 3 seconds and 3.25 seconds indicating that the arrow had begun falling back to the earth.

As you can see in Image 2 , from that point until contact with the ground, the displacement increased during each 0.25 second interval.

In this case, the velocity clearly wasn't uniform. Instead it was variable. The velocity decreased as the arrow was going up, and increased as the arrow was falling back down.

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 as possible and then divide the displacement by the value of the time interval. If you 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 by connecting 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 interval defined 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 the velocity 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 on that 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 of the 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 center of 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 the ground (height is positive). The loop continues to iterate and display time and height values in two separate columns (see Image 2 ) until the computation produces one negative height value.

When the test at the top of the while loop determines that the previously-computed value for height was negative,

  • the body of the loop is skipped,
  • the "End Script" message is displayed, and
  • the script terminates.

This is not a complicated script in comparison with some of the scripts that were presented in earlier modules.

Given the output shown in Image 2 , you should be able to estimate and plot the velocity of the arrow on the same graph by dividing the displacement during each time interval by the value of the time interval.

Variable velocity exercise #2

Estimating variable velocity with a computer model

Let's write a script that approximates the graphic procedure that I described above.

Copy the code from Listing 2 into an html file and open the file in your browser.

5
Listing 2: Variable velocity exercise #2.

<!---------------- File JavaScript2.html --------------------->
<html><body>
<script language="JavaScript1.3">

document.write("Start Script <br/>");

//Declare and initialize constants
var g = -32.2;//acceleration of gravity in ft/sec/sec
var v0 = 100;//initial velocity in ft/sec
var h0 = 6;//initial height in feet
var tInc = 0.25;//calculation interval in seconds

//Declare and initialize working variables
var t = .0001;//current time in seconds
var h = h0;//current height in feet
var v = 0;//current velocity in feet/sec

var oldT = 0;//previous time in seconds
var delT = 0;//change in time in seconds

var oldH = h0;//previous height in feet
var delH = 0;//change in height in feet

//The following variable is used to insert spaces in
// the output display.
var sp = "&nbsp;&nbsp;&nbsp;&nbsp;"

//Compute and display various values for as long as the
// height of the projectile is above the ground.
while(h > 0){
  //This is the general equation for the height of a
  // projectile under the influence of gravity in a
  // vacuum.
  h = h0 + v0*t +0.5*g*t*t;

  //Compute and save the time interval since the
  // previous estimate of height, etc.
  delT = t-oldT;
  oldT = t;//Save the current time for the next iteration

  //Estimate the velocity based on the change in
  // height since the previous estimate.
  delH = h-oldH;
  v = delH/delT;//compute velocity
  oldH = h;//Save the current height for the next iteration.

  //Display the information for this iteration
  document.write(
      "t = " + t.toFixed(2) + " seconds" + sp +
      " h = " + h.toFixed(1) + " feet" + sp +
      " v = " + v.toFixed(2) + " feet/second" + sp +
      "<br/>");

  //Increment the time for the next iteration.
  t = t + tInc;
}//end while loop

document.write("End Script");

</script>
</body></html>

Screen output

The text shown in Image 4 should appear in your browser window when the html file opens in your browser.

6
Image 4: Screen output for Listing #2.
Start Script
t = 0.00 seconds     h = 6.0 feet     v = 100.00 feet/second    
t = 0.25 seconds     h = 30.0 feet     v = 95.97 feet/second    
t = 0.50 seconds     h = 52.0 feet     v = 87.92 feet/second    
t = 0.75 seconds     h = 72.0 feet     v = 79.87 feet/second    
t = 1.00 seconds     h = 89.9 feet     v = 71.82 feet/second    
t = 1.25 seconds     h = 105.8 feet     v = 63.77 feet/second    
t = 1.50 seconds     h = 119.8 feet     v = 55.72 feet/second    
t = 1.75 seconds     h = 131.7 feet     v = 47.67 feet/second    
t = 2.00 seconds     h = 141.6 feet     v = 39.62 feet/second    
t = 2.25 seconds     h = 149.5 feet     v = 31.57 feet/second    
t = 2.50 seconds     h = 155.4 feet     v = 23.52 feet/second    
t = 2.75 seconds     h = 159.2 feet     v = 15.47 feet/second    
t = 3.00 seconds     h = 161.1 feet     v = 7.42 feet/second    
t = 3.25 seconds     h = 160.9 feet     v = -0.63 feet/second    
t = 3.50 seconds     h = 158.8 feet     v = -8.68 feet/second    
t = 3.75 seconds     h = 154.6 feet     v = -16.73 feet/second    
t = 4.00 seconds     h = 148.4 feet     v = -24.78 feet/second    
t = 4.25 seconds     h = 140.2 feet     v = -32.83 feet/second    
t = 4.50 seconds     h = 130.0 feet     v = -40.88 feet/second    
t = 4.75 seconds     h = 117.7 feet     v = -48.93 feet/second    
t = 5.00 seconds     h = 103.5 feet     v = -56.98 feet/second    
t = 5.25 seconds     h = 87.2 feet     v = -65.03 feet/second    
t = 5.50 seconds     h = 69.0 feet     v = -73.08 feet/second    
t = 5.75 seconds     h = 48.7 feet     v = -81.13 feet/second    
t = 6.00 seconds     h = 26.4 feet     v = -89.18 feet/second    
t = 6.25 seconds     h = 2.1 feet     v = -97.23 feet/second    
t = 6.50 seconds     h = -24.2 feet     v = -105.28 feet/second    
End Script 

A graphical representation of velocity

The velocity values shown in Image 4 are plotted in Image 1 along with the height values and the acceleration values, which will be computed shortly..

Analysis of the results

The difference between Image 2 and Image 4 is the addition of a column of velocity information on the right in Image 4 . As you can see, the velocity begins with a positive value of 100 feet/second at the top of the velocity column.

The velocity goes to zero somewhere between 3 and 3.25 seconds, which is the point where the height of the arrow reaches its maximum.

At 3.25 seconds, the velocity switches from positive to negative meaning that the arrow begins falling back toward the earth. The velocity reaches -100 feet/second somewhere between 6.25 and 6.5 seconds, which is about the same time that the arrow hits the ground.

Hopefully you have recognized that the velocity curve for this particular situation is a straight line with a negative slope. That straight line crosses the horizontal axis going from positive territory into negative territory about half way between the original release of the arrow and the point where the arrow strikes the ground.

Analysis of the code

A comparison of Listing 2 with Listing 1 shows the addition of the following variables:

  • var oldT = 0; //previous time in seconds
  • var delT = 0; //change in time in seconds
  • var oldH = h0; //previous height in feet
  • var delH = 0; //change in height in feet

Save values for use in next iteration

As you will see when I get into an explanation of the while loop, the variables oldT and oldH are used to save the time value and the height value during each iteration to make those values available during the next iteration.

Compute changes in time and height

Inside the while loop, the current value of t and the value stored in oldT are used to compute the change in time since the previous iteration. The current value of h and the value stored in oldH are used to compute the change in height since the previous iteration. These change values are saved in the variables named delT and delH .

Velocity is the ratio of the changes

In this case, the value in delH represents the displacement of the arrow during the time interval and the value stored in delT represents the length of the time interval. As you already know, the velocity is the ratio of those two values. The value for velocity is computed along with the time and the height and then the script executes the next iteration of the while loop.

The while loop

The while loop in Listing 2 begins the same as in Listing 1 . After the new height value is computed, the script performs the computations described above to estimate and display the velocity for the time interval since the previous iteration.

In addition, the script saves the current values of t and h in oldT and oldH to be used to estimate the velocity during the next iteration of the while loop.

Finally, the time value is increased by the value stored in the variable named tInc , and control goes back to the top of the loop where the current value of height is tested to determine if it has become negative (meaning that the arrow has hit the ground).

Acceleration of gravity exercise #1

To repeat the earlier definition, acceleration is the rate of change of velocity.

You learned earlier that velocity is the rate of change of position. Then you learned that we can estimate the velocity of a moving object at a point in time by determining the slope of a curve that plots the position of the object versus time at that particular point in time.

Positive and negative velocity

Positive slopes indicate positive velocity and negative slopes indicate negative velocity. In the case of our arrow, the velocity went to zero and switched from positive to negative at the point where the arrow reached its maximum height and began to fall back toward the earth. In a math class, that point would likely be referred to as an inflection point on the curve of position versus time.

Estimating acceleration

We can extend that procedure to estimate the acceleration of a moving object at a point in time by determining the slope of a curve that plots the velocity of the object versus time at that particular point in time. Positive slopes indicate positive acceleration and negative slopes indicate negative acceleration.

Estimate some velocity values graphically

If you have the velocity curve from Image 4 plotted on your graph, I recommend that you estimate and record the slope and hence the acceleration at a few points. That should be easy to do in this case, because the velocity curve should be a straight line with a negative slope.

A constant acceleration value

If the velocity curve is a straight line with a negative slope, and if the acceleration at any point in time is equal to the slope of the velocity curve, that means that the acceleration has a constant negative value throughout the time interval of interest. In fact, you should find that the value of the acceleration is approximately -32.2 feet/second^2, which is known as the acceleration of gravity .

Create a script

Copy the code from Listing 3 into an html file and open that file in your browser.

7
Listing 3: Acceleration of gravity exercise #1.
<!---------------- File JavaScript99.html --------------------->
<html><body>
<script language="JavaScript1.3">

document.write("Start Script <br/>");

//Declare and initialize constants
var g = -32.2;//acceleration of gravity in ft/(sec*sec)
var v0 = 100;//initial velocity in ft/sec
var h0 = 6;//initial height in feet
var tInc = 0.25;//calculation interval in seconds

//Declare and initialize working variables
var t = .0001;//current time in seconds
var h = h0;//current height in feet
var v = 0;//current velocity in feet/sec
var a = 0;//current acceleration in feet/(sec*sec)

var oldT = 0;//previous time in seconds
var delT = 0;//change in time in seconds

var oldH = h0;//previous height in feet
var delH = 0;//change in height in feet

var oldV = 0;//previous velocity in feet/sec
var delV = 0;//change in velocity in feet/sec

//The following variable is used to insert spaces in
// the output display.
var sp = "&nbsp;&nbsp;";

//Compute and display various values for as long as the
// height of the projectile is above the ground.
while(h > 0){
  //This is the general equation for the height of a
  // projectile under the influence of gravity in a
  // vacuum.
  h = h0 + v0*t +0.5*g*t*t;

  //Compute and save the time interval since the
  // previous estimate of height, etc.
  delT = t-oldT;
  oldT = t;//Save the current time for the next iteration.

  //Estimate the velocity based on the change in
  // height since the previous estimate.
  delH = h-oldH;
  v = delH/delT;//compute velocity
  oldH = h;//Save the current height for the next iteration.

  //Estimate the acceleration based on the change in
  // velocity once the data pipeline is full.
  delV = v - oldV;
  oldV = v;//Save the current velocity for the next iteration.
  if(t > 2*tInc){
    a = delV/delT;//compute acceleration
  }//end if

  //Display the information for this iteration
  document.write(
      "t = " + t.toFixed(2) + " sec" + sp +
      " h = " + h.toFixed(0) + " ft" + sp +
      " v = " + v.toFixed(2) + " ft/sec" + sp +
      " a = " + a.toFixed(2) + " ft/(sec*sec)" +
      "<br/>");

  //Increment the time for the next iteration.
  t = t + tInc;
}//end while loop

document.write("End Script");

</script>
</body></html>

Screen output

The text shown in Image 5 should appear in your browser window when the html file is opened in your browser.

8
Image 5: Screen output for Listing #3.
Start Script
t = 0.00 sec   h = 6 ft   v = 100.00 ft/sec   a = 0.00 ft/(sec*sec)
t = 0.25 sec   h = 30 ft   v = 95.97 ft/sec   a = 0.00 ft/(sec*sec)
t = 0.50 sec   h = 52 ft   v = 87.92 ft/sec   a = -32.20 ft/(sec*sec)
t = 0.75 sec   h = 72 ft   v = 79.87 ft/sec   a = -32.20 ft/(sec*sec)
t = 1.00 sec   h = 90 ft   v = 71.82 ft/sec   a = -32.20 ft/(sec*sec)
t = 1.25 sec   h = 106 ft   v = 63.77 ft/sec   a = -32.20 ft/(sec*sec)
t = 1.50 sec   h = 120 ft   v = 55.72 ft/sec   a = -32.20 ft/(sec*sec)
t = 1.75 sec   h = 132 ft   v = 47.67 ft/sec   a = -32.20 ft/(sec*sec)
t = 2.00 sec   h = 142 ft   v = 39.62 ft/sec   a = -32.20 ft/(sec*sec)
t = 2.25 sec   h = 149 ft   v = 31.57 ft/sec   a = -32.20 ft/(sec*sec)
t = 2.50 sec   h = 155 ft   v = 23.52 ft/sec   a = -32.20 ft/(sec*sec)
t = 2.75 sec   h = 159 ft   v = 15.47 ft/sec   a = -32.20 ft/(sec*sec)
t = 3.00 sec   h = 161 ft   v = 7.42 ft/sec   a = -32.20 ft/(sec*sec)
t = 3.25 sec   h = 161 ft   v = -0.63 ft/sec   a = -32.20 ft/(sec*sec)
t = 3.50 sec   h = 159 ft   v = -8.68 ft/sec   a = -32.20 ft/(sec*sec)
t = 3.75 sec   h = 155 ft   v = -16.73 ft/sec   a = -32.20 ft/(sec*sec)
t = 4.00 sec   h = 148 ft   v = -24.78 ft/sec   a = -32.20 ft/(sec*sec)
t = 4.25 sec   h = 140 ft   v = -32.83 ft/sec   a = -32.20 ft/(sec*sec)
t = 4.50 sec   h = 130 ft   v = -40.88 ft/sec   a = -32.20 ft/(sec*sec)
t = 4.75 sec   h = 118 ft   v = -48.93 ft/sec   a = -32.20 ft/(sec*sec)
t = 5.00 sec   h = 103 ft   v = -56.98 ft/sec   a = -32.20 ft/(sec*sec)
t = 5.25 sec   h = 87 ft   v = -65.03 ft/sec   a = -32.20 ft/(sec*sec)
t = 5.50 sec   h = 69 ft   v = -73.08 ft/sec   a = -32.20 ft/(sec*sec)
t = 5.75 sec   h = 49 ft   v = -81.13 ft/sec   a = -32.20 ft/(sec*sec)
t = 6.00 sec   h = 26 ft   v = -89.18 ft/sec   a = -32.20 ft/(sec*sec)
t = 6.25 sec   h = 2 ft   v = -97.23 ft/sec   a = -32.20 ft/(sec*sec)
t = 6.50 sec   h = -24 ft   v = -105.28 ft/sec   a = -32.20 ft/(sec*sec)
End Script 

A graphical representation of acceleration

The acceleration values shown in Image 5 are plotted in Image 1 along with the height values and the velocity values.

Analysis of the results

The main difference between Image 5 and Image 4 is the addition of an acceleration column on the right in Image 5 . (In addition, I abbreviated feet and seconds as ft and sec, and reduced the space between columns to make it all fit in the available space.)

Except for the first two values at the top of the acceleration column, every acceleration value is -32.2 ft/(sec*sec). This is what we predicted earlier when we observed that the velocity curve is a straight line with a constant negative slope. (Note that the procedure used to estimate the acceleration did not allow for an accurate estimate of acceleration for the first two values in the acceleration column.)

Free fall

According to Wikipedia , free fall is any motion of a body where gravity is the only force acting upon it.

Since this definition does not specify velocity, it also applies to objects initially moving upward (which is the case with our arrow that was shot upward).

Free fall was demonstrated on the moon by astronaut David Scott on August 2, 1971. He simultaneously released a hammer and a feather from the same height above the moon's surface. The hammer and the feather both fell at the same rate and hit the ground at the same time. This demonstrated Galileo's discovery that in the absence of air resistance, all objects experience the same acceleration due to gravity.

By the way, it is no accident that the value shown for acceleration in Image 4 matches the value specified for the acceleration of gravity near the beginning of the code in Listing 3 .

Analysis of the code

The code in Listing 3 is very similar to the code in Listing 2 with the addition of the code necessary to estimate the acceleration values on the basis of the slope of the velocity curve.

The code that estimates the acceleration in Listing 3 is so similar to the code that estimates the velocity in Listing 2 that I won't bore you by explaining the code in detail.

However, there is one bit of new code that is worthy of note. Without going into detail as to the reasons why, this procedure is incapable of accurately estimating the slope of the velocity curve during the first two time intervals. Therefore, an if statement was written into the while loop to force the acceleration estimate to be zero for the first two time intervals.

Acceleration of gravity exercise #2

In the previous exercises, the arrow was shot straight up in the air. However, that is rarely the case. Normally, an arrow is shot in an attempt to strike a target some horizontal distance away.

A more realistic scenario

Let's modify our scenario such that the archer shoots the arrow with an initial velocity of 100 feet per second at an angle of 45 degrees relative to the horizontal axis. We will compute and plot the horizontal and vertical position of the arrow at uniform increments in time from the beginning to the end of its trajectory.

Motion of a projectile with uniform acceleration

The following equation describes the straight-line motion of a projectile with uniform acceleration .

d = v0*t +0.5*a*t^2

where

  • d is distance in units of distance
  • v0 is the initial velocity in units of distance/time
  • t is time in units of time
  • a is acceleration in units of distance/time^2

As usual, the units for distance, time, velocity, and acceleration must be consistent with one another.

Shooting the arrow straight up

If we shoot an arrow straight up, as was the case in the previous exercises, the initial velocity doesn't have a horizontal component. Instead, the initial velocity has only a vertical component and the corresponding motion of the arrow has only a vertical component. In other words, the arrow goes straight up and it comes down in the same spot.

Shooting the arrow other than straight up

However, if we shoot the arrow in a direction other than straight up or straight down, the initial velocity has both a vertical component and a horizontal component. Therefore, the resulting motion has both a vertical component and a horizontal component.

To determine the position of the arrow at some time after it is released, we must determine both the vertical and the horizontal component of its motion.

Compute vertical and horizontal components independently

The equation given above can be used to compute the vertical and horizontal components of motion independently of one another. This approach can be used to give us the position as a function of time along each axis. We can then use that information to determine and plot the position of the arrow in x-y space at one or more points in time.

Vertical and horizontal motion components are independent

It is important to understand that the vertical and horizontal components of motion are independent of one another. In other words, changing the vertical component of motion doesn't effect the horizontal motion and changing the horizontal component of motion doesn't effect the vertical motion. The overall motion seen by an observer is the superposition of the two.

Create a script

Please copy the code shown in Listing 4 into an html file and open the file in your browser.

9
Listing 4: Acceleration of gravity exercise #2.
<!---------------- File JavaScript04.html --------------------->
<html><body>
<script language="JavaScript1.3">

document.write("Start Script <br/>");

//Define common parameters
var ang = 45;//firing angle degrees re the horizontal
var tInc = 0.25;//calculation interval in seconds
var v0 = 100;//initial velocity in ft/sec

//Define horizontal parameters
var ax = 0;//horizontal acceleration
var vx0 = v0*Math.cos(
  ang*Math.PI/180);//component of initial velocity in ft/sec
var x0 = 0;//initial x-offset in feet

//Define vertical parameters
var ay = -32.2;//vertical acceleration in ft/sec*sec
var vy0 = v0*Math.sin(
  ang*Math.PI/180);//component of initial velocity in ft/sec
var y0 = 6;//initial height in feet

//Declare and initialize working variables
var t = .0001;//current time in seconds
var x = x0;//current x in feet
var y = y0;//current height in feet

//The following variable is used to insert spaces in
// the output display.
var sp = "&nbsp;&nbsp;&nbsp;&nbsp;"

//Compute and display the horizontal and vertical
// positions of the projectile at uniform increments
// of time
while(y > 0){
  //These are the general equations for the straight-
  // line motion of a projectile under the influence
  // of uniform acceleration in a vacuum.
  y = y0 + vy0*t + 0.5*ay*t*t;
  x = x0 + vx0*t + 0.5*ax*t*t;

  //Display the information for this iteration
  document.write(
      "t = " + t.toFixed(2) + " seconds" + sp +
      " x = " + x.toFixed(1) + " feet" + sp +
      " y = " + y.toFixed(1) + " feet" + sp +
      "<br/>");

  //Increment the time for the next iteration.
  t = t + tInc;
}//end while loop

document.write("End Script");

</script>
</body></html>

Screen output

The text shown in Image 6 should appear in your browser when you open the html file in your browser.

10
Image 6: Screen output for Listing #4 at 45 degrees.
Start Script
t = 0.00 seconds     x = 0.0 feet     y = 6.0 feet    
t = 0.25 seconds     x = 17.7 feet     y = 22.7 feet    
t = 0.50 seconds     x = 35.4 feet     y = 37.3 feet    
t = 0.75 seconds     x = 53.0 feet     y = 50.0 feet    
t = 1.00 seconds     x = 70.7 feet     y = 60.6 feet    
t = 1.25 seconds     x = 88.4 feet     y = 69.2 feet    
t = 1.50 seconds     x = 106.1 feet     y = 75.8 feet    
t = 1.75 seconds     x = 123.8 feet     y = 80.4 feet    
t = 2.00 seconds     x = 141.4 feet     y = 83.0 feet    
t = 2.25 seconds     x = 159.1 feet     y = 83.6 feet    
t = 2.50 seconds     x = 176.8 feet     y = 82.2 feet    
t = 2.75 seconds     x = 194.5 feet     y = 78.7 feet    
t = 3.00 seconds     x = 212.1 feet     y = 73.2 feet    
t = 3.25 seconds     x = 229.8 feet     y = 65.8 feet    
t = 3.50 seconds     x = 247.5 feet     y = 56.3 feet    
t = 3.75 seconds     x = 265.2 feet     y = 44.8 feet    
t = 4.00 seconds     x = 282.8 feet     y = 31.2 feet    
t = 4.25 seconds     x = 300.5 feet     y = 15.7 feet    
t = 4.50 seconds     x = 318.2 feet     y = -1.8 feet    
End Script 

A graphical representation of the trajectory

Image 7 shows the trajectory of the arrow for firing angles of 45 degrees and 60 degrees. The vertical axis shows the height in feet and the horizontal axis shows the flight distance in feet.

11
Image 7: Trajectory for two different firing angles.
Missing image

Analysis of the output

Image 6 shows the x and y coordinates of the arrow's position every 0.25 seconds from the time that it is released until it strikes the ground a little less than 4.5 seconds later. This is the data for the case where the firing angle was 45 degrees.

Compute for a different angle

Next, I recommend that you modify the script by changing the value of the variable named ang from 45 degrees to 60 degrees and load the modified version of the html file into your browser. This should produce the output shown in Image 8 . This output is also plotted in Image 7 .

Which arrow went higher?

Which arrow went further along the horizontal axis?

12
Image 8: Screen output for Listing #4 at 60 degrees.
Start Script
t = 0.00 seconds     x = 0.0 feet     y = 6.0 feet    
t = 0.25 seconds     x = 12.5 feet     y = 26.7 feet    
t = 0.50 seconds     x = 25.0 feet     y = 45.3 feet    
t = 0.75 seconds     x = 37.5 feet     y = 61.9 feet    
t = 1.00 seconds     x = 50.0 feet     y = 76.5 feet    
t = 1.25 seconds     x = 62.5 feet     y = 89.1 feet    
t = 1.50 seconds     x = 75.0 feet     y = 99.7 feet    
t = 1.75 seconds     x = 87.5 feet     y = 108.3 feet    
t = 2.00 seconds     x = 100.0 feet     y = 114.8 feet    
t = 2.25 seconds     x = 112.5 feet     y = 119.4 feet    
t = 2.50 seconds     x = 125.0 feet     y = 121.9 feet    
t = 2.75 seconds     x = 137.5 feet     y = 122.4 feet    
t = 3.00 seconds     x = 150.0 feet     y = 120.9 feet    
t = 3.25 seconds     x = 162.5 feet     y = 117.4 feet    
t = 3.50 seconds     x = 175.0 feet     y = 111.9 feet    
t = 3.75 seconds     x = 187.5 feet     y = 104.3 feet    
t = 4.00 seconds     x = 200.0 feet     y = 94.8 feet    
t = 4.25 seconds     x = 212.5 feet     y = 83.2 feet    
t = 4.50 seconds     x = 225.0 feet     y = 69.7 feet    
t = 4.75 seconds     x = 237.5 feet     y = 54.1 feet    
t = 5.00 seconds     x = 250.0 feet     y = 36.5 feet    
t = 5.25 seconds     x = 262.5 feet     y = 16.9 feet    
t = 5.50 seconds     x = 275.0 feet     y = -4.7 feet    
End Script 

Perhaps you could do the same thing for some other launch angles and determine which launch angle provides the greatest horizontal range and which launch angle provides the greatest vertical height.

For example, how far does the arrow fly when launched at an angle of 0 degrees from a height of 6 feet?

Analysis of the code

The code in this script treats the horizontal and vertical components of motion independently and uses the equation given above to determine the position along that axis as a function of time every 0.25 seconds.

Common parameter values

The code in Listing 4 begins by defining common parameter values for the firing angle, the time increment at which coordinate values will be computed and displayed, and the initial velocity of the arrow in the firing direction.

Horizontal and vertical parameters

Following that, the code in Listing 4 defines horizontal parameters and vertical parameters that will be used to compute the horizontal and vertical components of motion respectively.

Horizontal acceleration

The horizontal acceleration is set to zero. In the absence of air resistance, there is nothing to cause the horizontal component of the arrow to speed up or slow down until it stops suddenly when it hits the ground.

Vertical acceleration

The vertical acceleration is set to the acceleration of gravity at the surface of the earth, which is the same value used for the previous exercises in this module.

Decompose the initial velocity

The cosine and sine functions are used to decompose the initial velocity into horizontal and vertical components of velocity.

Initial horizontal and vertical positions

Finally, the horizontal position when the arrow is released is set to 0 and the vertical position is set to 6 feet, approximately the height of the release point for an archer that is six feet tall.

Working variables

After defining the horizontal and vertical parameters, the code in Listing 4 declares working variables for time, horizontal position (x), and vertical position (y).

A while loop

A while loop is used to iterate for as long as the arrow is above the ground.

During each iteration, the equation given above is evaluated twice, once to determine the height of the arrow and once to determine the horizontal position of the arrow at the current time.

Time starts at 0, and increments by +0.25 seconds during each iteration.

The document.write method is called inside the while loop to display the results shown in Image 6 .

Acceleration of gravity exercise #3

A quadratic equation

Now let's turn things around and approach the problem from a different viewpoint. If we subtract d from both sides of the motion equation given above , replace a by g to avoid confusion later, and then rearrange the terms, we get the following equation :

0.5*g*t^2+v0*t-d = 0

where

  • d is distance in units of distance
  • v0 is the initial velocity in units of distance/time
  • t is time in units of time
  • g is acceleration in units of distance/time^2

In this form, you may recognize this as a standard quadratic equation which is often written as

a*t^2 + b*t + c = 0

(Now you know why I replaced the acceleration term a by the acceleration term g earlier. I need to use the symbol a in the standard quadratic equation.)

Standard solution for a quadratic equation

Given values for a, b, and c, you should know that the solution for determining the values for t is to find the roots of the equation.

There are two roots (hence two values for t). You should also know that the two roots can be found by evaluating the quadratic formula in two forms.

t1 = (-b+Math.sqrt(b*b-4*a*c))/(2*a);

t2 = (-b-Math.sqrt(b*b-4*a*c))/(2*a);

Using the solution

Relating the coefficients in the standard motion equation to the coefficients in the standard quadratic equation gives us:

  • a = 0.5*g
  • b = v0
  • c = -d

The scenario

Let's use the scenario posed in the first exercise in this module. In this scenario, an archer that is six feet tall shoots an arrow directly upward with a velocity of 100 feet per second. Assume that the arrow is at a height of 6 feet when it leaves the bow. Also ignore the effects of air resistance.

Referring back to Image 1...

We learned from the table in Image 2 that the arrow was at a height of 89.9 feet at 1 second on the way up from the surface of the earth, and was at a height of 89.9 feet again on the way down at approximately 5.2 seconds.

Let's pretend that we don't have the table in Image 1 and write a script that uses the quadratic form of the standard motion equation along with the quadratic formula to compute the times that the arrow was at a height of 89.9 feet.

Do it also for the moon

To make the problem even more interesting, let's also cause the script to compute and display the times that the arrow was at a height of 89.9 feet assuming that the archer was standing on the surface of the moon instead of the earth.

An issue involving the initial height

The standard motion equation can be used to compute the time that the arrow has traveled to any specific height, relative to the height from which it was released. Therefore, since the arrow was released from a height of 6 feet and it initially traveled up, we need to determine the time at which it had traveled 83.9 feet to find the time that it was actually at 89.9 feet.

The JavaScript code

Please copy the code from Listing 5 into an html file and open the file in your browser.

13
Listing 5: Acceleration of gravity exercise #3.
<!---------------- File JavaScript05.html --------------------->
<html><body>
<script language="JavaScript1.3">

document.write("Start Script <br/><br/>");

//The purpose of the getRoots function is to compute and
// return the roots of a quadratic equation expressed in
// the format
//   a*x^2 + b*x + c = 0
//The roots are returned in the elements of a two-element
// array. If the roots are imaginary, the function
// returns NaN for the value of each root.
function getRoots(a,b,c){
  var roots = new Array(2);
  roots[0] = (-b+Math.sqrt(b*b-4*a*c))/(2*a);
  roots[1] = (-b-Math.sqrt(b*b-4*a*c))/(2*a);
  return roots;
}//end getRoots

//Initialize the problem parameters.
var gE = -32.2;//gravity in ft/sec*sec on Earth
var gM = -32.2*0.167;//gravity in ft/sec*sec on the Moon
var v0 = 100;//initial velocity in ft/sec
var d0 = 6;//initial height in feet
var d = 89.9-d0;//target height corrected for initial height

//Equate problem parameters to coefficients in a
// standard quadratic equation.
var a = 0.5*gE;
var b = v0;
var c = -d;

//Solve the quadratic formula for the two times at which the
// height matches the target height corrected for the
// initial height.
var roots = getRoots(a,b,c);

//Extract the two time values from the array.
var t1 = roots[0];//time in seconds
var t2 = roots[1];//time in seconds

//Display the results for the earth.
document.write("On Earth <br/>");
document.write("Arrow is at " + (d+d0) + " feet at " +
               t1.toFixed(2) + " seconds" + "<br/>");
document.write("Arrow is at " + (d+d0) + " feet at " +
               t2.toFixed(2) + " seconds" + "<br/><br/>");

//Compute and display for the moon
//Adjust the value of a to represent the acceleration
// of gravity on the moon
a = 0.5*gM;

//Solve the quadratic formula for the two times at which the
// height matches the target height corrected for the
// initial height.
roots = getRoots(a,b,c);

//Extract the two time values from the array.
var t1 = roots[0];//time in seconds
var t2 = roots[1];//time in seconds

//Display the results.
document.write("On the Moon <br/>");
document.write("Arrow is at " + (d+d0) + " feet at " +
               t1.toFixed(2) + " seconds" + "<br/>");
document.write("Arrow is at " + (d+d0) + " feet at " +
               t2.toFixed(2) + " seconds" + "<br/><br/>");

document.write("End Script");

</script>
</body></html>

Screen output

The text shown in Image 9 should appear in the browser window when you open the html file in the browser.

14
Image 9: Screen output for Listing #5.
Start Script

On Earth
Arrow is at 89.9 feet at 1.00 seconds
Arrow is at 89.9 feet at 5.21 seconds

On the Moon
Arrow is at 89.9 feet at 0.86 seconds
Arrow is at 89.9 feet at 36.33 seconds

End Script 

A function named getRoots

The quadratic formula isn't very complicated, but it is fairly tedious and easy to type incorrectly. Therefore, I decided to encapsulate it in a function that we can copy into future scripts saving us the need to type it correctly in the future.

Listing 5 begins with the definition of a function named getRoots that receives the parameters a, b, and c, and returns the roots of the quadratic equation in a two-element array.

Real or imaginary roots

The roots of a quadratic equation can be either real or imaginary. If the roots are imaginary, this function simply returns NaN (not a number) for each root.

The parameters of the problem

Following the definition of the getRoots function, Listing 5 declares and initializes several variables to establish the parameters of the problem, such as the acceleration of gravity on the earth and moon, the initial velocity of the arrow, etc.

The computed height versus the target height

The target height for the problem is 89.9 feet. Note that the variable named d contains that value less the initial height of 6 feet. Thus, the script will find the time at which the arrow has traveled 83.9 feet on the way up, and the time that it has traveled that same distance on the way back down.

Establish quadratic coefficients

The next three lines of code use the problem parameters to establish values for the standard coefficients of a quadratic equation, a, b, and c, as described above . Note that at this point in the script, the coefficient named a is based on the acceleration of gravity on earth. (Later, it will be changed to reflect the acceleration of gravity on the moon.)

Get the roots of the quadratic equation

Then the script calls the getRoots function, passing a, b, and c as parameters, and stores the returned array containing the roots in the variable named roots .

Following that, the script extracts the roots from the array and displays them as shown by the text in the upper half of Image 9 .

Repeat the process for the moon

Then Listing 5 sets the value of the coefficient named a to reflect the acceleration of gravity on the moon, repeats the process, and displays the results in the lower half of Image 9 .

Note that the arrow reaches the target height somewhat quicker on the moon due to the lower acceleration of gravity, and takes much longer to arrive at the same height on the way back down to the surface of the moon. Were we to create a chart similar to Image 2 for the moon, we would see that the arrow goes much higher before turning around and falling back to the surface of the moon.

Other useful equations

You have learned how to use the following equation to solve various physics problems involving motion in a straight line with uniform acceleration so far in this module.

h = v0*t + 0.5*g*t^2

where

  • h is the distance of the projectile above the surface of the earth in units of distance
  • v0 is the initial velocity of the projectile in units of distance/time
  • t is time in seconds
  • g is the acceleration of gravity, approximately 9.8 meters per second squared, or approximately 32.2 feet per second squared.

Some physics textbooks also list the following equations as being important .

v = v0 + g*t

v^2 = v0^2 + 2*g*h

where v is the velocity of the object and the other terms are the same as described above .

Exercise to find the velocity

Let's do an exercise using the first of the two equations given above .

An individual on the surface of the earth shoots an arrow directly upward with a velocity of 100 feet per second. How many seconds elapse before the arrow turns and starts falling towards the surface of the earth. Ignore the effects of air resistance.

Create a script

Please copy the code from Listing 6 into an html file and open the file in your browser.

15
Listing 6: Exercise to find the velocity.
<!---------------- File JavaScript06.html --------------------->
<html><body>
<script language="JavaScript1.3">

document.write("Start Script <br/><br/>");

//Initialize the problem parameters.
var g = -32.2;//gravity in ft/sec*sec on Earth
var v0 = 100;//initial velocity in ft/sec

//Given that v = v0 + g * t
//At what time does the velocity go to zero?

//Rearrange the terms in the equation.
var t = -v0/g;

//Display the results
document.write("Arrow has zero velocity at " +
               t.toFixed(2) + " seconds " + "<br/>");

document.write("<br/>End Script");

</script>
</body></html>

Screen output

The text shown in Image 10 should appear in your browser window when you open the html file in your browser.

16
Image 10: Screen output for Listing #6.
Start Script

Arrow has zero velocity at 3.11 seconds

End Script 

Analysis of the code

Compared to working through the solutions to the previous exercises, this one seems almost trivial.

After establishing values for the acceleration of gravity and the initial velocity of the arrow, the code in Listing 6 rearranges the first equation given above and solves for the value of time at which the velocity goes to zero. This is the point in time when the arrow turns from moving up and begins falling back toward the earth.

The results are shown in Image 10 . You should compare this result with Image 1 , which shows that the arrow reaches its maximum height at approximately 3 seconds, which agrees very well with the result shown in Image 10 .

Exercise to find the height

Let's do an exercise using the second of the two equations given above .

An individual that is six feet tall standing on the surface of the earth shoots an arrow directly upward with a velocity of 100 feet per second. What is the maximum height achieved by the arrow before it turns and falls back towards the surface of the earth? Ignore the effects of air resistance.

Create a script

Please copy the code from Listing 7 into an html file and open the file in your browser.

17
Listing 7: Exercise to find the height.
<!---------------- File JavaScript07.html --------------------->
<html><body>
<script language="JavaScript1.3">

document.write("Start Script <br/><br/>");

//Initialize the problem parameters.
var g = -32.2;//gravity in ft/sec*sec on Earth
var v0 = 100;//initial velocity in ft/sec
var h0 = 6;//initial height

//Given that v^2 = v0^2 + 2*g*h
//What is the maximum height reached by the arrow?
//Note that the maximum height is six feet more than
// the value given by the above equation because that
// equation is based on the point of release.

//The maximum height occurs when the velocity goes to zero.
//Setting the velocity to zero and rearranging the terms
// in the equation gives:
var h = h0 + (-(v0 * v0))/(2*g);

//Display the results
document.write("Arrow reaches maximum height of " +
               h.toFixed(2) + " feet " + "<br/>");

document.write("<br/>End Script");

</script>
</body></html>

Screen output

The text shown in Image 11 should appear in your browser window when the html file is opened in your browser.

18
Image 11: Screen output for Listing #7.
Start Script

Arrow reaches maximum height of 161.28 feet

End Script 

Analysis of the code

Once again, compared to working through the previous exercises, this one also seems almost trivial.

After establishing values for the acceleration of gravity, the initial velocity of the arrow, and the height at which the arrow was released, the code in Listing 7 rearranges the second equation given above and solves for the value of the height (relative to the release point) at which the velocity goes to zero. This is the point in the trajectory where the arrow turns from moving up and begins falling back toward the earth.

Note that in order to get the actual height, it was necessary to add the initial height of 6 feet to the computed height.

Compare the results

The results are shown in Image 11 . You should compare this result with Image 2 , which shows that the arrow reaches its maximum height at approximately 161.1 feet, which agrees very well with the result shown in Image 11 .

Run the scripts

I encourage you to run the scripts that I have presented in this lesson to confirm that you get the same results. Copy the code for each script into a text file with an extension of html. Then open that file in your browser. Experiment with the code, making changes, and observing the results of your changes. Make certain that you can explain why your changes behave as they do.

Miscellaneous

This section contains a variety of miscellaneous information.

Note:

Housekeeping material
  • Module name: GAME 2302 Motion -- Variable Velocity and Acceleration
  • File: Game0380.htm
  • Published: 10/13/12
  • Revised: 12/31/12

Note:

Disclaimers:

Financial : Although the Connexions site makes it possible for you to download a PDF file for this module at no charge, and also makes it possible for you to purchase a pre-printed version of the PDF file, you should be aware that some of the HTML elements in this module may not translate well into PDF.

I also want you to know that, I receive no financial compensation from the Connexions website even if you purchase the PDF version of the module.

In the past, unknown individuals have copied my modules from cnx.org, converted them to Kindle books, and placed them for sale on Amazon.com showing me as the author. I neither receive compensation for those sales nor do I know who does receive compensation. If you purchase such a book, please be aware that it is a copy of a module that is freely available on cnx.org and that it was made and published without my prior knowledge.

Affiliation : I am a professor of Computer Information Technology at Austin Community College in Austin, TX.

-end-

Collection Navigation

Content actions

Download:

Collection as:

PDF | EPUB (?)

What is an EPUB file?

EPUB is an electronic book format that can be read on a variety of mobile devices.

Downloading to a reading device

For detailed instructions on how to download this content's EPUB to your specific device, click the "(?)" link.

| More downloads ...

Module as:

PDF | EPUB (?)

What is an EPUB file?

EPUB is an electronic book format that can be read on a variety of mobile devices.

Downloading to a reading device

For detailed instructions on how to download this content's EPUB to your specific device, click the "(?)" link.

| More downloads ...

Add:

Collection to:

My Favorites (?)

'My Favorites' is a special kind of lens which you can use to bookmark modules and collections. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need an account to use 'My Favorites'.

| A lens I own (?)

Definition of a lens

Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual member, a community, or a respected organization.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

| External bookmarks

Module to:

My Favorites (?)

'My Favorites' is a special kind of lens which you can use to bookmark modules and collections. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need an account to use 'My Favorites'.

| A lens I own (?)

Definition of a lens

Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual member, a community, or a respected organization.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

| External bookmarks

Reuse / Edit:

Reuse or edit collection (?)

Check out and edit

If you have permission to edit this content, using the "Reuse / Edit" action will allow you to check the content out into your Personal Workspace or a shared Workgroup and then make your edits.

Derive a copy

If you don't have permission to edit the content, you can still use "Reuse / Edit" to adapt the content by creating a derived copy of it and then editing and publishing the copy.

| Reuse or edit module (?)

Check out and edit

If you have permission to edit this content, using the "Reuse / Edit" action will allow you to check the content out into your Personal Workspace or a shared Workgroup and then make your edits.

Derive a copy

If you don't have permission to edit the content, you can still use "Reuse / Edit" to adapt the content by creating a derived copy of it and then editing and publishing the copy.