给定输入一个曲线图元curve(*LINE,ARC均可)和两个点pp1、pp2,
假设过两点的线段与曲线有交点,大佬有没有什么好的办法计算出交点?
附一个我现有的方案:
弊端:需要创建一个LINE图元
- (defun lineinsect(curve pp1 pp2 / obj1 obj2 objen intp xintp closedpoint)
- ;closedpoint返回计算在点列表pbll中距离点pa最近的点
- (defun closedpoint(pa pbll / padistlst cx)
- (setq padistlst(mapcar'(lambda(cx)(distance pa cx))pbll))
- (nth (car(HG::LIST::INDEX (HG::LIST::MIN padistlst)padistlst)) pbll)
- )
-
- (setq obj1(vlax-ename->vla-object curve))
- ;创建pp1、pp2为起点终点的LINE
- (setq objen(HG::ACT::PUT_ENAME "LINE" (LIST (trans2wcs pp1) (trans2wcs pp2))))
- (setq obj2(vlax-ename->vla-object objen))
- (setq intp(vla-intersectwith obj1 obj2 acExtendNone))
- (ENTDEL objen)
- (setq xintp(vlax-safearray->list (vlax-variant-value intp)))
- (if(> (length xintp)3)
- (trans2ucs(closedpoint pp1 (HG::LIST::DIVIDE3 xintp)));辅助函数HG::LIST::DIVIDE3将列表三三分割
- (trans2ucs xintp);辅助函数trans2ucs将点转化为UCS坐标系
- )
- )
|