TheWaveLad
TheWaveLad

Reputation: 1016

Python Numpy: Radians to degrees in [0,360]

When applying rad2degI get

>>> np.rad2deg(4*np.pi)
720.0

An angle of 720.0 degrees is in many application equivalent to an angle of 360.0 degrees.

What's the best way to convert radians (from dtype=float64) into degrees where the result is the correct value in [0,180]?

Upvotes: 1

Views: 3535

Answers (2)

Alexander Jansing
Alexander Jansing

Reputation: 89

If you want [0,n] Use

np.rad2deg(4*np.pi)%n

Upvotes: 2

heltonbiker
heltonbiker

Reputation: 27575

Apply modulo division:

result = converted % 360

Upvotes: 7

Related Questions