<< Chapter < Page Chapter >> Page >

A ratio of two sides

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

As before, if we know the lengths of the hypotenuse and the adjacent side, we can compute the cosine and use it to determine the value of the angle. (We willdo this later.)

Conversely, if we know the value of the angle but don't know the lengths of the hypotenuse and/or the adjacent side, we can obtain the cosine value (theratio of the adjacent side and the hypotenuse) using a scientific calculator or lookup table and use it for other purposes later.

The cosine of an angle -- sample computation

Enter the following into the Google search box:

cos(53.13010235415598 degrees)

The following will appear immediately below the search box:

cos(53.13010235415598 degrees) = 0.6

This matches the ratio of the adjacent side to the hypotenuse for a 3-4-5 triangle.

The arccosine (inverse cosine) of an angle

The arccosine of an angle is the value of the angle having a given cosine value. In other words, if you know the value of the cosine of an unknown angle,you can use a scientific calculator or lookup table to find the value of the angle.

Getting the angle for a known cosine value

For example, we know that the cosine of the angle at the origin of the 3-4-5 triangle is 0.6. From that, we can determine the value of the angle using eitherthe Google calculator or JavaScript.

The arccosine of an angle -- sample computation

Enter the following into the Google search box:

arccos(3/5) in degrees

The following will appear immediately below the search box:

arccos(3/5) = 53.1301024 degrees

This is the angle that corresponds to a ratio of the adjacent side to the hypotenuse of 3/5.

As you should expect. the computed angle is the same as before. We didn't change the angle, we simply computed it using a different approach.

Getting the angle using JavaScript

Please create an html file containing the code shown in Listing 4 and open it in your browser.

Listing 4 . Arccosine of 3-4-5 triangle.
<!-- File JavaScript04.html --><html><body><script language="JavaScript1.3">function toRadians(degrees){ return degrees*Math.PI/180}//end function toRadians //============================================//function toDegrees(radians){ return radians*180/Math.PI}//end function toDegrees //============================================//var adj = 3 var hyp = 5var ratio = adj/hyp var angRad = Math.acos(ratio)var angDeg = toDegrees(angRad) document.write("radians = " + angRad + "<br/>") document.write("degrees = " + angDeg)</script></body></html>

Similar to a previous script

If you examine the code in Listing 4 carefully, you will see that it is very similar to the code in Listing 2 with a couple of exceptions:

  • The variable opp having a value of 4 was replaced by the variable adj having a value of 3.
  • The call to the Math.asin method was replaced by a call to the Math.acos method.

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