The sin() method calculates the sine value of x , where xis in radians.
sin(x)
This method takes the parameter x, which represents the radian value for which the sine value is to be found.
This method returns the sine value of the argument.
The code below demonstrates the use of the sin method:
## find sin of radiandegree = 0radian = deg2rad(degree)println( "sin($(radian)) => $(sin(radian))")## find sin of 10degree = 10radian = deg2rad(degree)println( "sin($(radian)) => $(sin(radian))")
Line 2: We create a new variable degree and assign 0 as a value to it.
Line 3: We use the deg2rad method with the degree variable as an argument. This method converts the degree to radians. The radian value of 0 degrees is 0.0.
Line 4: We use the sin method with the variable radian as an argument. This method calculates the sine value of the radian. In our case, the sine value of radian is 0.0.
Line 7: We assign 10 as the value for the degree variable.
Line 8: We use the deg2rad method with the degree variable as an argument. This method converts the degree to radians. The radian value of 10 degrees is 0.17453292519943295.
Line 9: We use the sin method with the variable radian as an argument. This method calculates the sine value of the radian. In our case, the sine value of radian is 0.17364817766693033.