You are here

public static function PHPExcel_Calculation_MathTrig::ATAN2 in Loft Data Grids 6.2

Same name and namespace in other branches
  1. 7.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/MathTrig.php \PHPExcel_Calculation_MathTrig::ATAN2()

* ATAN2 * * This function calculates the arc tangent of the two variables x and y. It is similar to * calculating the arc tangent of y ÷ x, except that the signs of both arguments are used * to determine the quadrant of the result. * The arctangent is the angle from the x-axis to a line containing the origin (0, 0) and a * point with coordinates (xCoordinate, yCoordinate). The angle is given in radians between * -pi and pi, excluding -pi. * * Note that the Excel ATAN2() function accepts its arguments in the reverse order to the standard * PHP atan2() function, so we need to reverse them here before calling the PHP atan() function. * * Excel Function: * ATAN2(xCoordinate,yCoordinate) * * @access public * @category Mathematical and Trigonometric Functions *

Parameters

float $xCoordinate The x-coordinate of the point.: * @param float $yCoordinate The y-coordinate of the point. * @return float The inverse tangent of the specified x- and y-coordinates.

File

vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/MathTrig.php, line 100

Class

PHPExcel_Calculation_MathTrig
PHPExcel_Calculation_MathTrig

Code

public static function ATAN2($xCoordinate = NULL, $yCoordinate = NULL) {
  $xCoordinate = PHPExcel_Calculation_Functions::flattenSingleValue($xCoordinate);
  $yCoordinate = PHPExcel_Calculation_Functions::flattenSingleValue($yCoordinate);
  $xCoordinate = $xCoordinate !== NULL ? $xCoordinate : 0.0;
  $yCoordinate = $yCoordinate !== NULL ? $yCoordinate : 0.0;
  if ((is_numeric($xCoordinate) || is_bool($xCoordinate)) && is_numeric($yCoordinate) || is_bool($yCoordinate)) {
    $xCoordinate = (double) $xCoordinate;
    $yCoordinate = (double) $yCoordinate;
    if ($xCoordinate == 0 && $yCoordinate == 0) {
      return PHPExcel_Calculation_Functions::DIV0();
    }
    return atan2($yCoordinate, $xCoordinate);
  }
  return PHPExcel_Calculation_Functions::VALUE();
}