fix a bug caused by c++ math.acos() of 1 or -1