此方法在java.lang包中可用。
此方法用于返回方法中给定参数的角度的反正切。
在这种方法中,atan代表角度的反正切。
这是一个静态方法,因此也可以使用类名访问此方法。
此方法的返回类型为double,这意味着它返回给定角度的反正切为double数据类型。
在此方法中,我们仅将一个参数作为参数传递给Math类的方法。
在此方法中,我们仅传递弧度类型的参数(即,首先,通过使用toRadians()Math类的方法将给定的参数转换为弧度,然后在方法中传递相同的变量atan())。
此方法不会引发任何异常。
在此方法中,反正切的含义是给定参数的反正切或反正切。
范围atan()–PI / 2至PI / 2。
语法:
public static double atan(double d){
}参数:
double d-要找到反正切的弧度的双精度值。
注意:
如果我们传递“ NaN”,则返回“ NaN”。
如果传递零,则返回相同值。
返回值:
此方法的返回类型为double,它返回给定角度的反正切。
//Java程序演示的例子
//数学类的atan(double d)方法。
class AtanMethod {
public static void main(String[] args) {
//在这里,我们声明了几个变量
double d1 = -0.0;
double d2 = Math.PI / 2;
//显示d1和d2的先前值
System.out.println(" Before implementing atan() so the value of d1 is :" + d1);
System.out.println(" Before implementing atan() so the value of d2 is :" + d2);
//在这里,我们将得到(-0.0),因为我们正在传递绝对值为-0.0-
System.out.println("After implementing atan() so the value of d1 is :" + Math.atan(d1));
//通过使用toRadians()方法将绝对值转换为弧度
d2 = Math.toRadians(d2);
//以弧度形式显示d2的值
System.out.println("After implementing toRadians() so the value of d2 is :" + d2);
//找到d2的反正切
System.out.println("After implementing atan() so the value of d2 is :" + Math.atan(d2));
}
}输出结果
E:\Programs>javac AtanMethod.java E:\Programs>java AtanMethod Before implementing atan() so the value of d1 is :-0.0 Before implementing atan() so the value of d2 is :1.5707963267948966 After implementing atan() so the value of d1 is :-0.0 After implementing toRadians() so the value of d2 is :0.027415567780803774 After implementing atan() so the value of d2 is :0.0274087022410345