An example,
;; 3-Point grvecs Arc - Lee Mac
;; Example to display a 3-Point Arc using grvecs
(defun c:grarc ( / _grarc p1 p2 p3 lst )
(defun _grarc ( sa ea / in pl )
(setq in (/ (rem (+ pi pi (- ea sa)) (+ pi pi)) 25.0))
(repeat 26
(setq pl (cons (polar '(0.0 0.0) sa 1.0) pl)
sa (+ sa in)
)
)
(apply 'append (mapcar 'list pl (cdr pl)))
)
(if
(and
(setq p1 (getpoint "\nPick 1st Point: "))
(setq p2 (getpoint "\nPick 2nd Point: "))
(setq p1 (trans p1 1 0)
p2 (trans p2 1 0)
)
)
(while (= 5 (car (setq p3 (grread nil 13 0))))
(redraw)
(if (setq lst (LM:3PArc p1 p2 (trans (cadr p3) 1 0)))
(grvecs (cons -3 (_grarc (cadr lst) (caddr lst)))
(list
(list (cadddr lst) 0.0 0.0 (caar lst))
(list 0.0 (cadddr lst) 0.0 (cadar lst))
(list 0.0 0.0 (cadddr lst) 0.0)
(list 0.0 0.0 0.0 1.0)
)
)
)
)
)
(redraw) (princ)
)
;; 3-Point Arc - Lee Mac
;; Returns the Center, Start/End Angle and Radius of the
;; Arc defined by three supplied points.
(defun LM:3PArc ( p1 p2 p3 / cn m1 m2 )
(setq m1 (mid p1 p2)
m2 (mid p2 p3)
)
(if
(setq cn
(inters
m1 (polar m1 (+ (angle p1 p2) (/ pi 2.)) 1.0)
m2 (polar m2 (+ (angle p2 p3) (/ pi 2.)) 1.0)
nil
)
)
(append (list cn)
(if (LM:Clockwise-p p1 p2 p3)
(list (angle cn p3) (angle cn p1))
(list (angle cn p1) (angle cn p3))
)
(list (distance cn p1))
)
)
)
;; Midpoint - Lee Mac
;; Returns the midpoint of two points
(defun mid ( a b )
(mapcar (function (lambda ( a b ) (/ (+ a b) 2.0))) a b)
)
;; Clockwise-p - Lee Mac
;; Returns T if p1,p2,p3 are clockwise oriented
(defun LM:Clockwise-p ( p1 p2 p3 )
(< (* (- (car p2) (car p1)) (- (cadr p3) (cadr p1)))
(* (- (cadr p2) (cadr p1)) (- (car p3) (car p1)))
)
)
Some more examples:
http://lee-mac.com/3pointarccircle.html