- abs: documentation ( source)
- rad2deg: documentation ( source)
- min: documentation ( source)
- deg2rad: documentation ( source)
<?php
function diff($this, $that){
$diff = abs((deg2rad($this)+M_PI_2)-(deg2rad($that)+M_PI_2));
$diff = min( M_PI_2 - $diff, $diff);
echo rad2deg($diff)
.PHP_EOL;
}
diff(-1,1);//2
diff(-90,90);//180
diff(-179,179);//2