Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

so much difference in two angles for a cond function

2 REPLIES 2
Reply
Message 1 of 3
cadking2k5
336 Views, 2 Replies

so much difference in two angles for a cond function

I left part of it out the pt is the point you select so it will not be polar with the endpoints and the intersection always is there a way like (= ang1 ang2) but make it so it can be 0.05 degrees off 

 

(setq obj (entsel "\nSelect object:"))
  (setq pol (car obj))
  (setq pt (cadr obj))

  (setq end1 (cdr (assoc 10 (entget pol))))
  (setq end2 (cdr (assoc 11 (entget pol))))

  (setq int1 (list (car int) (cadr int) (caddr int))) ;intersection 1 of objects
  (setq int2 (cdddr int)) ;intersections 2 of objects

  (setq ang1 (angle pt int1))

  (setq ang2 (angle int1 end1))

 

2 REPLIES 2
Message 2 of 3
Lee_Mac
in reply to: cadking2k5


cadking2k5 wrote:

is there a way like (= ang1 ang2) but make it so it can be 0.05 degrees off


You could use the equal function with an appropriate tolerance, e.g.:

 

(equal ang1 ang2 (* 0.05 (/ pi 180.0)))

 

However, since radians are 2-pi periodic, be careful when the supplied angles are around 0.0; for example, if ang1 = 0.0 and ang2 = 6.282312642553589 these angles are 0.05 degrees apart, however, the above equal expression will return nil. For these cases it may be more appropriate to compare the cosine of the angles to a given tolerance.

 

Lee

 

 

Message 3 of 3
stevor
in reply to: cadking2k5

Accounting for the nearly 2 pi, ie 360 degrees; and for multiples of 360: ; equal angles 360rel (DeFun Eq_Ang ( a b r / k) (setq a (A_Cir a) b (A_Cir b) k (* 2 pi) ) (or (equal a b r) (equal (+ a k) b r) (equal a (+ b k) r))); ed ; angle to 0 to 360 degree interval (DeFun a_cir (a / k) (setq k (* 2 pi)) (while (< a 0) (setq a (+ a k))) ; (while (>= a k) (setq a (- a k))) a )
S

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost