Java anti-trigonometric function arc tangent function original code precision to 0.03 seconds

Source: Internet
Author: User
ArticleDirectory
    • Java anti-trigonometric function arc tangent function original code precision to 0.03 seconds
Original Java arctangent Function Code Precision to 0.03 seconds

Http://blog.163.com/luckyjackyt@126/blog/static/1404476132010284149643/

 

16:01:49 | classification: Technical article |Font SizeSubscription

I recently encountered one of the biggest problems when I used the Java Road lofting software on my mobile phone. The Java library function does not have the inverse trigonometric function. If this problem cannot be solved, the software cannot be compiled. No third-party libraries are available for a long time. I was forced to write it myself. The original code is released below for your reference or use. The only requirement for use is: If you want to reprint it, please indicate it is transferred from here. Thank you.

/**
* cosine Inverse Calculation function, accurate to 0.03 seconds
* @ Param a double cosine
* @ return double angle (360)
*/
Public double arccos (double A)
{< br> double B = 90.0, C0 = 0.0, C1 = 180.0;
if (a <1 & A>-1)
{< br> DO
{< br> If (math. cos (B * Math. PI/180)> = A)
{< br> C0 = B;
B = (C0 + C1)/2;
}< br> If (math. cos (B * Math. PI/180) <= A)
{< br> C1 = B;
B = (C0 + C1)/2;
}< BR >}< br> while (math. ABS (C0-C1)> 0.00001);
}< br> return B;
}

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.