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