(defun c:test
( / *error* acn arc ard ccn cir crd grr int pt1 pt2 vec
)
(setq arc
(LM:selectifobject
"\nSelect arc: " "ARC" )) (setq cir
(LM:selectifobject
"\nSelect circle: " "CIRCLE")) )
)
int
(LM:inters
-line
-circle pt2
(mapcar '
+ pt2
(list (- (cadr vec
)) (car vec
))) ccn crd
) )
)
)
)
)
)
)
;; Select if Object - Lee Mac
;; Continuously prompts the user for a selection of a specific object type
(defun LM:selectifobject
( msg typ
/ ent
) (princ "\nMissed, try again.") )
(princ "\nInvalid object selected.") )
)
)
)
ent
)
;; Line-Circle Intersection (vector version) - Lee Mac
;; Returns the point(s) of intersection between an infinite line defined by
;; points p,q and circle with centre c and radius r
(defun LM:inters
-line
-circle
( p q c r
/ v s
) )
(quad (vxv v v) (* 2 (vxv v s)) (- (vxv s s) (* r r)))
)
)
;; Quadratic Solution - Lee Mac
;; Args: a,b,c - coefficients of ax^2 + bx + c = 0
(defun quad
( a b c
/ d r
) ( (equal 0.0 (setq d
(- (* b b
) (* 4.0 a c
))) 1e
-8
) )
( (< 0 d)
(list (/ (- r b
) (* 2.0 a
)) (/ (- (- b
) r
) (* 2.0 a
))) )
)
)
;; Vector x Scalar - Lee Mac
;; Args: v - vector in R^n, s - real scalar
)
;; Vector Dot Product - Lee Mac
;; Args: u,v - vectors in R^n
)