本文共 2508 字,大约阅读时间需要 8 分钟。
strictmath
toDegrees() method is available in java.lang package.
toDegrees()方法在java.lang包中可用。
toDegrees() method is used to convert the given angle from radians to degrees or in other words, this method is used to convert an angle measured in radians to an equivalent angle measured in degrees.
toDegrees()方法用于将给定角度从弧度转换为度,换句话说,该方法用于将以弧度测量的角度转换为以度为单位的等效角度。
toDegrees() method is a static method so it is accessible with the class name and if we try to access the method with the class object then we will not get any error.
toDegrees()方法是一个静态方法,因此可以使用类名进行访问,如果尝试使用类对象访问该方法,则不会出现任何错误。
toDegrees() method does not throw any exception at the time of conversion of angle from radians to degrees.
从弧度到度的角度转换时, toDegrees()方法不会引发任何异常。
The result of conversion an angle from radians to degrees is not generally exact.
通常将角度从弧度转换为角度的结果不准确。
Syntax:
句法:
public static double toDegrees(double ang_in_rad);
Parameter(s):
参数:
double ang_in_rad – represents an angle in radians.
double ang_in_rad –表示弧度的角度。
Return value:
返回值:
The return type of this method is double – it returns the degrees converted value of the given angle (in radians).
此方法的返回类型为double-返回给定角度的度数转换值(以弧度为单位)。
Example:
例:
// Java program to demonstrate the example of // toDegrees(double ang_in_rad) method of StrictMath classpublic class ToDegrees { public static void main(String[] args) { // Variable Declarations double d1 = 60; double d2 = -60; double d3 = 90; double d4 = -90; // Display previous value of d1,d2,d3 and d4 System.out.println("d1: " + d1); System.out.println("d2: " + d2); System.out.println("d3: " + d3); System.out.println("d4: " + d4); // By using toDegrees() method is used to convert the //given angle from radians into degrees d1 = StrictMath.toDegrees(d1); d2 = StrictMath.toDegrees(d2); d3 = StrictMath.toDegrees(d3); d4 = StrictMath.toDegrees(d4); System.out.println("StrictMath.toDegrees(d1): " + d1); System.out.println("StrictMath.toDegrees(d2): " + d2); System.out.println("StrictMath.toDegrees(d3): " + d3); System.out.println("StrictMath.toDegrees(d4): " + d4); }}
Output
输出量
d1: 60.0d2: -60.0d3: 90.0d4: -90.0StrictMath.toDegrees(d1): 3437.746770784939StrictMath.toDegrees(d2): -3437.746770784939StrictMath.toDegrees(d3): 5156.620156177409StrictMath.toDegrees(d4): -5156.620156177409
翻译自:
strictmath
转载地址:http://ipvzd.baihongyu.com/