Get Cosine Method
The Get Cosine method returns an approximate cosine of the value that the number argument contains, expressed in radians.The return value is between negative 1 and 1. The angle can be positive or negative. If this method cannot convert the value to a number, then it returns the following value:
NaN
This method uses the same argument as the Get Absolute Value method. The only difference is that the number argument for the Get Cosine method includes an angle in radians. For more information, see Get Absolute Value Method.
Format
Math.cos(number)
The following example finds the length of a roof, given the roof pitch and the distance of the house from the center of the house to the outside wall of the house:
function RoofBtn3_Click ()
{
var pitch;
var width;
var roof;
pitch = 35;
pitch = Math.cos(pitch*(Math.PI/180));
width = 75;
width = width / 2;
roof = width/pitch;
TheApplication().RaiseErrorText("The length of the roof is " +
Clib.rsprintf("%5.2f", roof) + " feet.");
}