Math.sin()
Math.sin() returns the trigonometric sin value of an angle in radian.
Syntax
Math.sin(angle_in_radian)
Note that all input numbers are in Radians.
Here are some examples.
System.out.println(Math.sin(Math.PI)); //1.2246467991473532E-16
System.out.println(Math.sin(Math.PI/2));//1.0
System.out.println(Math.sin(2)); //0.9092974268256817
System.out.println(Math.sin(1.22)); //0.9390993563190676
System.out.println(Math.sin(-1.22)); //-0.9390993563190676
System.out.println(Math.sin(0)); // 0.0
We can use toRadians to convert degree value to radian.
Math.round() to rounds a floot or double data type to nearest integer value
System.out.println(Math.round((Math.sin(Math.toRadians(180)))));//0
System.out.println((Math.sin(Math.toRadians(180))));//1.2246467991473532E-16
System.out.println(Math.sin(Math.toRadians(90))); //1.0
System.out.println(Math.sin(Math.PI)); //1.2246467991473532E-16
System.out.println(Math.sin(Math.PI/2)); //1.0
« All Math functions
« Java
This article is written by plus2net.com team.
plus2net.com