Adding function to calculate minimal angle-difference.