Mapping   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 28
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getCoordinates() 0 5 1
A getFaces() 0 3 1
A getPosition() 0 6 1
1
<?php
2
3
namespace AmaTeam\Image\Projection\Type\Equirectangular;
4
5
use AmaTeam\Image\Projection\Type\AbstractValidatingMapping;
6
7
/**
8
 * This class maps coordinates to points and vice versa.
9
 */
10
class Mapping extends AbstractValidatingMapping
11
{
12
    /**
13
     * @inheritDoc
14
     */
15
    public function getPosition($latitude, $longitude)
16
    {
17
        return [
18
            self::DEFAULT_FACE,
19
            ($longitude + self::PI) / self::DOUBLE_PI,
20
            (self::PI - ($latitude + self::PI_HALF)) / self::PI
21
        ];
22
    }
23
24
    /**
25
     * @inheritDoc
26
     */
27
    public function getCoordinates($face, $u, $v)
28
    {
29
        return [
30
            self::PI_HALF - ($v * self::PI),
31
            $u * self::DOUBLE_PI - self::PI
32
        ];
33
    }
34
35
    public function getFaces()
36
    {
37
        return [self::DEFAULT_FACE];
38
    }
39
}
40