📜  Java toRadians() 方法与示例

📅  最后修改于: 2022-05-13 01:54:20.321000             🧑  作者: Mango

Java toRadians() 方法与示例

Java.lang.Math.toRadians() 用于将以度为单位的角度转换为以弧度为单位的大致等效角度。
注意:从度数到弧度的转换通常是不精确的。

语法

public static double toRadians(double deg)

Parameter:
deg : This parameter is an angle in degrees which
we want to convert in radians.
Return :
This method returns the measurement of the angle 
deg in radians.

示例:显示Java.lang.Math.toRadians()方法的工作。

Java
// Java program to demonstrate working
// of java.lang.Math.toRadians() method
import java.lang.Math;
 
class Gfg {
 
    // driver code
    public static void main(String args[])
    {
        // converting PI from degree to radian
        double deg = 180.0;
        System.out.println(Math.toRadians(deg));
 
        // converting PI/2 from degree to radian
        deg = 90.0;
        System.out.println(Math.toRadians(deg));
 
        // converting PI/4 from degree to radian
        deg = 45.0;
        System.out.println(Math.toRadians(deg));
    }
}


输出:

3.141592653589793
1.5707963267948966
0.7853981633974483