作者sjgau (sjgau)
看板Cad_Cae
標題[心得] 叫AutoCAD畫 極座標函數的LISP函數
時間Mon Sep 26 21:46:56 2005
(setvar "cmdecho" 0)
; plot r= G(theta)
; r=a(1-sinθ)
(setq a 2.5)
(setq no (getint "Please input no= "))
(setq t1 (* -1 pi) t2 (* +1 pi)
dt (/ (- t2 t1) no)
t2 (+ t2 (* 0.1 dt)))
; for theta= t1 to t2 step dt do ...
; dt= (t2 - t1)/no
; no= ?
(command "PLINE")
(setq theta t1)
(while (< theta t2)
; // r=a(1-sinθ)
(setq r (* a (- 1.0 (sin theta))))
(setq x (* r (cos theta))
y (* r (sin theta)))
(setq p1 (list x y))
(command p1)
(setq theta (+ theta dt))
)
(command "")
(princ)
只要改 r= G(theta)的那幾行,就可以畫出任何你想要的圖形
no= 100 到 30
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 59.104.48.208
→ sjgau:sorry, no= 100 到 300 為適當,a= ? 調整大小 09/27 08:50
→ sjgau:此為 迪卡爾發現的 心臟線 09/27 08:51