The sin() function in p5.js is used to calculate the sine value of an angle in radians taken as the input parameter of the function and gives the result in between -1 to 1.
sin( angle )
Parameters: This function accepts a single parameter angle which is an angle in radian whose sine value is calculated.
Return Value: It returns the sine value of an angle in radian taken as the input parameter.
Below program illustrates the sin() function in p5.js:
Example: This example uses sin() function to get sine value of an angle in radian.
Note: In the above code, the input angle should be in radian. For converting the degree into radian use the following formula:
Angles_in_radian = (π/180)*angles_in_degree