<< Chapter < Page Chapter >> Page >

To determine the position of the arrow at some time after it is released, we must determine both the vertical and thehorizontal 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 independentlyof 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 andplot 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 verticalcomponent of motion doesn't effect the horizontal motion and changing the horizontal component of motiondoesn'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.

Listing 4 . Acceleration of gravity exercise #2.

<!---------------- File JavaScript04.html ---------------------><html><body><script language="JavaScript1.3">document.write("Start Script<br/>"); //Define common parametersvar ang = 45;//firing angle degrees re the horizontal var tInc = 0.25;//calculation interval in secondsvar v0 = 100;//initial velocity in ft/sec //Define horizontal parametersvar 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*secvar vy0 = v0*Math.sin( ang*Math.PI/180);//component of initial velocity in ft/secvar y0 = 6;//initial height in feet //Declare and initialize working variablesvar t = .0001;//current time in seconds var x = x0;//current x in feetvar 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 timewhile(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 loopdocument.write("End Script");</script></body></html>

Screen output

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

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

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