PolarLogScale::SetClockwise()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

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 0
cts 3
cp 0
crap 2
rs 10
1
<?php
2
3
/**
4
 * JPGraph v4.0.3
5
 */
6
7
namespace Amenadiel\JpGraph\Graph;
8
9
class PolarLogScale extends LogScale
10
{
11
    private $graph;
12
    public $clockwise = false;
13
14
    public function __construct($aMax, $graph, $aClockwise = false)
15
    {
16
        parent::__construct(0, $aMax, 'x');
17
        $this->graph = $graph;
18
        if ($this->ticks instanceof LogTicks) {
0 ignored issues
show
introduced by
$this->ticks is never a sub-type of Amenadiel\JpGraph\Graph\LogTicks.
Loading history...
19
            $this->ticks->SetLabelLogType(LOGLABELS_MAGNITUDE);
20
        }
21
        $this->clockwise = $aClockwise;
22
    }
23
24
    public function SetClockwise($aFlg)
25
    {
26
        $this->clockwise = $aFlg;
27
    }
28
29
    public function PTranslate($aAngle, $aRad)
30
    {
31
        if ($aRad == 0) {
32
            $aRad = 1;
33
        }
34
35
        $aRad = log10($aRad);
36
        $m    = $this->scale[1];
37
        $w    = $this->graph->img->plotwidth / 2;
38
        $aRad = $aRad / $m * $w;
39
40
        $a = $aAngle / 180 * M_PI;
41
        if ($this->clockwise) {
42
            $a = 2 * M_PI - $a;
43
        }
44
45
        $x = cos($a) * $aRad;
46
        $y = sin($a) * $aRad;
47
48
        $x += $w + $this->graph->img->left_margin; //$this->_Translate(0);
49
        if ($this->graph->iType == POLAR_360) {
50
            $y = ($this->graph->img->top_margin + $this->graph->img->plotheight / 2) - $y;
51
        } else {
52
            $y = ($this->graph->img->top_margin + $this->graph->img->plotheight) - $y;
53
        }
54
55
        return [$x, $y];
56
    }
57
}
58