Fixed problems with tan(HALF_PI) = -infinity