Triangle function in Java block chain

Source: Internet
Author: User

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:




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.