《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。
相关文章推荐
- 《JAVA编程技巧1001条》第334条:数学函数 求绝对值.
- 《JAVA编程技巧1001条》第335条:数学函数 SQRT.
- 《JAVA编程技巧1001条》第337条:数学函数 SIN。
- 《JAVA编程技巧1001条》第338条:数学函数 TAN
- 《JAVA编程技巧1001条》第341条:数学函数 ARCTAN;
- 《Java编程技巧1001条》 第345条:使用ceil方法
- 《Java编程技巧1001条》 第598...条 滚动文本动画
- 《Java编程技巧1001条》第604条:了解图像的观察器
- 《Java编程技巧1001条》第591-609条 播放声音剪辑
- 《Java编程技巧1001条》 第346条:浮点数向上向下舍入方法
- 《Java编程技巧1001条》第373条: 了解不同的日期标准,
- 《Java编程技巧1001条》 第605条: 检测图像装入过程
- 《Java编程技巧1001条》357条:用高斯分布建立随机数
- 《Java编程技巧1001条》第606条: 获得图像的大小尺寸
- 《Java编程技巧1001条》第609条: 建立推进特殊效果
- 《Java编程技巧1001条》360-373条:用日期函数获得当前日期
- 《Java编程技巧1001条》第603条: 使用双缓冲器改进动画
- 《Java编程技巧1001条》第362条: 用日期类 建立你自己的 日期/时间
- 《Java编程技巧1001条》第607条: 利用MediaTraker预装图像
- 《Java编程技巧1001条》第375条: 使用DOS下的 TZ 环境变量,