fix the bug when angle is exactly 180