GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 6fcb7a...fcde01 )
by t
06:59 queued 04:42
created

AMAT::acot()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
/**
3
 * Trait MathAndTrigonometry-A
4
 *
5
 * @link https://www.icy2003.com/
6
 * @author icy2003 <[email protected]>
7
 * @copyright Copyright (c) 2017, icy2003
8
 */
9
namespace icy2003\php\icomponents\excel\mathAndTrigonometry;
10
use icy2003\php\ihelpers\Strings;
11
12
/**
13
 * MathAndTrigonometry-A
14
 */
15
trait AMAT
16
{
17
    /**
18
     * 返回数字的绝对值
19
     *
20
     * - y = |x|, x ∈ (-∞, +∞)
21
     *
22
     * @param double  $number 必需。 需要计算其绝对值的实数
23
     *
24
     * @return double
25
     */
26 2
    public static function abs($number)
27
    {
28 2
        return abs($number);
29
    }
30
31
    /**
32
     * 返回数字的反余弦值
33
     *
34
     * - y = arccos(x), x ∈ [-1, 1]
35
     *
36
     * @param double $number 必需。 所求角度的余弦值,必须介于 -1 到 1 之间
37
     *
38
     * @return double
39
     */
40 1
    public static function acos($number)
41
    {
42 1
        return acos($number);
43
    }
44
45
    /**
46
     * 返回数字的反双曲余弦值
47
     *
48
     * - y = arcosh(x) = ln(x + √(x^2 -1)), x ∈ [1, +∞)
49
     *
50
     * @param double $number 必需。 大于或等于 1 的任意实数
51
     *
52
     * @return double
53
     */
54 1
    public static function acosh($number)
55
    {
56 1
        return acosh($number);
57
    }
58
59
    /**
60
     * 返回数字的反余切值的主值
61
     *
62
     * - y = arccot(x), x ∈ (-∞, +∞)
63
     *
64
     * @param double $number 必需。 Number 为所需角度的余切值。 此值必须是实数
65
     *
66
     * @return double
67
     */
68 1
    public static function acot($number)
69
    {
70 1
        return pi() / 2 - atan($number);
71
    }
72
73
    /**
74
     * 返回数字的反双曲余切值
75
     *
76
     * - y = arccoth(x) = arctanh(1 / x), {x| x > 1 或 x < -1}
77
     *
78
     * @param double $number 必需。 Number 的绝对值必须大于 1
79
     *
80
     * @return double
81
     */
82 1
    public static function acoth($number)
83
    {
84 1
        return atanh(1 / $number);
85
    }
86
87
    /**
88
     * 将罗马数字转换为阿拉伯数字
89
     *
90
     * @param string $string 必需。 用引号引起的字符串、空字符串 ("") 或对包含文本的单元格的引用
91
     *
92
     * @return integer
93
     */
94 1
    public static function arabic($string)
95
    {
96
        $roman = array(
97 1
            'M' => 1000,
98
            'D' => 500,
99
            'C' => 100,
100
            'L' => 50,
101
            'X' => 10,
102
            'V' => 5,
103
            'I' => 1,
104
        );
105 1
        $strlen = Strings::length($string);
106 1
        $values = [];
107 1
        for ($i = 0; $i < $strlen; $i++) {
108 1
            if (isset($roman[strtoupper($string[$i])])) {
109 1
                $values[] = $roman[strtoupper($string[$i])];
110
            }
111
        }
112
113 1
        $sum = 0;
114 1
        while ($current = current($values)) {
115 1
            $next = next($values);
116 1
            $next > $current ? $sum += $next - $current + 0 * next($values) : $sum += $current;
117
        }
118 1
        return $sum;
119
    }
120
121
    /**
122
     * 返回数字的反正弦值
123
     *
124
     * - y = arcsin(x), x ∈ [-1, 1]
125
     *
126
     * @param double $number 必需。 所求角度的正弦值,必须介于 -1 到 1 之间
127
     *
128
     * @return double
129
     */
130 1
    public static function asin($number)
131
    {
132 1
        return asin($number);
133
    }
134
135
    /**
136
     * 返回数字的反双曲正弦值
137
     *
138
     * - y = arsinh(x) = ln(x + √(x^2 + 1)), x ∈ (-∞, +∞)
139
     *
140
     * @param double $number 必需。 任意实数
141
     *
142
     * @return double
143
     */
144 1
    public static function asinh($number)
145
    {
146 1
        return asinh($number);
147
    }
148
149
    /**
150
     * 返回数字的反正切值
151
     *
152
     * - y = arctan(x), x ∈(-π/2, π/2)
153
     *
154
     * @param double $number 必需。 所求角度的正切值
155
     *
156
     * @return double
157
     */
158 2
    public static function atan($number)
159
    {
160 2
        return atan($number);
161
    }
162
163
    /**
164
     * 返回给定的 X 轴及 Y 轴坐标值的反正切值
165
     *
166
     * @param double $x 必需。 点的 x 坐标
167
     * @param double $y 必需。 点的 y 坐标
168
     *
169
     * @return double
170
     */
171 1
    public static function atan2($x, $y)
172
    {
173 1
        $sign = 1;
174 1
        if ($y < 0) {
175 1
            $sign = -1;
176
        }
177 1
        if ($x < 0) {
178 1
            return $sign * (pi() - self::abs(self::atan($y / $x)));
179 1
        } elseif ($x == 0) {
180 1
            return pi() / 2 * $sign;
181
        } else {
182 1
            return $sign * self::abs(self::atan($y / $x));
183
        }
184
    }
185
186
    /**
187
     * 返回数字的反双曲正切值
188
     *
189
     * - y = artanh(x), x ∈(-1, 1) = 1/2 * ln((1 + x) / (1 - x))
190
     *
191
     * @param double $number 必需。 -1 到 1 之间的任意实数
192
     *
193
     * @return double
194
     */
195 1
    public static function atanh($number)
196
    {
197 1
        return atanh($number);
198
    }
199
}
200