Osnap交点
我在一个lisp程序中有两条弧,其中一个交点,程序会暂停,以便用户可以选择交点,这很好。但是有没有办法让autolisp找到圆弧的交点,这样我就不必暂停程序并获得外部帮助?谢谢你,迈克 它已经为你写了,看看这个:http://www.lee-mac.com/intersectionfunctions.html
来自@Lee Mac
http://www.cadtutor.net/forum/member.php?16898-李·麦克 非常感谢您的推荐
作为使用ActiveX intersectwith方法的替代方法,以下是一个用于数学计算点的函数:
;; 2-Arc Intersection-Lee Mac
;; Returns the point(s) of intersection between two arcs
;; with centres c1,c2 radii r1,r2, start angles s1,s2 & end angles e1,e2
(defun LM:arc-arc-inters ( c1 r1 s1 e1 c2 r2 s2 e2 )
(cond
( (< e1 s1) (LM:arc-arc-inters c1 r1 s1 (+ e1 pi pi) c2 r2 s2 e2))
( (< e2 s2) (LM:arc-arc-inters c1 r1 s1 e1 c2 r2 s2 (+ e2 pi pi)))
( (vl-remove-if-not
'(lambda ( pt ) (and (<= s1 (angle c1 pt) e1) (<= s2 (angle c2 pt) e2)))
(LM:circle-circle-inters c1 r1 c2 r2)
)
)
)
)
;; 2-Circle Intersection-Lee Mac
;; Returns the point(s) of intersection between two circles
;; with centres c1,c2 and radii r1,r2
(defun LM:circle-circle-inters ( c1 r1 c2 r2 / a d m l x y )
(if (and (<= (setq d (distance c1 c2)) (+ r1 r2))
(<= (abs (- r1 r2)) d)
)
(progn
(if (equal r1 (setq x (/ (- (+ (* r1 r1) (* d d)) (* r2 r2)) (+ d d))) 1e-
(setql(list (list x 0.0 0.0)))
(setqy(sqrt (- (* r1 r1) (* x x)))
l(list (list x y 0.0) (list x (- y) 0.0))
)
)
(setq a (angle c1 c2)
m (list (list (cos a) (- (sin a)) 0) (list (sin a) (cos a) 0) '(0 0 1))
)
(mapcar '(lambda ( v ) (mapcar '+ c1 (mxv m v))) l)
)
)
)
;; Matrix x Vector-Vladimir Nesterovsky
;; Args: m - nxn matrix, v - vector in R^n
(defun mxv ( m v )
(mapcar '(lambda ( r ) (apply '+ (mapcar '* r v))) m)
)
页:
[1]