TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Mark on April 24, 2004, 12:45:36 PM
-
All comments, questions welcome. :roll:
(defun dms->deg (num / d m s)
(setq d (fix num)
m (fix (* (- num (fix num)) 100))
s (* (rem (* (- num (fix num)) 100) 1.0) 100)
)
(+ d (/ (+ (/ s 60) m) 60))
)
-
There is probably a more elegant of doing this but.
(defun deg->dms (num)
(setq d (fix num)
m (fix (* (- num (fix num)) 60))
s (atoi (rtos (* (rem (* (- num (fix num)) 60) 1) 60) 2 0))
)
(if (< m 10)
(setq m (strcat "0" (itoa m)))
(setq m (itoa m))
)
(if (< s 10)
(setq s (strcat "0" (itoa s)))
(setq s (itoa s))
)
(atof (strcat (itoa d) "." m s))
)
-
could it be done just with ANGTOS and ANGTOF back and forth
Guess you have
(setq ang "180d0'25\"")
(Setq angr (angtof ang))
(setq ang-deg (angtos angr 0 5))
Given the ang in d m s
you get ang in d.xxxxx
(SETQ ang-dec 60.2556)
(setq $ang-dec (rtos ang-dec))
(setq angrr (angtof $ang-dec))
(setq ang-dms (angtos angrr 1 4))
And given the ang as d.xxx you get D M S
-
Good idea DEVITG