明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 8210|回复: 11

[已解答] 过曲线上的一点做曲线的垂线

[复制链接]
发表于 2014-1-16 11:05:42 | 显示全部楼层 |阅读模式
如何做过曲线上一点做曲线的垂线,请教各位大神,是否有函数可以实现。先在此谢过
发表于 2014-1-16 11:39:08 | 显示全部楼层
发表于 2014-1-16 15:01:06 | 显示全部楼层
arx中有函数getClosestPoint()可以获得垂足点
 楼主| 发表于 2014-1-16 17:13:02 | 显示全部楼层
wxd20130610 发表于 2014-1-16 15:01
arx中有函数getClosestPoint()可以获得垂足点

这个函数我知道,那是不在曲线上的点,我现在是在曲线上的点,过这个点做曲线的垂线
发表于 2014-1-16 23:25:29 | 显示全部楼层
求曲线上点的法向点
发表于 2014-1-17 08:00:47 | 显示全部楼层
info:
http://www.bricsys.com/common/support/forumthread.jsp?id=18314

  1. (defun c:perpl (/ from_object from_point first_derivative line_angle loop perp_line grread_result end_point str)
  2.   (setvar "CMDECHO" 0)
  3.   (setq old_osmode (getvar "osmode"))
  4.   (if (and (setq from_object (entsel "\nSelect curve at point to start the perpendicular line."))
  5.                                                                      ; select
  6.            (setvar "osmode" 0)
  7.            (setq from_point (cadr from_object))                      ; get the point part
  8.            (setq from_object (car from_object))                      ; get the entity part
  9.            (setq from_point (vlax-curve-getclosestpointto from_object from_point))
  10.                                                                      ; adjust point to be on the entity
  11.            (not (vl-catch-all-error-p
  12.                   (setq first_derivative (vl-catch-all-apply
  13.                                 'vlax-curve-getFirstDeriv
  14.                                   (list from_object (vlax-curve-getParamAtPoint from_object from_point))
  15.                               )
  16.                   )
  17.                 )
  18.            )                                                         ; get the first derivative
  19.       )
  20.     (progn
  21.       (entmake (list '(0 . "LINE") (cons 10 from_point) (cons 11 from_point)))
  22.                                                                      ; create initial line
  23.       (setq perp_line  (entlast)                                     ; store the initial line
  24.             line_angle  (angle '(0 0 0) first_derivative)            ; get the slope
  25.             loop T                                                   ; loop
  26.       )
  27. ;      (princ "\nSpecify line length: ")
  28.       (while (and (setq grread_result (grread T 12 0))               ; control cursor, no error on ESC, normal crosshairs
  29.                   (/= (car grread_result) 3)                         ; 3 = point selected
  30.                   loop                                               ; loop is active
  31.              )
  32.         (cond
  33.           ((= (car grread_result) 5)                                 ; mouse action
  34.             (setq end_point (polar from_point
  35.                             (if (minusp (sin (- (angle from_point (cadr grread_result)) line_angle)))
  36.                               (- line_angle (/ pi 2))
  37.                               (+ line_angle (/ pi 2))
  38.                             )
  39.                             (distance from_point (cadr grread_result))
  40.                      )
  41.             )                                                        ; calculate end point
  42.             (entmod (subst (cons 11 (trans end_point 1 0)) (assoc 11 (entget perp_line)) (entget perp_line)))
  43.                                                                      ; modify the line
  44.           )
  45.         )
  46.       )
  47.     )
  48.   )
  49.   (setvar "osmode" old_osmode)
  50.   (princ)
  51. )
 楼主| 发表于 2014-1-24 10:26:16 | 显示全部楼层
自贡黄明儒 发表于 2014-1-16 11:39
http://bbs.mjtd.com/forum.php?mod=viewthread&tid=95149

http://bbs.mjtd.com/forum.php?mod=viewthre ...

我又想到了一个思路,将原来的曲线偏移然后得到一条新的曲线,然后过原来曲线上的点做新曲线上的垂线,然后把新曲线删除。这样就找到了过曲线上一点做曲线的垂线,并且可以通过偏移的大小和方向控制垂线的长度和方向。能不能再创建这条新曲线的时候同时将它设置成为不可见,系统变量是什么呢?

点评

查一下组码,好象是60,  发表于 2014-1-24 11:25
 楼主| 发表于 2014-1-24 10:31:57 | 显示全部楼层
自贡黄明儒 发表于 2014-1-16 11:39
http://bbs.mjtd.com/forum.php?mod=viewthread&tid=95149

http://bbs.mjtd.com/forum.php?mod=viewthre ...

我查了下系统变量没有找到控制对象可见性的系统变量,那就只能将新曲线的颜色用chprop改成纯黑,这样就看不见了,但是这种方法实在不好
发表于 2014-1-24 11:26:56 | 显示全部楼层
vlax-curve-getFirstDeriv
可以得到切线,转90度就是法线了。
 楼主| 发表于 2014-1-24 11:33:17 | 显示全部楼层
自贡黄明儒 发表于 2014-1-24 11:26
vlax-curve-getFirstDeriv
可以得到切线,转90度就是法线了。

试了下我的思路,在转角处附近就不行了,看来这种思路还是不可行
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2025-5-20 15:56 , Processed in 0.193312 second(s), 27 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表