您的位置:首页 > 编程语言 > Java开发

《JAVA编程技巧1001条》第339条:数学函数 ARCCOS

2017-12-17 10:09 1656 查看


《JAVA编程技巧1001条》第9章 Java数学函数
第339条:数学函数 ArcCOS

339 Using the acos Method

339 acos方法的使用(译著:以下一段中原文有错! 中文已改)

The arccosine is the ratio between the hypotenuse of a right triangle and the leg adjacent to a given angle; the inverse of the cosine of an angle. If y is the cosine of (, then ( is the arccosine of y. The Math class acos method returns the arccosine of an
angle specified in radians. The declaration for the acos function is as follows:

一个角的余弦是与此角相邻的直角边与三角形的斜边的比,而反余弦是一个角的余弦的逆,即: 如果y是角a的余弦,则a就是y的反余弦。在Math类中,acos方法返回用弧度表示的反余弦值。acos函数的说明如下:
public static double acos(double a);

To return the arccosine of a number, you can use the acos method, as shown:

要得到一个数的反余弦,你可使用acos方法,如下所示:

float num = 0.707107F;

num = (float) Math.acos(num);  // return the arccosine,返回反余弦

Notice that these statements use an explicit cast to assign the result to a float because the acos method returns a double. In this case, num will have a value of 0.785398 radians after the assignment.

注意,语句用强制类型转换方式指定返回的结果为float型,因为acos方法缺省情况下返回

double型。在本例中,变量num在赋值后所得到的值将是0.785398。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: