叫 AutoCAD 自動畫 y= sin(x) 函數圖形的程式

1 view
Skip to first unread message

sjgau02

unread,
Aug 28, 2008, 10:06:29 PM8/28/08
to aw4ntu164
收件者 sjga...@gmail.com
日期 2008/8/29 10:04
主旨 Re: 叫AutoCAD畫sin- 函數圖形的程式

作者: sjgau (sjgau) 看板: Cad_Cae
標題: Re: 叫AutoCAD畫sin- 函數圖形的程式
時間: Fri Aug 29 10:02:27 2008

叫 AutoCAD 自動畫 y= sin(x) 函數圖形的程式,
你可以改 no, x1, x2

你也可以改 sin(x) --> 變成你 想要的任何函數,
如果你不會改,我可以免費幫你。

如果你想要學 AutoLISP 程式設計,
我可以免費 教你。

透過 e-mail 或是 meeting 教你
e-mail: sjga...@gmail.com



; file name: d:\plot-sin.lsp

; plot y= f(x) 的函數圖形
; x= x1 to x2 step dx do ...

; dx= (x2 - x1)/no

; no= ???, 以下為設定 16個等分
(setq no 16)

; 以下為設定 x1, x2, dx= ???
(setq x1 0 x2 pi)
(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= sin(x) 的函數圖形
(setq y (sin x))
(command (list x y))

(setq x (+ x dx))
); end while

(command "" "" "")
(princ)
; end of file



Reply all
Reply to author
Forward
0 new messages