Hi, Lee, funny question~
Is this three points 3d points, or only consider the XY plane situation?
If only a XY question, this is my geometry solution:), and also has some formula solution.(will post later)
if a 3d question, I will solve it by Barycentric Coordinates later.
Function
;;Midpoint of two point
(defun q:geo:mid (p1 p2)
(mapcar '(lambda (x)(/ x 2.))(mapcar '+ p1 p2))
)
;;2d line midnormal
(defun q:geo:line-midnormal(p1 p2 / p)
(list (setq p (q:geo:mid p1 p2)) (polar p (+ (angle p1 p2) (/ pi 2.0)) 1.0))
)
;;2d angle bisector
(defun q:geo:angle-bisector(p1 p2 p3)
(list p1 (polar p1 (/ (+ (angle p1 p2) (angle p1 p3)) 2.0) 1.0))
)
;;2d distance from a point to a line
(defun q:geo:dis-point-to-2dline(p p1 p2)
(distance p (inters p (polar p (+ (angle p1 p2) (/ pi 2.0)) 1.0) p1 p2 nil))
)
;;Find out the incircle of three point (three distinct, noncollinear WCS points)
(defun q:geo:incircle(p1 p2 p3 / l1 l2 p)
(setq l1 (q:geo:line-midnormal p1 p2) l2 (q:geo:line-midnormal p1 p3))
(setq p (inters (car l1) (cadr l1) (car l2) (cadr l2) nil))
(list p (distance p1 p))
)
;;Find out the circumcircle of three point (three distinct, noncollinear WCS points)
(defun q:geo:circumcircle(p1 p2 p3 / l1 l2 p)
(setq l1 (q:geo:angle-bisector p1 p2 p3) l2 (q:geo:angle-bisector p2 p3 p1))
(setq p (inters (car l1) (cadr l1) (car l2) (cadr l2) nil))
(list p (q:geo:dis-point-to-2dline p p1 p2))
)
Test code
;;;;;Test function
(defun c:test(/ p1 p2 p3)
(setq p1 (getpoint) p2 (getpoint) p3 (getpoint))
(q:entmake:point (car (q:geo:incircle p1 p2 p3)) (getvar "clayer"))
(q:entmake:circle (car (q:geo:incircle p1 p2 p3)) (cadr (q:geo:incircle p1 p2 p3)) (getvar "clayer"))
(q:entmake:point (car (q:geo:circumcircle p1 p2 p3)) (getvar "clayer"))
(q:entmake:circle (car (q:geo:circumcircle p1 p2 p3)) (cadr (q:geo:circumcircle p1 p2 p3)) (getvar "clayer"))
)
;;entmake point
(defun q:entmake:point(pt layer)
(entmake (list (cons 0 "POINT")
(cons 8 layer);***
(cons 10 pt) ;***
)
)
)
;;entmake circle
(defun q:entmake:circle (center rad layer)
(entmake (list (cons 0 "CIRCLE") ;***
(cons 6 "BYLAYER") (cons 8 layer) (cons 10 center) ;***
(cons 40 rad) ;***
(cons 39 0.0) (cons 210 (list 0.0 0.0 1.0))
)
)
)