<< Chapter < Page Chapter >> Page >

Screen output

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

Figure 3 . Screen output for Listing #2.
Start Script Time for leg A = 0.30 secondsTime for leg B = 0.33 seconds Displacement magnitude = 25.00 feetDisplacement angle = 98.13 degreesTotal time = 0.63 seconds Average velocity magnitude = 39.47 feet/secondAverage velocity angle = 98.13 degrees End Script

Analysis of the code

In this exercise, the puck makes a journey across the ice consisting of two sequential legs in different directions with different magnitudes ofvelocity. Although each leg involves motion along a line, the total trip is not along a line.

The objective of the script is to

  • Compute and display the time required to traverse each leg of the trip based on the given information.
  • Compute and display the magnitude and the angle of the displacement from start to finish.
  • Compute and display the time required to complete the entire trip, which is the sum of the times from both legs.
  • Compute and display the magnitude of the average velocity as the magnitude of the displacement divided by the total time.
  • Recognize that the angle of the average velocity is the same as the angle of the displacement.

The getAngle function

The code in Listing 2 begins with the getAngle function that we developed and used an earlier module. The purpose of the function is to receive the adjacentand opposite side values for a right triangle as parameters and to return the angle in degrees in the correct quadrant.

I explained this function in an earlier module and won't repeat that explanation in this module.

Compute the time for each leg

Following the definition of the getAngle function, Listing 2 computes the time required to traverse each leg of the trip. For variable naming purposes, the two legs are identified as A and B.

Variable names that end with "mag" contain vector magnitudes. Variable names that end with "ang" contain vector angles. Variable names that endwith "vel" contain the magnitudes of straight-line, uniform velocities.

The time to complete each leg of the trip is computed by dividing the magnitude of the displacement vector for that leg by the magnitude of thestraight-line velocity for that leg. The resulting times have units of seconds, and are saved in the variables named timeA and timeB .

The overall displacement

The magnitude and angle of the overall displacement for the two-leg trip (identified by the variables named vecResultMag and vecResultAng respectively) are computed using procedures that were explained in an earlier module. Therefore, I won't repeat that explanation inthis module.

The magnitude of the overall displacement is stored in the variable named vecResultMag , and the angle for the overall displacement is stored in the variable named vecResultAng .

The total time

The total time for the trip, identified by the variable named totalTime , is computed as the sum of the times for the individual legs.

Magnitude of the average velocity vector

Questions & Answers

a perfect square v²+2v+_
Dearan Reply
kkk nice
Abdirahman Reply
algebra 2 Inequalities:If equation 2 = 0 it is an open set?
Kim Reply
or infinite solutions?
Kim
y=10×
Embra Reply
if |A| not equal to 0 and order of A is n prove that adj (adj A = |A|
Nancy Reply
rolling four fair dice and getting an even number an all four dice
ramon Reply
Kristine 2*2*2=8
Bridget Reply
Differences Between Laspeyres and Paasche Indices
Emedobi Reply
No. 7x -4y is simplified from 4x + (3y + 3x) -7y
Mary Reply
is it 3×y ?
Joan Reply
J, combine like terms 7x-4y
Bridget Reply
im not good at math so would this help me
Rachael Reply
how did I we'll learn this
Noor Reply
f(x)= 2|x+5| find f(-6)
Prince Reply
f(n)= 2n + 1
Samantha Reply
Need to simplify the expresin. 3/7 (x+y)-1/7 (x-1)=
Crystal Reply
. After 3 months on a diet, Lisa had lost 12% of her original weight. She lost 21 pounds. What was Lisa's original weight?
Chris Reply
preparation of nanomaterial
Victor Reply
Yes, Nanotechnology has a very fast field of applications and their is always something new to do with it...
Himanshu Reply
can nanotechnology change the direction of the face of the world
Prasenjit Reply
At high concentrations (>0.01 M), the relation between absorptivity coefficient and absorbance is no longer linear. This is due to the electrostatic interactions between the quantum dots in close proximity. If the concentration of the solution is high, another effect that is seen is the scattering of light from the large number of quantum dots. This assumption only works at low concentrations of the analyte. Presence of stray light.
Ali Reply
the Beer law works very well for dilute solutions but fails for very high concentrations. why?
bamidele Reply
how did you get the value of 2000N.What calculations are needed to arrive at it
Smarajit Reply
Got questions? Join the online conversation and get instant answers!
QuizOver.com Reply

Get the best Algebra and trigonometry course in your pocket!





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