In this article, we will discuss how to convert array elements consisting of different angles as radian to degree.
To convert an angle from radians to degrees we need to simply multiply the radians by 180°/Π?. We can also use the
numpy.rad2deg() method to perform the same operation.
Now suppose we have an array containing angles in radian now our task is to convert that array into elements containing element in degree.
Example :
Input : [Π, Π/4, Π/2, 3Π/2, 2Π)
Output : [180. 45. 90. 270. 360.]
Now let us try to implement this using Python:
Example 1 : We will be using the
numpy.pi attribute for Π.
Output :
The angles in radian
[3.14159265 0.78539816 1.57079633 4.71238898 6.28318531]
The angles in degree
[180. 45. 90. 270. 360.]
Example 2 : This time the conversion will be performed without using the inbuilt method.
Output :
The angles in radian
[3.14159265 0.78539816 1.57079633 4.71238898 6.28318531]
The angles in degree
[180.0, 45.0, 90.0, 270.0, 360.0]