Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
3 / 3
CRAP
100.00% covered (success)
100.00%
1 / 1
RectangularPyramid
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
3 / 3
3
100.00% covered (success)
100.00%
1 / 1
 getVolume
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getSurface
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getLateralSurface
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2/**
3 * Jingga
4 *
5 * PHP Version 8.1
6 *
7 * @package   phpOMS\Math\Geometry\Shape\D3
8 * @copyright Dennis Eichhorn
9 * @license   OMS License 2.0
10 * @version   1.0.0
11 * @link      https://jingga.app
12 */
13declare(strict_types=1);
14
15namespace phpOMS\Math\Geometry\Shape\D3;
16
17/**
18 * Rectangular pyramid shape.
19 *
20 * @package phpOMS\Math\Geometry\Shape\D3
21 * @license OMS License 2.0
22 * @link    https://jingga.app
23 * @since   1.0.0
24 */
25final class RectangularPyramid implements D3ShapeInterface
26{
27    /**
28     * Volume
29     *
30     * @param float $a Edge
31     * @param float $b Edge
32     * @param float $h Height
33     *
34     * @return float
35     *
36     * @since 1.0.0
37     */
38    public static function getVolume(float $a, float $b, float $h) : float
39    {
40        return $a * $b * $h / 3;
41    }
42
43    /**
44     * Surface area
45     *
46     * @param float $a Edge
47     * @param float $b Edge
48     * @param float $h Height
49     *
50     * @return float
51     *
52     * @since 1.0.0
53     */
54    public static function getSurface(float $a, float $b, float $h) : float
55    {
56        return $a * $b + $a * \sqrt(($b / 2) ** 2 + $h ** 2) + $b * \sqrt(($a / 2) ** 2 + $h ** 2);
57    }
58
59    /**
60     * Lateral surface area
61     *
62     * @param float $a Edge
63     * @param float $b Edge
64     * @param float $h Height
65     *
66     * @return float
67     *
68     * @since 1.0.0
69     */
70    public static function getLateralSurface(float $a, float $b, float $h) : float
71    {
72        return $a * \sqrt(($b / 2) ** 2 + $h ** 2) + $b * \sqrt(($a / 2) ** 2 + $h ** 2);
73    }
74}