<< Chapter < Page Chapter >> Page >

No further explanation needed

Because of the similarity of Listing 5 and Listing 2 , no further explanation of the code in Listing 5 should be needed. As you can see from Figure 7 , the output values match the known lengths for the hypotenuse and the adjacent sidefor the 3-4-5 triangle.

Figure 7 . Output for script in Listing 5.
adjacent = 3.0000071456633126 hypotenuse = 5

Computing length of adjacent side with the Google calculator

We could also compute the length of the adjacent side using the Google calculator.

The length of the adjacent side -- sample computation

Enter the following into the Google search box:

5*cos(53.1301024 degrees)

The following will appear immediately below the search box:

5 * cos(53.1301024 degrees) = 3

This is the length of the adjacent side for the given angle and the given length of the hypotenuse.

Two very important equations

From an introductory physics viewpoint, two of the most important and perhaps most frequently used equations from Figure 5 and Figure 6 are shown in Figure 8 .

Figure 8 . Two very important equations.
opp = hyp * sine(angle) adj = hyp * cosine(angle)

These two equations are so important that it might be worth your while to memorize them. Of course, you will occasionally need most of the equationsin Figure 5 and Figure 6 , so you should try to remember them, or at least know where to find them when you need them.

Vectors

As you will see later in the module that deals with vectors, you are often presented with something that resembles the hypotenuse of a righttriangle whose adjacent side is on the horizontal axis and whose opposite side is parallel to the vertical axis.

The thing that looks like the hypotenuse of a right triangle is called a vector . It has a length and it has a direction. Typically, the direction is stated as the angle between the vector and the horizontal axis. Thus, thedirection is analogous to the angle at the origin in your triangle.

Horizontal and vertical components

For reasons that I won't explain until we get to that module, you will often need to compute the horizontal and vertical components of the vector.The horizontal component is essentially the adjacent side of our current right triangle. Thus, the value of the horizontal component can be computed using thesecond equation in Figure 8 .

The vertical component is essentially the opposite side of our current right triangle, and its value can be computed using the first equation in Figure 8 .

The tangent and arctangent of an angle

Once again, although the tangent of an angle is based on very specific geometric considerations involving circles (see (External Link) ), for our purposes, the tangent of an angle is simply a ratio between the lengths of two different sides of a righttriangle.

A ratio of two sides

For our purposes, we will say that the tangent of an angle is equal to the ratio of the opposite side and the adjacent side. Therefore, in the case of the3-4-5 triangle, the tangent of the angle at the origin is equal to 4/3 or 1.333.

Not limited to 1.0

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