utility function to calculate head angle