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;
}