Angular Conversion

AutoCAD AutoLISP & Visual LISP

 
Angular Conversion
 
 
 

If your application needs to convert angular values from radians to degrees, you can use the angtos function, which returns a string, and then convert that string into a floating point value with atof.

(setq pt1 '(1 1) pt2 '(1 2))
(setq rad (angle pt1 pt2))
(setq deg (atof (angtos rad 0 2)))         returns    90.0

However, a more efficient method might be to include a Radian->Degrees function in your application. The following code shows this:

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

After this function is defined, you can use the Radian->Degrees function throughout your application, as in

(setq degrees (Radian->Degrees rad))      returns    90.0

You may also need to convert from degrees to radians. The following code shows this:

; Convert value in degrees to radians
(defun Degrees->Radians (numberOfDegrees)
  (* pi (/ numberOfDegrees 180.0))
) ;_ end of defun