Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
2 / 2 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
Ellipse | |
100.00% |
2 / 2 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
getSurface | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getPerimeter | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | /** |
3 | * Jingga |
4 | * |
5 | * PHP Version 8.1 |
6 | * |
7 | * @package phpOMS\Math\Geometry\Shape\D2 |
8 | * @copyright Dennis Eichhorn |
9 | * @license OMS License 2.0 |
10 | * @version 1.0.0 |
11 | * @link https://jingga.app |
12 | */ |
13 | declare(strict_types=1); |
14 | |
15 | namespace phpOMS\Math\Geometry\Shape\D2; |
16 | |
17 | /** |
18 | * Ellipse shape. |
19 | * |
20 | * @package phpOMS\Math\Geometry\Shape\D2 |
21 | * @license OMS License 2.0 |
22 | * @link https://jingga.app |
23 | * @since 1.0.0 |
24 | */ |
25 | final class Ellipse implements D2ShapeInterface |
26 | { |
27 | /** |
28 | * Area |
29 | * |
30 | * | |
31 | * b |
32 | * -------a-|---- |
33 | * | |
34 | * |
35 | * @param float $a Axis |
36 | * @param float $b Axis |
37 | * |
38 | * @return float Distance between points in meter |
39 | * |
40 | * @since 1.0.0 |
41 | */ |
42 | public static function getSurface(float $a, float $b) : float |
43 | { |
44 | return \M_PI * $a * $b; |
45 | } |
46 | |
47 | /** |
48 | * Circumference |
49 | * |
50 | * | |
51 | * b |
52 | * -------a-|---- |
53 | * | |
54 | * |
55 | * @param float $a Axis |
56 | * @param float $b Axis |
57 | * |
58 | * @return float Distance between points in meter |
59 | * |
60 | * @since 1.0.0 |
61 | */ |
62 | public static function getPerimeter(float $a, float $b) : float |
63 | { |
64 | return \M_PI * ($a + $b) * (3 * ($a - $b) ** 2 / (($a + $b) ** 2 * (\sqrt(-3 * ($a - $b) ** 2 / (($a + $b) ** 2) + 4) + 10)) + 1); |
65 | } |
66 | } |