作者sjgau (sjgau)
看板Cad_Cae
标题Re: 叫AutoCAD画sin- 函数图形的程式
时间Fri Aug 29 11:15:16 2008
这次,是叫 AutoCAD 自动画 极座标函数的图形
※ 引述《sjgau (sjgau)》之铭言:
: 叫 AutoCAD 自动画 y= sin(x) 函数图形的程式,
: 你可以改 no, x1, x2
: 你也可以改 sin(x) --> 变成你 想要的任何函数,
: 如果你不会改,我可以免费帮你。
: 如果你想要学 AutoLISP 程式设计,
: 我可以免费 教你。
: 透过 e-mail 或是 meeting 教你
: e-mail: [email protected]
; file name: d:\plot-hart.lsp
; plot r= G(th) 的极座标函数图形
; for th= t1 to t2 step dt do ...
; dt= (t2 - t1)/no
; no= ???, 以下为设定 32个等分点
(setq no 32)
; 以下为设定 t1, t2, dt= ???
(setq t1 0 t2 (* 2.0 pi))
(setq dt (/ (- t2 t1) no))
; 为了避免浮点数的运算误差,导致最後一个点被忽略,
; 必须把 t2 往外面推出去 一点点
; t2= t2 + 0.1*dt
(setq t2 (+ t2 (* 0.1 dt)))
(command "spline")
; for th= t1 to t2 step dt do ...
(setq th t1 a 1.0)
(while (<= th t2)
; plot r= G(th) 的极座标函数图形
(setq r (* 2.0 a (+ 1.0 (cos th))))
(setq x (* r (cos th)))
(setq y (* r (sin th)))
(command (list x y))
(setq th (+ th dt))
); end while
(command "" "" "")
(princ)
; end of file
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 118.231.132.140
1F:推 Egriawei:喔喔这个好,拜收回去研究<(_ _)> 08/31 13:12