(defun ufb00017 ( u_pc1 ;円1の中心座標 u_r1 ;円1の半径 u_pc2 ;円2の中心座標 u_r2 ;円2の半径 u_eps ;許容誤差 / pntot ;交点座標値 ; nil:交点がないまたは求めることができない ; ((x y) nil) 交点が重解 ; ((x y) (x y)) 2つの交点がある lec nfg xx yy yw pin pot pot1 pot2 ) ;円と円の交点を求める (setq pntot nil) (if (and (> u_r1 u_eps) (> u_r2 u_eps)) (progn (setq xx (- (car u_pc2) (car u_pc1))) (setq yy (- (cadr u_pc2) (cadr u_pc1))) (setq lec (sqrt (+ (* xx xx) (* yy yy)))) (if (and (> lec u_eps) (<= lec (+ u_r1 u_r2 u_eps))) (progn (setq nfg 2) (if (< (- (+ u_r1 u_r2) lec) u_eps) (setq nfg 1) ) (if (< (abs (- (abs (- u_r2 u_r1)) lec)) u_eps) (setq nfg 1) ) (if (= nfg 1) (progn ;交点は1個 (setq xx (/ (+ (- (* u_r1 u_r1) (* u_r2 u_r2)) (* lec lec)) (* 2.0 lec))) (setq yy 0.0) (setq pin (list xx yy 0.0)) (setq pot (ufb00011 u_pc1 u_pc2 pin u_eps)) (if (/= pot nil) (setq pntot (list pot nil)) ) ) (progn ;交点は2個 (setq xx (/ (+ (- (* u_r1 u_r1) (* u_r2 u_r2)) (* lec lec)) (* 2.0 lec))) (setq yw (- (* u_r1 u_r1) (* xx xx))) (if (> yw (- u_eps)) (progn (if (< yw 0.0) (setq yw 0.0) ) (setq yy (sqrt yw)) (setq pin (list xx yy 0.0)) (setq pot1 (ufb00011 u_pc1 u_pc2 pin u_eps)) (setq pin (list xx (- yy) 0.0)) (setq pot2 (ufb00011 u_pc1 u_pc2 pin u_eps)) (if (and (/= pot1 nil) (/= pot2 nil)) (setq pntot (list pot1 pot2)) ) (if (and (/= pot1 nil) (= pot2 nil)) (setq pntot (list pot1 nil)) ) (if (and (= pot1 nil) (/= pot2 nil)) (setq pntot (list pot2 nil)) ) ) ) ) ) ) ) ) ) pntot )