cos() : Cosine Function
On this page
Summary
Calculate the cosine of an angle (in radians).
Signature
cos(angleInRadians)
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
angleInRadians |
Number | Yes | The angle in radians |
Returns
Type: Double
The cosine of the angle (value between -1 and 1).
Examples
Basic Cosine
Output:
<p>cos(0) = 1.000</p>
<p>cos(π) = -1.000</p>
Convert Degrees to Radians
Output:
<p>cos(0°) = 1.000</p>
<p>cos(60°) = 0.500</p>
<p>cos(90°) = 0.000</p>
Calculate Position
Data:
doc.Params["model"] = new {
radius = 10,
angle = Math.PI / 3 // 60 degrees
};
Output:
<p>X = 5.00</p>
Notes
- Input must be in radians (not degrees)
- Returns value between -1 and 1
- For degrees, use:
cos(radians(degrees)) - Common values:
- cos(0) = 1
- cos(π/3) = 0.5
- cos(π/2) = 0
- cos(π) = -1