[求助]如何画出圆弧的两个切线
<p></p><p>已知一个多段线的圆弧,如何画出切线部分?(蓝色的两条直线),请高人给出lisp,多谢</p> 正是我想要的,赞一个 <p>给点帮助</p>
<p><font face="Verdana">;;;<br/>;;;选择并计算曲线参数函数DimSelqx<br/>;;;返回值:曲线参数(alfa[弧度] R)<br/>;;;<br/>(defun DimSelqx( / wh ss ssLen i alfa R Ename vdata N p1 p2 bulge alfai XL Ri)</font></p>
<p><font face="Verdana"> (setq wh 1 ss nil)<br/> (while (and (= wh 1) (setq ss (ssget '((0 . "LWPOLYLINE")))) ) <br/> (setq ssLen (sslength ss))<br/> (setq i 0 wh 0 R 0 alfa 0)<br/> (while (and (= wh 0) (< i ssLen))<br/> (setq Ename (ssname ss i))<br/> (setq vdata (entget Ename))<br/> (setq N (length vdata))<br/> (setq p1 (cdr (nth (- N 9) vdata)) ;第一个顶点<br/> p2 (cdr (nth (- N 5) vdata))) ;第二个顶点<br/> (setq bulge (cdr (nth (- N 6) vdata))) ;第一个顶点凸度<br/> (if (/= bulge 0) <br/> (progn (setq alfai (* 4 (atan (abs bulge))) <br/> XL (distance p1 p2) <br/> Ri (ccfix (/ (/ XL 2) (sin (/ alfai 2))) 0)) <br/> (if (and (/= R Ri) (/= i 0))<br/> (progn (redraw Ename 3)<br/> (alert "曲线半径不同,请重新选择!")<br/> (redraw Ename 4)<br/> (setq wh 1)<br/> )<br/> (setq alfa (+ alfai alfa) R Ri)<br/> )<br/> )<br/> (progn (redraw Ename 3)<br/> (alert "虚显的巷道是直线,请重新选择!")<br/> (redraw Ename 4)<br/> (setq wh 1)<br/> )<br/> )<br/> (setq i (1+ i))<br/> )<br/> )<br/> (if (not ss) (exit) )<br/> (setq ss nil)<br/> <br/> (list alfa R)</font></p>
<p><font face="Verdana">);End DimSelqx</font></p> 沉的好快,自己顶顶,有哪位大侠给指点一下啊 <p>求出圆心,然后求出圆心和切点的角度,然后。。。。。出来了吧</p> <p>楼上的,我不会做啊,能给个lisp吗</p> 我这有一个程序,你可试试
;虚拟交点的绘制
(defun C:XNJD (/ p1 p2 p3 p4 p5)
(setvar "cmdecho" 0)
(setq p1 (entsel "\n选取一段圆弧: "))
(if p1
(progn (setq p0 (entget (car p1)))
(setq p1 (cdr (assoc 0 p0)))
)
)
(if (/= p1 "ARC")
(prompt "\n选择的不是圆弧,请再试...")
)
(setq p1 (polar (cdr (assoc 10 p0))
(cdr (assoc 50 p0))
(cdr (assoc 40 p0))
)
p2 (polar (cdr (assoc 10 p0))
(cdr (assoc 51 p0))
(cdr (assoc 40 p0))
)
p3 (polar p1
(+ (/ pi 2) (cdr (assoc 50 p0)))
(cdr (assoc 40 p0))
)
p4 (polar p2
(+ (/ pi 2) (cdr (assoc 51 p0)))
(cdr (assoc 40 p0))
)
p5 (inters p1 p3 p2 p4 nil)
)
(if (not p5)
(prompt "\n没有交点...")
(progn
(if (> (distance p1 p5)
(* 2 (getvar "dimscale") (getvar "dimexo"))
)
(command
"_.line"
(polar p1
(angle p1 p5)
(* (getvar "dimexo") (getvar "dimscale"))
)
(polar p5
(angle p1 p5)
(* (getvar "dimexe") (getvar "dimscale"))
)
""
"_.line"
(polar p2
(angle p2 p5)
(* (getvar "dimexo") (getvar "dimscale"))
)
(polar p5
(angle p2 p5)
(* (getvar "dimexe") (getvar "dimscale"))
)
""
)
(command
"_.line"
(polar p1 (angle p1 p5) (* 0.5 (distance p1 p5)))
(polar p5
(angle p1 p5)
(* (getvar "dimexe") (getvar "dimscale"))
)
""
"_.line"
(polar p2 (angle p2 p5) (* 0.5 (distance p2 p5)))
(polar p5
(angle p2 p5)
(* (getvar "dimexe") (getvar "dimscale"))
)
""
)
)
)
)
(princ)
)
<p>一个偏门的方法:</p>
<p>(command "fillet" "r" 0. "p" 选pl线)</p>
<p> </p> <p>楼上的偏方倒是可以,但是,我要的是另外两条切线,用倒角的话会延长这两条线,而不是画两条新的切线,不过还是非常感谢你哦,这个思路也行,就是通过两条边画这个焦点切线</p> 感谢<font color="#61b713" face="Verdana"><b>xianaihua问题是你的针对是圆弧,我这个是多段线构成的圆弧,怎么样修改一下你的程序呢,还有你的程序实际使用时,圆弧下凸就会有多余的部分,p3点计算出错</b></font> 以上的代码不错啊
页:
[1]
2