<< Chapter < Page | Chapter >> Page > |
For example, we know that the sine of the angle at the origin on your graph board is4/5. From that, we can determine the value of the angle. However, we probably can't do this calculation in our heads so we will use the Google calculator to computethe value of the angle.
The arcsine of an angle -- sample computation
Enter the following into the Google search box:
arcsin(4/5) in degrees
The following will appear immediately below the search box:
arcsin(4/5) = 53.1301024 degrees
This is the angle that corresponds to a ratio of the opposite side to the hypotenuse of 4/5.
We can also write a JavaScript script to perform the calculation, which we will do shortly.
Getting the angle for a known sine value
Please use your protractor to measure and record the angle at the origin on your graph board, or measure it on your tactile graphic. Then create an html file containing the code shown in Listing 2 and open it in your browser.
Listing 2 . Arcsin of 3-4-5 triangle. |
---|
<!-- File JavaScript02.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 opp = 4
var hyp = 5var ratio = opp/hyp
var angRad = Math.asin(ratio)var angDeg = toDegrees(angRad)
document.write("radians = " + angRad + "</br>")
document.write("degrees = " + angDeg)</script></body></html> |
The output for the angle
When you open your html file in your browser, the output shown in Figure 5 should appear in the browser window.
Figure 5 . Output for script in Listing 2. |
---|
radians = 0.9272952180016123
degrees = 53.13010235415598 |
Did you measure the angle to be 53 degrees with your protractor. If so, congratulations. If not, you should probably take another look at it.
Define conversion functions
The code in Listing 2 begins by defining the functions named toRadians and toDegrees that we developed earlier in Listing 1 . (In this case, we will only need the function named toDegrees so I could have omitted the code for the function named toRadians .)
Declare and initialize variables
Then the code in Listing 2 declares and initializes variables to represent the lengths of the opposite side and the hypotenuse for thetriangle on your graph board ( opp and hyp ). Then it computes and saves the ratio of the two. (We learned earlier thatthe ratio is the value of the sine of the angle at the origin even though we don't know the value of the angle.)
The built-in Math.asin method
JavaScript has a built-in method named Math.asin that receives the sine value for an unknown angle and returns the value of thecorresponding angle in radians. (The Math.asin method has the same purpose at the word arcsin in the Google calculator.)
The returned value is an angle between -PI/2 and PI/2 radians. (I will have more to say about this later.)
Listing 2 calls the Math.asin method, passing the ratio (sine of the angle) as a parameter, and stores the returned value in a variablenamed angRad .
Notification Switch
Would you like to follow the 'Contemporary math applications' conversation and receive update notifications?