ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
theta.php
Go to the documentation of this file.
1<?php
2
10namespace Complex;
11
20if (!function_exists(__NAMESPACE__ . '\\theta')) {
21 function theta($complex): float
22 {
23 $complex = Complex::validateComplexArgument($complex);
24
25 if ($complex->getReal() == 0.0) {
26 if ($complex->isReal()) {
27 return 0.0;
28 } elseif ($complex->getImaginary() < 0.0) {
29 return M_PI / -2;
30 }
31 return M_PI / 2;
32 } elseif ($complex->getReal() > 0.0) {
33 return \atan($complex->getImaginary() / $complex->getReal());
34 } elseif ($complex->getImaginary() < 0.0) {
35 return -(M_PI - \atan(\abs($complex->getImaginary()) / \abs($complex->getReal())));
36 }
37
38 return M_PI - \atan($complex->getImaginary() / \abs($complex->getReal()));
39 }
40}
An exception for terminatinating execution or to throw for unit testing.