Bisector orientation

Bisector orientation

carlos_m_gil_p
Advocate Advocate
415 Views
4 Replies
Message 1 of 5

Bisector orientation

carlos_m_gil_p
Advocate
Advocate

Hello guys, how have you been?
I wanted to see if you can help me with this.
I am trying to draw a line on the bisector between three points.
Int - First point I always select (Intersection)
P1 and P2 - They have no order when selecting them (Direction of angles)
The problem is that sometimes it is drawn correctly and other times in the opposite direction and I don't know how to guide how the new line is drawn.
I attach how I am doing it and I am also going to attach a dwg file so that you can understand me better.
Or I don't know if anyone already has a better routine.

 

(defun c:xxx (/ int p1 p2 direct) 
  (setq int (getpoint))
  (setq p1 (getpoint))
  (setq p2 (getpoint))
  (setq direct (polar int (/ (+ (angle int p1) (angle int p2)) 2.0) 20.0))
  (command "_.line" "_non" int "_non" direct "")
  (princ))

 

Thank you.


AutoCAD 2026
Visual Studio Code 1.99.3
AutoCAD AutoLISP Extension 1.6.3
Windows 10 (64 bits)

0 Likes
Accepted solutions (1)
416 Views
4 Replies
Replies (4)
Message 2 of 5

Kent1Cooper
Consultant
Consultant

You don't show what the wrong result looks like.  But I suspect the issue has to do with the 0° direction falling between the directions to the two points.  For example, if the direction from the intersection to one point is 45° and to the other is -45°, that second direction is really 315°, so the sum is 360°, meaning halfway between is 180°, not the 0° you want.

Kent Cooper, AIA
0 Likes
Message 3 of 5

carlos_m_gil_p
Advocate
Advocate

Hello @Kent1Cooper how are you.
As always, thanks for your help.
I don't understand much about the angles, but anyway, I'm going to attach a dwg with the correct one and what's wrong when I apply the lisp, sorry for not doing it in the previous one.
Thank you.


AutoCAD 2026
Visual Studio Code 1.99.3
AutoCAD AutoLISP Extension 1.6.3
Windows 10 (64 bits)

0 Likes
Message 4 of 5

Kent1Cooper
Consultant
Consultant
Accepted solution

As I suspected, the problem occurs when the two directions you want to split between straddle the 0° direction [dashed blue] from the intersection:

Kent1Cooper_0-1710103204942.png

I think it might be valid to test whether the difference between the two angles is greater than 180°, and if so, reverse the angle argument in the (polar) function [i.e add pi radians to it].  From this:

(defun c:xxx (/ int p1 p2 direct)
  (setq
    int (getpoint)
    p1 (getpoint)
    p2 (getpoint)
    direct
      (polar
        int
        (+
          (/ (+ (angle int p1) (angle int p2)) 2.0)
          (if (> (abs (- (angle int p1) (angle int p2))) pi) pi 0)
        ); +
        20.0
      ); polar
  )
  (command "_.line" "_non" int "_non" direct "")
  (princ)
)

in your sample drawing, using your Polylines and Points, I got the yellow results here at those corners:

Kent1Cooper_1-1710103994696.png

[I have not tested it any more than that.]

Kent Cooper, AIA
Message 5 of 5

carlos_m_gil_p
Advocate
Advocate

Thank you very much brother, for me so far it works very well.
God bless you and fill you with patience to continue helping.
Greetings.


AutoCAD 2026
Visual Studio Code 1.99.3
AutoCAD AutoLISP Extension 1.6.3
Windows 10 (64 bits)

0 Likes