0 Members and 2 Guests are viewing this topic.
(MakeReadable (* -1 pi)) => 0.0(MakeReadable (* -3 pi)) => -3.14159(LM:READABLE (* -1 pi)) => 0.0(LM:READABLE (* -3 pi)) -3.14159
Similar: http://www.theswamp.org/index.php?topic=47220.0Small issue: both functions proposed here do not work properly if the input is smaller than -2*pi.Code: [Select](MakeReadable (* -1 pi)) => 0.0(MakeReadable (* -3 pi)) => -3.14159(LM:READABLE (* -1 pi)) => 0.0(LM:READABLE (* -3 pi)) -3.14159
(defun MakeReadable (a) (if (minusp (setq a (rem a (+ pi pi)))) (setq a (+ a pi pi))) (rem (if (< (* pi 0.5) a (* pi 1.5))(+ a pi) a) (+ pi pi)) )
Quote from: roy_043 on February 22, 2015, 06:48:48 AMSimilar: http://www.theswamp.org/index.php?topic=47220.0Small issue: both functions proposed here do not work properly if the input is smaller than -2*pi.Code: [Select](MakeReadable (* -1 pi)) => 0.0(MakeReadable (* -3 pi)) => -3.14159(LM:READABLE (* -1 pi)) => 0.0(LM:READABLE (* -3 pi)) -3.14159Thanks roy - a possible correction:Code - Auto/Visual Lisp: [Select];; Readable - Lee Mac;; Returns an angle corrected for text readability. (defun LM:readable ( a ) ( (lambda ( a ) (if (< a 0.0) (LM:readable a) (if (and (< (* pi 0.5) a) (<= a (* pi 1.5))) (LM:readable (+ a pi)) a ) ) ) (rem (+ a pi pi) (+ pi pi)) ))
Hi LeeI tested its corrected function.She worked well with the angles that I informed:(LM: readable (angle p1 p2)) or (LM: readable (angle p2 p1)) -> Returns the correct angleThanks