; the angle between the lines never exceeds 180 degrees
(setq CntPnt '(10. 10. 0.) Pnt001 '(208.14 37.20 0.) Pnt002 '(191.12 -74.84 0.))
Command: (setq Ang001 (angle CntPnt Pnt001)) => 0.136424
Command: (setq Ang002 (angle CntPnt Pnt002)) => 5.84512
Command: (setq Deg090 (/ pi 2.)) => 1.5708
Command: (if (> Ang001 Ang002)
(_> (setq Ang003 (+ Ang001 (/ (- Ang002 Ang001) 2.00)))
(_> (setq Ang003 (+ Ang001 pi (/ (- Ang002 Ang001) 2.00)))
(_> ) => 6.13236
(cond
( (and (>= Ang003 0) (>= Deg090 Ang003)) (list 0 Deg090) )
( (and (>= Ang003 Deg090) (>= pi Ang003)) (list Deg090 pi) )
( (and (>= Ang003 pi) (>= (+ pi Deg090) Ang003)) (list pi (+ pi Deg090)) )
( T (list (+ pi Deg090) 0) )
) => (4.71239 0)
the ultimate goal is to draw a clove in the quadrant more occupied.(defun ALE_Math_OrthoAngles (CntPnt Pnt001 Pnt002 / Ang001 Ang002 Ang003 Deg090)
(setq
Deg090 (/ pi 2.)
Ang001 (angle CntPnt Pnt001)
Ang002 (angle CntPnt Pnt002)
Ang003 (+ Ang001 (/ (- Ang002 Ang001) 2.00))
)
(cond
( (and (>= Ang003 0) (>= Deg090 Ang003)) (cons 0 Deg090) )
( (and (>= Ang003 Deg090) (>= pi Ang003)) (cons Deg090 pi) )
( (and (>= Ang003 pi) (>= (+ pi Deg090) Ang003)) (cons pi (+ pi Deg090)) )
( T (cons (+ pi Deg090) 0) )
)
)
(defun C:Test_OrthoAngles ( / CntPnt Pnt001 Pnt011 Pnt002 Pnt012 OutLst Dst001 Dst002)
(setq
CntPnt (GetPoint "\nC: ")
Pnt001 (GetPoint "\nP: ")
Pnt002 (GetPoint "\nP: ")
Dst001 (distance CntPnt Pnt001)
Dst002 (distance CntPnt Pnt002)
OutLst (ALE_Math_OrthoAngles CntPnt Pnt001 Pnt002)
Pnt011 (polar CntPnt (car OutLst) Dst001)
Pnt012 (polar CntPnt (cdr OutLst) Dst002)
)
(entmake (list '(0 . "CIRCLE") (cons 40 20) (cons 10 Pnt011)))
(entmake (list '(0 . "CIRCLE") (cons 40 20) (cons 10 Pnt012)))
)
The two failures are caused by you not allowing for angles either side of 0.0Thanks. :-) Do you have an idea also for this?
You need something like thisCode - Auto/Visual Lisp: [Select]
(defun ALE_Math_OrthoAngles (CntPnt Pnt001 Pnt002 / Ang001 Ang002 Ang003 AngFlg Deg090 Deg270)
(setq
Deg090 (/ pi 2.)
Deg270 (+ pi Deg090)
Ang001 (angle CntPnt Pnt001)
Ang002 (angle CntPnt Pnt002)
AngFlg (> (abs (- Ang001 Ang002)) pi)
Ang003 (if (> Ang001 Ang002)
(+ (/ (- Ang001 Ang002) 2.) Ang002)
(+ (/ (- Ang002 Ang001) 2.) Ang001)
)
)
(and AngFlg (setq Ang003 (+ Ang003 pi)))
(and (> Ang003 (+ pi pi) (setq Ang003 (rem Ang003 (+ pi pi)))))
(cond
( (and (>= Ang003 0) (>= Deg090 Ang003)) (cons 0 Deg090) )
( (and (>= Ang003 Deg090) (>= pi Ang003)) (cons Deg090 pi) )
( (and (>= Ang003 pi) (>= Deg270 Ang003)) (cons pi Deg270) )
( T (cons Deg270 0) )
)
)
Lines must be in two adjacent quadrants ? Else multi answers.Show me an example. Thanks.
If I understand, this should be what you are looking for. It will return a list of the quadrant angles.I have tried your version, can you tell me in which situations does it return a different result?Code - Lisp: [Select]
....
Which points should be returned for a scenario in which each given point lies equidistant within each quadrant? e.g.:
(http://lee-mac.com/swamp/quad.png)
Which points should be returned for a scenario in which each given point lies equidistant within each quadrant? e.g.:The points returned have no valid logic, they mainly depend on how this is written:
(cond
( (and (>= Ang003 0) (>= Deg090 Ang003)) (cons 0 Deg090) )
( (and (>= Ang003 Deg090) (>= pi Ang003)) (cons Deg090 pi) )
( (and (>= Ang003 pi) (>= Deg270 Ang003)) (cons pi Deg270) )
( T (cons Deg270 0) )
)
Edit: maybe this is better:If I understand, this should be what you are looking for. It will return a list of the quadrant angles.I have tried your version, can you tell me in which situations does it return a different result?Code - Lisp: [Select]
....
Thanks.
Command: (test (getpoint) (getpoint) (getpoint))
(0.0 4.71239)
Command: (test (getpoint) (getpoint) (getpoint))
(4.71239 3.14159)
Command: (test (getpoint) (getpoint) (getpoint))
(0.0 4.71239)
Command: (test (getpoint) (getpoint) (getpoint))
(3.14159 1.5708)
Is that not was is desired, Marc? Did I not understand correctly?Yes that's what I wanted to achieve. What I don't understand is the difference or advantage of your version which is much more complicated.
I don't think mine is very complicated. I test to see which quadrant the point lies, then see if it's greater than the 45 degree line of said quadrant and return the appropriate angle. But for the second angle I make sure that if they are in the same quadrant, you get the second angle of the quadrant so that the same angle is not returned for both. You're welcome. This is a place of learning, so asking why one coded it a certain way is fine. I hope my explanation make sense to you (though it looks like you figured it out before I posted this message).Ok, thanks for the explanation, I have to understand if for my use it is a useful twining. Basically I have to draw an arc in the quadrant where the angle bisector lies (which is always less than 180 degrees). :-)
Assuming I've understood the requirements, here's my suggestion:Thanks Lee, it seem very good for my needs and can be simply:Code - Auto/Visual Lisp: [Select]
) )
A program to test:Code - Auto/Visual Lisp: [Select]
) ) )
Assumes (= (distance c p) (distance c q)) per the images.
(defun foo2 ( c p q / a b)
(setq a (angle '(0 0) (mapcar '+ (mapcar '- p c) (mapcar '- q c)))
b (+ (if (< 0 (sin a)) 0 pi) (if (< 0 (* (sin a) (cos a))) 0 (/ pi 2)))
)
(cons b (+ b (/ pi 2)))
)
Grazie. :-)
Alternatively, just -More succinct than that I think is not possible! 8-) Notte.Code - Auto/Visual Lisp: [Select]