-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtransit.php
62 lines (58 loc) · 1.23 KB
/
transit.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
class Transit
{
private $_planet;
public function __construct($planets)
{
$this->_planet = $planets;
}
public function getTransit($p1, $p2)
{
$angle = $this->mod2pi( $this->_planet[$p1]['fulldegree'] - $this->_planet[$p2]['fulldegree'] );
if ( $angle > 180 ) $angle = 360 - $angle;
//return round($angle);
//echo $angle;
return $this->isTransit($angle, $p1, $p2);
}
private function isTransit($angle, $p1, $p2)
{
// Currently only 0, 60, 90, 120 and 180 are acceptable
$orb = 0.1;
/* if($p1 == 'Moon' || $p2 == 'Moon')
{
$orb = 0.2;
}*/
$type = $angle/30;
$dec = $type - (int)$type;
$type = (int)$type;
if( $dec <= $orb )
{
if( $type == 0 || $type == 2 || $type == 3 || $type == 4 || $type == 6)
{
return $type*30;
}
}
else if( $dec >= 1 - $orb )
{
$type = $type + 1;
if( $type == 0 || $type == 2 || $type == 3 || $type == 4 || $type == 6)
{
return $type*30;
}
}
else return NULL;
}
public function mod2pi($angle)
{
$b = $angle/360.0;
$a = 360.0*($b - $this->absFloor($b));
if ($a < 0) $a = 360.0 + $a;
return $a;
}
private function absFloor($val)
{
if ($val >= 0.0) return floor($val);
else return ceil($val);
}
}
?>