作者sjgau (sjgau)
看板Cad_Cae
标题分享一个 好玩的 AutoCAD LISP 程式
时间Tue May 13 12:12:22 2008
用来模拟 产生圆的内摆线
小圆套在 大圆的里面旋转。
r3 是笔的位置,距离小圆 圆心的距离。
转动的圈数,可以是 0.5圈。
每转动 绕大圆一圈 所产生的曲线,要分成几个 直线段。
分的段数越多,越平滑。
有输入资料的范例可以参考
; file: flower.lsp
(defun c:flower( / )
(setq r1 (getreal "\n 请输入 大圆半径(ex.: 50)"))
(setq r2 (getreal "\n 请输入 小圆半径(ex.: 16.6667)"))
(setq r3 (getreal "\n 请输入 笔的偏心距离(ex.: 20)"))
(setq no (getreal "\n 请输入 转动的圈数(ex.: 1.0)"))
(setq n1 (getreal "\n 请输入 每一圈的 step 数目(ex.: 100)"))
(setq r1a (- r1 r2)
t1 (* no (* 2.0 pi))
dt (/ (* 2.0 pi) n1))
; for t2= 0.0 to t1 step dt do ...
(setq t2 0.0)
(command "pline")
(while (<= t2 (+ t1 (* 0.1 dt)))
;
(setq s (* r1 t2))
(setq t3 (* -1.0 (/ s r2)))
(setq x1 (* r1a (cos t2))
y1 (* r1a (sin t2)))
(setq x2 (* r3 (cos t3))
y2 (* r3 (sin t3)))
(setq x3 (+ x2 x1)
y3 (+ y2 y1))
; (command "point" (list x3 y3))
(command (list x3 y3))
(setq t2 (+ t2 dt))
); end of while
(command "")
(princ)
); end of flower()
; end of file
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 118.231.54.130
1F:→ sjgau:有人跟我建议,一开始的角度可以控制的话,会更好玩。 05/13 12:13
2F:推 zerod:推s大 05/13 14:32
3F:→ sjgau:不好意思,好像是 没有什麽用处的 玩意儿 05/13 15:26