Recently used a Java triangle function, found that the knowledge of middle school forget, here in conjunction with the Java Trigonometric function method to review again.
In the Math class: PI represents the radian corresponding to 180°.
Trigonometric functions: sin (); cos (); Tan (); The parameter is a radian value , and the result is a trigonometric value.
Inverse trigonometric functions such as: ASIN (), ACOs (), atan (); parameter, tangent or slope ; Result: the radian value corresponding to the angle.
A method of obtaining an angle in the Math class: Math.todegree (); The argument is a Radian value (can be the result of an inverse function)
Note here:
The parameter of a trigonometric function is a radian corresponding to an angle, not a direct write angle value.
Inverse Trigonometric functions Parameters generally we write the slope, which is the value of the hypotenuse in the triangle.
Example:
@Test public
void Test () {
System.out.println ("Exampleunittest-sin 90°=" +math.sin (MATH.PI/2));
System.out.println ("exampleunittest-30°-1=" +math.todegrees (MATH.PI/6));
System.out.println ("exampleunittest-30°-2=" +math.todegrees (Math.asin (Math.sin (MATH.PI/6)));
System.out.println ("exampleunittest-sin30°=" +math.sin (MATH.PI/6));
System.out.println ("Exampleunittest-asin 0.5=" +math.todegrees (Math.asin (0.5));//To find the radian corresponding angle
of a sine value System.out.println ("Exampleunittest-cos 60°==" +math.cos (MATH.PI/3));
System.out.println ("Exampleunittest-tan 45°==" +math.tan (MATH.PI/4));
System.out.println ("exampleunittest-atan==" +math.atan (Math.tan (MATH.PI/4)));/Seek solitude
System.out.println (" exampleunittest-atan1== "+math.atan (1));//Find the slope corresponding to the lonely
System.out.println (" exampleunittest-atan1== "+ Math.todegrees (Math.atan (1)))//To find the corresponding angle of the slope of loneliness
The results are illustrated as follows: