numpy
  1. numpy-rad2deg

rad2deg()

The rad2deg() function in NumPy is used to convert angles from radians to degrees.

Syntax

The syntax for using rad2deg() function is as follows:

numpy.rad2deg(x)

Where x is the angle in radians.

Example

Consider the following example, which converts an angle of pi/2 from radians to degrees using rad2deg() function:

import numpy as np

radian = np.pi / 2
degree = np.rad2deg(radian)

print("Angle in Radian:", radian)
print("Angle in Degree:", degree)

Output:

Angle in Radian: 1.5707963267948966
Angle in Degree: 90.0

Explanation

The rad2deg() function in NumPy takes an angle in radians as input and returns the equivalent angle in degrees. It uses the following formula for the conversion:

angle_in_degrees = angle_in_radians * (180.0 / np.pi)

Use

The rad2deg() function can be used to convert angles in radians to degrees. It is particularly useful when working with trigonometric functions, which often take angles in radians as input.

Important Points

  • The rad2deg() function returns a floating-point number.
  • The input angle in radians may be a scalar value or a NumPy array.
  • The radians to degrees conversion factor used by rad2deg() is 180.0 / np.pi, where np.pi represents the value of pi in radians.

Summary

The rad2deg() function in NumPy is used to convert angles from radians to degrees. It takes an angle in radians as input and returns the equivalent angle in degrees. The function is particularly useful when working with trigonometric functions that take angles in radians as input.

Published on: