Relative Content

Tag Archive for c++angle

Angle wrapping error (mishandling 0, pi, -pi)

I am trying to wrap the angle to be within the range of [-pi, pi]. I have tried many variations of the following code, it should be a very easy task, however, if the angle is already pi, -pi, or 0, it outputs it as negative (so pi = -pi, -pi = pi, 0 = -0).