About Angular Conversion (AutoLISP)

Angular values returned by most AutoLISP functions and those stored in a drawing are expressed in radians, while angular input is commonly provided in degrees or another angular format than radians.

You can convert angular values directly with a combination of math functions, or use the angtos and angtof functions. The angtos function converts an angular value expressed in radians to degrees or one of the other supported angular formats. This function returns a string value. If you need a real (or floating point) value, you can use the atof function to convert the string value that is returned by angtos.

(setq half-PI (/ PI 2))
1.5708

(setq angstr (angtos half-PI 0 2))
"90.00"

(setq deg (atof angstr))
90.0

The angtof function is the opposite of angtos, it converts a string representing an angular value into a real (or floating point) value in radians.

(setq angstr (angtos 1.5708 1 6))
"90d0'0.76\""

(setq rad (angtof angstr 1))
1.5708

Converting Radians to Degrees and Degrees to Radians with Math Functions

A more efficient method way to convert radians to degrees and degrees to radians than using the angtos and angtof functions is to use math functions.

The math formula to convert radians to degrees is:

(Radians / PI) * 180 = Degrees

In AutoLISP, the same can be achieved using the following function:

; Convert value in radians to degrees
(defun Radian->Degrees (nbrOfRadians)
  (* 180.0 (/ nbrOfRadians pi))
)
RADIAN->DEGREES

(Radian->Degrees PI)
180.0

The math formula to convert degrees to radians is:

(Degrees / 180) * PI = Degrees

In AutoLISP, the same can be achieved using the following function:

; Convert value in degrees to radians
(defun Degrees->Radians (numberOfDegrees)
  (* pi (/ numberOfDegrees 180.0))
)
DEGREES->RADIANS

(Degrees->Radians 180.0)
3.14159