过曲线上的一点做曲线的垂线
如何做过曲线上一点做曲线的垂线,请教各位大神,是否有函数可以实现。先在此谢过 本帖最后由 自贡黄明儒 于 2014-1-17 08:10 编辑http://bbs.mjtd.com/forum.php?mod=viewthread&tid=95149
http://bbs.mjtd.com/forum.php?mod=viewthread&tid=109038#lastpost arx中有函数getClosestPoint()可以获得垂足点 wxd20130610 发表于 2014-1-16 15:01 static/image/common/back.gif
arx中有函数getClosestPoint()可以获得垂足点
这个函数我知道,那是不在曲线上的点,我现在是在曲线上的点,过这个点做曲线的垂线 求曲线上点的法向点 info:
http://www.bricsys.com/common/support/forumthread.jsp?id=18314
(defun c:perpl (/ from_object from_point first_derivative line_angle loop perp_line grread_result end_point str)
(setvar "CMDECHO" 0)
(setq old_osmode (getvar "osmode"))
(if (and (setq from_object (entsel "\nSelect curve at point to start the perpendicular line."))
; select
(setvar "osmode" 0)
(setq from_point (cadr from_object)) ; get the point part
(setq from_object (car from_object)) ; get the entity part
(setq from_point (vlax-curve-getclosestpointto from_object from_point))
; adjust point to be on the entity
(not (vl-catch-all-error-p
(setq first_derivative (vl-catch-all-apply
'vlax-curve-getFirstDeriv
(list from_object (vlax-curve-getParamAtPoint from_object from_point))
)
)
)
) ; get the first derivative
)
(progn
(entmake (list '(0 . "LINE") (cons 10 from_point) (cons 11 from_point)))
; create initial line
(setq perp_line(entlast) ; store the initial line
line_angle(angle '(0 0 0) first_derivative) ; get the slope
loop T ; loop
)
; (princ "\nSpecify line length: ")
(while (and (setq grread_result (grread T 12 0)) ; control cursor, no error on ESC, normal crosshairs
(/= (car grread_result) 3) ; 3 = point selected
loop ; loop is active
)
(cond
((= (car grread_result) 5) ; mouse action
(setq end_point (polar from_point
(if (minusp (sin (- (angle from_point (cadr grread_result)) line_angle)))
(- line_angle (/ pi 2))
(+ line_angle (/ pi 2))
)
(distance from_point (cadr grread_result))
)
) ; calculate end point
(entmod (subst (cons 11 (trans end_point 1 0)) (assoc 11 (entget perp_line)) (entget perp_line)))
; modify the line
)
)
)
)
)
(setvar "osmode" old_osmode)
(princ)
)
自贡黄明儒 发表于 2014-1-16 11:39 static/image/common/back.gif
http://bbs.mjtd.com/forum.php?mod=viewthread&tid=95149
http://bbs.mjtd.com/forum.php?mod=viewthre ...
我又想到了一个思路,将原来的曲线偏移然后得到一条新的曲线,然后过原来曲线上的点做新曲线上的垂线,然后把新曲线删除。这样就找到了过曲线上一点做曲线的垂线,并且可以通过偏移的大小和方向控制垂线的长度和方向。能不能再创建这条新曲线的时候同时将它设置成为不可见,系统变量是什么呢? 自贡黄明儒 发表于 2014-1-16 11:39 static/image/common/back.gif
http://bbs.mjtd.com/forum.php?mod=viewthread&tid=95149
http://bbs.mjtd.com/forum.php?mod=viewthre ...
我查了下系统变量没有找到控制对象可见性的系统变量,那就只能将新曲线的颜色用chprop改成纯黑,这样就看不见了,但是这种方法实在不好 vlax-curve-getFirstDeriv
可以得到切线,转90度就是法线了。 自贡黄明儒 发表于 2014-1-24 11:26 static/image/common/back.gif
vlax-curve-getFirstDeriv
可以得到切线,转90度就是法线了。
试了下我的思路,在转角处附近就不行了,看来这种思路还是不可行
页:
[1]
2