Calculates the cosine of an angle.
cos() is useful for many geometric tasks in creative coding. The values returned oscillate between -1 and 1 as the input angle increases. cos() calculates the cosine of an angle, using radians by default, or according to if angleMode() setting (RADIANS or DEGREES).
cos() can also be used in shaders with p5.strands. The following example uses cos() to smoothly oscillate the color of a shape over time.
Examples
Syntax
cos(angle)
Parameters
angle
Number: the angle, in radians by default, or according to if angleMode() setting (RADIANS or DEGREES).
Returns
Number: cosine of the angle.
Notice any errors or typos? Please let us know. Please feel free to edit src/math/trigonometry.js and open a pull request!