Java.lang.StrictMath.atan() 方法

描述

java.lang.StrictMath.atan() 方法返回一个值的反正切值。返回的角度在 -pi/2 through pi/2 范围内。包括这些情况 −

  • 如果参数为 NaN,则结果为 NaN。
  • 如果参数为零,则结果为零,符号与参数相同。

声明

以下是 java.lang.StrictMath.atan() 方法的声明。

public static double atan(double a)

参数

a − 这是要返回其反正切的值。


返回值

此方法返回参数的反正切。


异常

NA


示例

下面的例子展示了 java.lang.StrictMath.atan() 方法的使用。

package com.tutorialspoint;

import java.lang.*;

public class StrictMathDemo {

   public static void main(String[] args) {

      double d1 = 0.20 , d2 = 60.00, d3 = 0;
   
      /* returns the arc tangent of a value, returned angle range is
         -pi/2 to pi/2  */
    
      double dAbsValue = StrictMath.atan(d1); 
      System.out.println("arc tangent of " + d1 + " = " + dAbsValue);

      dAbsValue = StrictMath.atan(d2); 
      System.out.println("arc tangent of " + d2 + " = " + dAbsValue);

      dAbsValue = StrictMath.atan(d3); 
      System.out.println("arc tangent of " + d3 + " = " + dAbsValue);
   }
}

让我们编译并运行上面的程序,这将产生下面的结果 −

arc tangent of 0.2 = 0.19739555984988078
arc tangent of 60.0 = 1.554131203080956
arc tangent of 0.0 = 0.0