Java StrictMath atan()方法
java.lang.StrictMath.atan() 是StrictMath类中的一个内置方法,用于返回给定参数的正切值。它返回的角度是在-pi/2和pi/2的范围内。它产生了两个特殊的结果。
- 如果传递的参数是NaN,则输出为NaN。
- 如果传递的参数是0,那么结果也是一个0,保留与参数相同的符号。
语法:
public static double atan(double num)
参数。该方法接受一个双倍类型的参数num,它指的是要返回的正切值。
返回值。该方法返回参数的正切弧度值。
例子 :
Input: num = 0.61
Output: 0.5477400137159024
Input: num = 0.0
Output: 0.0
Input: num = -71.0
Output: -1.5567127509720364
下面的程序说明了java.lang.StrictMath.atan()方法:
程序1:
// Java program to illustrate the
// java.lang.StrictMath.atan()
import java.lang.*;
public class Geeks {
public static void main(String[] args)
{
double num1 = 0.70, num2 = 55.00, num3 = 0;
double atanValue = StrictMath.atan(num1);
System.out.println("The arc tangent of " +
num1 + " = " + atanValue);
atanValue = StrictMath.atan(num2);
System.out.println("The arc tangent of " +
num2 + " = " + atanValue);
atanValue = StrictMath.atan(num3);
System.out.println("The arc tangent of " +
num3 + " = " + atanValue);
}
}
输出:
The arc tangent of 0.7 = 0.6107259643892086
The arc tangent of 55.0 = 1.5526165117219184
The arc tangent of 0.0 = 0.0
程序2:
// Java program to illustrate the
// java.lang.StrictMath.atan()
import java.lang.*;
public class Geeks {
public static void main(String[] args)
{
double num1 = -0.52, num2 = -71.00, num3 = 0;
double atanValue = StrictMath.atan(num1);
System.out.println("The arc tangent of " +
num1 + " = " + atanValue);
atanValue = StrictMath.atan(num2);
System.out.println("The arc tangent of " +
num2 + " = " + atanValue);
atanValue = StrictMath.atan(num3);
System.out.println("The arc tangent of " +
num3 + " = " + atanValue);
}
}
输出:
The arc tangent of -0.52 = -0.4795192919925962
The arc tangent of -71.0 = -1.5567127509720364
The arc tangent of 0.0 = 0.0