作者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