参考http://bbs.mjtd.com/thread-182133-1-1.html,写了一个简化版的垂线代码,其中有一句始终理解不了,所以只要请教各位大佬。- (defun c:cxx (/ a b c cv pt ang ang1 p p2 add *len)
- (setq a vlax-curve-getClosestPointTo b Vlax-curve-getfirstderiv c vlax-curve-getParamAtPoint)
- (setq cv (car (entsel "\n选择曲线 : ")))
- (setq pt (getpoint "\n选择曲线上的点 : "))
- (setq p (getpoint pt "\n选择方向"))
- (setq p2 (a cv (trans p 1 0)))
- (setq ang (angle '(0 0) (b cv (c cv p2))))
- (setq add (- (angle p2 p) ang))
- (setq pt (a cv (trans pt 1 0))
- ang1 (angle '(0 0) (b cv (c cv pt)))
- )
- (cond ((setq *len (getdist (strcat "\n长度 > :"))))
- ((setq *len (distance pt p)))
- )
- (entmake (list '(0 . "LINE")(cons 10 pt)(cons 11 (polar pt (+ ang1 add ) *len))))
- (princ)
- )
其中,(setq ang (angle '(0 0) (b cv (c cv p2)))),这一句怎么理解,这一句理解不了,整个计算过程就理解不了。如果只是针对直线,其实是不需要ang、ang1这段计算的。这句是针对曲线的。
|