<< Chapter < Page Chapter >> Page >

Discussion and sample code

Let's work through an exercise manually to determine the distance from your home to your school in miles given that we know the distance in paces. (I will convertthis to a JavaScript script later in the module.)

As we discussed earlier, you have already determined that the distance from your home to your school is 2112paces. We have also recognized that the length of one of your paces is likely to be different from the length of someone else's paces.

Manual exercise on converting units

This is a somewhat long and tedious explanation, but unless you already have quite a lot of experience in this area, you should probably bear with me as Iwalk you through it.

Convert your pace length to standard units

First we must convert the length of your pace to standard units, which we can then convert to miles.

A calibration exercise

Assume that you go into an empty parking lot, mark your starting position, walk 100paces, and then mark your ending position on the pavement. Assume that you then use a measuring tape to measure the distance from the starting position tothe ending position and you find that distance to be 3000 inches.

From that, we could conclude that for your pace length,

100 paces = 3000 inches

Thus, we have calibrated your pace length in terms of the standard unit inch.

The plural versus the singular

Note that the use of the plural such as inches and the singular such as inch has no impact on the results of our computations. we can switch back and forth from the plural to the singular atwill as long as it makes sense to do so.

A conversion factor

If we divide both sides of the above equation by 100 paces, we get

1 = 3000 inches/100 paces = 30 inches/pace

Note that we now have a 1 on the left side and a fraction on the right side.

Multiplication by 1

Multiplying a value by 1 doesn't change the value. This means that if we multiply a term in an algebraic expression by

30*inch/pace

we won't change the intrinsic value of the term, although we might change the units in which that value is expressed.

The term

30*inch/pace

can be used to convert a quantity in units of paces to the same quantity in units of inches.

Move your body forward

So now we know that on the average, each time you execute one pace, you have moved your body forward by 30 inches. The next task is to determine how far youhave moved your body when you have executed 2112 paces (the distance from home to school measured in paces).

Convert from paces to inches

We can begin by determining the distance from home to school in inches as follows:

distance = (2112*pace) * (30*inch/pace)

A review of algebra

At this point, let's review a little algebra:

Given the expression: ((w/x)*(y/z))

we can rewrite this as

(w*y)/(x*z)

Given this expression, we can reverse the process by rearranging and factoring out the terms producing our original expression:

((w/x)*(y/z))

An algebraic manipulation

We determined earlier that

distance = (2112*pace) * (30*inch/pace)

Applying the algebraic process shown above to the problem at hand, we can rearrange terms and factor our expression to produce

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