Java Math.toDegrees()弧度转换成角度

Java中Math.toDegrees()用于将以弧度测量的角度转换为以度为单位的近似等效角度,也就是将-π/2到π/2之间的弧度值转化为度。如果要将角度转成成弧度用Math.toRadians

语法

public static double toDegrees(double angrad)

参数

angrad //以弧度表示的角度

返回值

返回以度为单位的角度

源码

public final class Math {
    private Math() {}
 
    public static final double E = 2.7182818284590452354;
 
    public static final double PI = 3.14159265358979323846;	
	
    public static double toDegrees(double angrad) {
        return angrad * 180.0 / PI;
    }
}

实例

public class MathtoDegreesDemo{
	public static void main(String args[]){
		System.out.println(Math.toDegrees(Math.PI/2));
	}
}

输出:90.0

版权声明:本文为JAVASCHOOL原创文章,未经本站允许不得转载。