TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: David Bethel on November 24, 2005, 01:27:35 PM
-
Okay, I'm having a brain fade I need to compare 2 angles to see if they are
within 90 degrees. The angles can pass thru the X axis
ie ang1 = 350 degrees & ang2 = 15 degrees ( 25 degree included angle ) so return T
The angles be randomly CW & CCW ( not like an ARCs CCW )
The angles will always be in radians
I'm tring to comapre the current view angle with the previous view angle
;;;loop thru a (while) statement
(setq cva (angle '(0 0) (getvar "VIEWDIR"))
(if (not pva)
(setq pva cva))
;;;if the previous angle and current angle are with 90 degrees then do some more stuff
(setq pva cva); record the previous view angle
;;;Go to the next viewpoint & loop
I need to find if the current view angle changed more than 90 degrees different from the previous one.
TIA -David
-
I think my brain finally kicked back in
(setq a1 0.1)
a2 3.0))
(or (< (abs (- a1 a2)) (* pi 0.5))
(> (abs (- a1 a2)) (* pi 1.5)))
-David
-
Here are some I have collected, source unknown.
;;=====================================================================
;; compute the absolute delta angle between 2 angles a1 & a2
(defun @delta (a1 a2)
(abs ; added to return a positave angle only
(cond
((> a1 (+ a2 pi)) (- (+ a2 pi pi) a1))
((> a2 (+ a1 pi)) (- a2 a1 pi pi))
((- a2 a1))
)
)
)
;;=====================================================================
;; same results as above, except no (abs added
;; compute the delta angle between 2 angles a1 & a2
(defun @delta (a1 a2)
(cond
((> a1 (+ a2 pi)) (setq a2 (+ a2 pi pi)))
((> a2 (+ a1 pi)) (setq a1 (+ a1 pi pi)))
)
(- a2 a1)
)
;;=====================================================================
-
I would guess those came from John Uhden CAB. He uses the @ prefix quite frequently.
-
Yes they are from John.... to bad he does not participate on this type of forums and also that he closed his web site too...
-
Thanks guys, I had clipped them out of some routines & saved them as DeltaAngle.lsp
This was before I started recording the authors.
-
Yep,
Sure enough I had a @delta subr in my collection and it had mention of John Uhden. I told you brain fade.
(defun @delta (a1 a2)
(cond ((> a1 (+ a2 pi))
(- (+ a2 pi pi) a1))
((> a2 (+ a1 pi))
(- a2 a1 pi pi))
((- a2 a1))))
Thanks all. -David
-
I think Jiohn is still around. -David
http://www.cadlantic.com/
-
Thanks.... I tried to get to his web site, several times before.... without luck, great.