作者sjgau (sjgau)
看板Cad_Cae
标题Re: 在 AutoCAD 里面画 函数图形,并且求出函数的极植
时间Mon May 4 08:19:21 2009
; file name: d:\plot-fx.lsp
; plot y= f(x) 的函数图形
; x= x1 to x2 step dx do ...
; dx= (x2 - x1)/no
; no= ???, 以下为设定 32个等分
(setq no 32)
; 以下为设定 x1, x2, dx= ???
(setq x1 (- 1.0 2.0) x2 (+ 1.0 2.0))
(setq dx (/ (- x2 x1) no))
; 为了避免浮点数的运算误差,导致最後一个点被忽略,
; 必须把 x2 往外面推出去 一点点
; x2= x2 + 0.1*dx
(setq x2 (+ x2 (* 0.1 dx)))
(command "spline")
; for x= x1 to x2 step dx do ...
(setq x x1)
(while (<= x x2)
; plot y= fx(x) 的函数图形
(setq y (+ (* x x) (* -2.0 x) -1.0))
(command (list x y))
(setq x (+ x dx))
); end while
(command "" "" "")
(princ)
; end of file
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 118.231.67.192
2F:→ sjgau:画出来的图形,如上面的 连结 05/04 08:23