Re: 叫AutoCAD畫sin- 函數圖形的程式

看板Cad_Cae (電腦輔助設計)作者 (人生苦短)時間19年前 (2005/10/17 08:36), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/5 (看更多)
※ 引述《sjgau (sjgau)》之銘言: 我也來貼我的sine 不過好像可以直接用sin比較快喔.... (defun c:pt ( / ip p1 p2 l n w1 w2 w3 i x y y1 c k) (graphscr) (setq ip (getpoint "\n Input insertion point ip=")) (setq l (getdist "\n Input beam's length l=")) (setq n (getdist "\n Input how many points to draw:")) (setq w1 (getdist "\n Input the sine frequency w1:")) (setq k (getdist "\n Input the manitude:")) (setq i (/ l n)) (setq p1 ip) (setq x (car ip)) (while (<= x (+ l (car ip))) (setq y (sin (* w1 x))) (setq y (* k y)) (setq p2 (list x y)) (command "line" p1 p2 "") (setq p1 p2) (setq x (+ x i)) ) (redraw) (princ) ) : ; for theta=0 to 360 step dt do : (setq no 100) : (setq theta 0.0 dt (/ 360.0 no)) : (setq dt (+ dt (/ dt 10.0))) : (setvar "cmdEcho" 0) : (command "pline") : (while (<= theta 360.0) : (setq t1 (* (/ theta 180.0) pi)) : (setq y1 (sin t1)) : (command (list t1 y1)) : (setq theta (+ theta dt)) : ); end of while() : (command "") : (princ) -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 220.133.60.47
文章代碼(AID): #13Kl834j (Cad_Cae)
文章代碼(AID): #13Kl834j (Cad_Cae)