See Release Notes
Long Term Support Release
Differences Between: [Versions 400 and 401]
1 <?php 2 3 namespace PhpOffice\PhpSpreadsheet\Calculation\MathTrig\Trig; 4 5 use PhpOffice\PhpSpreadsheet\Calculation\ArrayEnabled; 6 use PhpOffice\PhpSpreadsheet\Calculation\Exception; 7 use PhpOffice\PhpSpreadsheet\Calculation\Information\ExcelError; 8 use PhpOffice\PhpSpreadsheet\Calculation\MathTrig\Helpers; 9 10 class Tangent 11 { 12 use ArrayEnabled; 13 14 /** 15 * TAN. 16 * 17 * Returns the result of builtin function tan after validating args. 18 * 19 * @param mixed $angle Should be numeric, or can be an array of numbers 20 * 21 * @return array|float|string tangent 22 * If an array of numbers is passed as the argument, then the returned result will also be an array 23 * with the same dimensions 24 */ 25 public static function tan($angle) 26 { 27 if (is_array($angle)) { 28 return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $angle); 29 } 30 31 try { 32 $angle = Helpers::validateNumericNullBool($angle); 33 } catch (Exception $e) { 34 return $e->getMessage(); 35 } 36 37 return Helpers::verySmallDenominator(sin($angle), cos($angle)); 38 } 39 40 /** 41 * TANH. 42 * 43 * Returns the result of builtin function sinh after validating args. 44 * 45 * @param mixed $angle Should be numeric, or can be an array of numbers 46 * 47 * @return array|float|string hyperbolic tangent 48 * If an array of numbers is passed as the argument, then the returned result will also be an array 49 * with the same dimensions 50 */ 51 public static function tanh($angle) 52 { 53 if (is_array($angle)) { 54 return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $angle); 55 } 56 57 try { 58 $angle = Helpers::validateNumericNullBool($angle); 59 } catch (Exception $e) { 60 return $e->getMessage(); 61 } 62 63 return tanh($angle); 64 } 65 66 /** 67 * ATAN. 68 * 69 * Returns the arctangent of a number. 70 * 71 * @param array|float $number Number, or can be an array of numbers 72 * 73 * @return array|float|string The arctangent of the number 74 * If an array of numbers is passed as the argument, then the returned result will also be an array 75 * with the same dimensions 76 */ 77 public static function atan($number) 78 { 79 if (is_array($number)) { 80 return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $number); 81 } 82 83 try { 84 $number = Helpers::validateNumericNullBool($number); 85 } catch (Exception $e) { 86 return $e->getMessage(); 87 } 88 89 return Helpers::numberOrNan(atan($number)); 90 } 91 92 /** 93 * ATANH. 94 * 95 * Returns the inverse hyperbolic tangent of a number. 96 * 97 * @param array|float $number Number, or can be an array of numbers 98 * 99 * @return array|float|string The inverse hyperbolic tangent of the number 100 * If an array of numbers is passed as the argument, then the returned result will also be an array 101 * with the same dimensions 102 */ 103 public static function atanh($number) 104 { 105 if (is_array($number)) { 106 return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $number); 107 } 108 109 try { 110 $number = Helpers::validateNumericNullBool($number); 111 } catch (Exception $e) { 112 return $e->getMessage(); 113 } 114 115 return Helpers::numberOrNan(atanh($number)); 116 } 117 118 /** 119 * ATAN2. 120 * 121 * This function calculates the arc tangent of the two variables x and y. It is similar to 122 * calculating the arc tangent of y รท x, except that the signs of both arguments are used 123 * to determine the quadrant of the result. 124 * The arctangent is the angle from the x-axis to a line containing the origin (0, 0) and a 125 * point with coordinates (xCoordinate, yCoordinate). The angle is given in radians between 126 * -pi and pi, excluding -pi. 127 * 128 * Note that the Excel ATAN2() function accepts its arguments in the reverse order to the standard 129 * PHP atan2() function, so we need to reverse them here before calling the PHP atan() function. 130 * 131 * Excel Function: 132 * ATAN2(xCoordinate,yCoordinate) 133 * 134 * @param mixed $xCoordinate should be float, the x-coordinate of the point, or can be an array of numbers 135 * @param mixed $yCoordinate should be float, the y-coordinate of the point, or can be an array of numbers 136 * 137 * @return array|float|string 138 * The inverse tangent of the specified x- and y-coordinates, or a string containing an error 139 * If an array of numbers is passed as one of the arguments, then the returned result will also be an array 140 * with the same dimensions 141 */ 142 public static function atan2($xCoordinate, $yCoordinate) 143 { 144 if (is_array($xCoordinate) || is_array($yCoordinate)) { 145 return self::evaluateArrayArguments([self::class, __FUNCTION__], $xCoordinate, $yCoordinate); 146 } 147 148 try { 149 $xCoordinate = Helpers::validateNumericNullBool($xCoordinate); 150 $yCoordinate = Helpers::validateNumericNullBool($yCoordinate); 151 } catch (Exception $e) { 152 return $e->getMessage(); 153 } 154 155 if (($xCoordinate == 0) && ($yCoordinate == 0)) { 156 return ExcelError::DIV0(); 157 } 158 159 return atan2($yCoordinate, $xCoordinate); 160 } 161 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body