AutoCAD visual lisp实例:函数绘制
1(defun c:mysin ()
2 (setq x 0
3 dx (/ pi 100)
4 )
5 (setq y 0)
6 (command "line")
7
8 (while (<= x (* 2 pi))
9 (setq y (sin x))
10 (command (list x y))
11
12 (setq x (+ x dx))
13 )
14
15 (command "")
16 (command "line"
17 (list 0 0)
18 (list (* 2 pi) 0)
19 ""
20 )
21 (command "line"
22 (list 0 -1)
23 (list 0 1)
24 ""
25 )
26 (command "zoom" "e")
27)
28
2 (setq x 0
3 dx (/ pi 100)
4 )
5 (setq y 0)
6 (command "line")
7
8 (while (<= x (* 2 pi))
9 (setq y (sin x))
10 (command (list x y))
11
12 (setq x (+ x dx))
13 )
14
15 (command "")
16 (command "line"
17 (list 0 0)
18 (list (* 2 pi) 0)
19 ""
20 )
21 (command "line"
22 (list 0 -1)
23 (list 0 1)
24 ""
25 )
26 (command "zoom" "e")
27)
28