Hello. We need to find a point that is located at a distance a from point A and from point B at a distance b.

I understand that you must first enter the data (A, a, B, b). But I don’t know what to do next.

I have just started. Wrote data entry

(defun fnc() (setq A (getpoint "Enter A(dot):")) (setq a (getdist A "Enter a(dist):")) (setq B (getpoint "Enter B(dot):")) (setq b (getpoint B "Enter b(dist):")) ) 

Can someone tell me what to do next?

    2 answers 2

    At its core, the task is to find the points of intersection of two circles: with center at point A and radius a and with center at point B and radius b . Such points can be 0, 1 or 2.

    The math needed to solve can be found here or here .

    • Stupid question, of course, but how to take the values ​​x and y from the variable assigned via getpoint? - Desmond Fox
    • Honestly, this is the first time I've come across AutoLISP, but I’m good at Google. There, in fact, there may be three coordinates. Documentation: knowledge.autodesk.com/search-result/caas/CloudHelp/cloudhelp/… - Uladzimirkh Palekh
    • Yes, I myself very briefly in Autolisp, forced to learn at the university. About your link. There is only a list option, and I need from getpoint, as the point should be entered in an interactive mode. There, in fact, the three coordinates when entered via getpoint is formed (xyz), but I can not output x / y separately. - Desmond Fox
    • This is Lisp, there everything is lists, including the result of the getpoint . Under the link there is information how to receive X , Y and Z components. - Uladzimir Palekh
    • Oh, I get it. In AutoLisp, the register of variables is not important. Elementary. Oh, those habits from C-like languages. I just overwritten the variable. Now I can focus on solving the problem. - Desmond Fox

    Tux, sort of solved the puzzle. I deduce only one point, since this is on assignment. Decided by this method.

     (defun fnc() (setq A (getpoint "\nEnter A(dot):"))(princ A) (setq ah (getdist A "\nEnter a(dist):"))(princ ah) (command "_circle" (list (car A)(cadr A)) ah) ; Для удобства нарисуем окружности (setq B (getpoint "\nEnter B(dot):"))(princ B) (setq bh (getdist B "\nEnter b(dist):"))(princ bh) (command "_circle" (list (car B)(cadr B)) bh) ; Определим флаг (setq s -1) ; Вычислим расстояние между центрами окружностей (setq d (expt (+ (expt (- (car B) (car A)) 2) (expt (- (cadr B) (cadr A)) 2)) 0.5)) (if (> d (+ ah bh)) (progn (print "Решений ноль. Окружности не пересекаются") (setq s 0))) (if (< d (- ah bh)) (progn (print "Решений ноль. Одна окружность внутри второй") (setq s 0))) ; если решение есть, то... (if (not (= s 0)) (progn (setq aa (/ (+ (- (expt ah 2) (expt bh 2)) (expt d 2)) (* 2.0 d))) (setq h (expt (- (expt ah 2) (expt aa 2)) 0.5)) ; Вычислим точку (setq x2 (+ (car A) (/ (* aa (- (car B) (car A))) d))) (setq y2 (+ (cadr A) (/ (* aa (- (cadr B) (cadr A))) d))) (setq x3 (+ x2 (/ (* h (- (cadr B) (cadr A))) d))) (setq y3 (+ y2 (- (/ (* h (- (car B) (car A))) d)))) (print "X = ")(princ x3) (print "Y = ")(princ y3) (command "_circle" (list x3 y3) 0.5))) ) 

    The code is damp, but it works. Maybe someone will need it.