cos()
The cos()
function returns the cosine of an angle given in radians.
Syntax
$result = math.cos(angle);
result
: The variable to store the output of the cosine operation.
angle
: The angle in radians.
Example
The example below demonstrates the use of the math.cos()
function to find the cosine of a 45-degree angle.
local angle = (math.pi / 4) -- 45 degrees in radianslocal cosineOutput = math.cos(angle)print(cosineOutput)
This example will result in the following output:
0.70710678118655
Looking to contribute?
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.