<< Chapter < Page Chapter >> Page >

Screen output

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

Figure 4 . 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 degrees Total time = 0.63 secondsAverage velocity magnitude = 39.47 feet/second Average velocity angle = 98.13 degreesEnd 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

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Accessible physics concepts for blind students. OpenStax CNX. Oct 02, 2015 Download for free at https://legacy.cnx.org/content/col11294/1.36
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Accessible physics concepts for blind students' conversation and receive update notifications?

Ask