<< Chapter < Page Chapter >> Page >

resultant[0].toFixed(2)

In this case, the "[0]" means to retrieve the value stored in thearray element identified by the index value 0.

Once that value has been retrieved, the built-in toFixed method is called, passing the literal value 2 as a parameter, to format the valueso that it will be displayed with two digits to the right of the decimal point.

Figure 5 shows that value displayed in the line of text that reads:

Velocity magnitude = 3.00 miles/hour

(Note that very few of the values that I display in these modules comply with the rules for decimal digits and significant figures that I explained in anearlier module.)

A partial solution to the problem

A partial answer to the question posed for this exercise is that the magnitude of the man's overall velocity with respect to the ground is 3 milesper hour as shown in Figure 5 .

The rest of the solution

The next statement in Listing 3 uses a similar syntax to retrieve the value from the second element in the array object (the element with an index value of1) and to display it as

Velocity angle = 0.00 degrees

as shown in Figure 5 .

This means that the man is moving due east (the same direction that the train is moving) with a velocity of 3 miles per hour with reference to the ground.

Analysis of the results

Now I will tell you why I used a strange walking speed (2.933 feet per second) for the man. As it turns out, this is very close to 2 miles per hour, and Iwanted the man to have a walking speed that would result in simple numeric results.

Let's review the problem

The train is moving east with a uniform velocity of 1 mile per hour relative to the ground.

The man is moving east with a uniform velocity of 2 miles per hour (2.933 feet per second) relative to the train.

What is the man's velocity relative to the ground?

The algebraic sum of the magnitudes

Because the man and the train are both moving along the same straight line, and the man's velocity is stated relative to the train, the magnitude of the man's velocityrelative to the ground is the algebraic sum of the magnitudes of the two velocities. Because they are both moving in the same direction, that algebraicsum is additive.

An analysis of the velocities

The train is moving 1 mile per hour with reference to the ground, and the man is moving 2 miles per hour with reference to the train (along the same line andin the same direction as the train). Therefore, the man is moving 1+2=3 miles per hour with reference to the ground.

This means that an observer standing on the ground at a point on a line perpendicular to the train would perceive the man to be moving to the to theright with a velocity of 3 miles per hour (assuming that the train is moving to the right).

A zero-degree angle is not required

Note that it isn't necessary that the train and the man be moving at an angle of zero degrees (east). The magnitude of the result would be the same regardless of thedirection that they are moving provided they are moving along the same straight line.

We will specify a different common direction for the train and the man in the next exercise.

Get the best College algebra 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