現在要進入錐面上的軸向孔與錐面相交所形成的輪廓曲線,為了觀看容易,本文就靶軸向孔改成軸向圓柱並加大圓柱直徑,以方便觀察兩者相交所形成的輪廓曲線。
在寫AutoLISP之前,要先瞭解這交線的性質,下圖所示的是一個圓錐面與一軸向圓柱相交,在圓柱之上,畫出圓柱的上視圖--為一個圓形,此圓與底下那個相交輪廓的X及Y軸的座標是一樣的,所不同的是Z軸座標而已,故只要求出相交輪廓的Z軸座標,就可以畫出相交輪廓。
相交輪廓的Z軸座標求法:
假設錐面的上頂面半徑為r1,底面半徑為r2,高度是h1
1. x2 = c1 + r3*cos( b ), y2 = r3*sin( b )2. L = sqrt( x2*x2 + y2*y2);
3. S2 = L*tan( a) = L * ( h1/(r2-r1) )
4. S1 = r1*tan( a) = r1 * ( h1/(r2-r1) )
5. z2 = S2 - S1
AuotLISP的寫法:
(defun c:bt()
(command "color" "bylayer" "")
(setq r1 0 r2 0 h1 0 )
(setq r1 (/ (getreal "Enter the top diameter : \n") 2 ))
(setq r2 (/ (getreal "Enter the bottom diameter : \n") 2 ))
(setq h1 (getreal "Enter the height : \n"))
(setq r3 (/ (getreal "Enter the diameter of the hole : \n") 2 ))
(setq x2 0 y2 0 x22 0 y22 0 )
(setq i1 1 cta (/ 3.1415926 180.0) ctaWk 0 h1 (* -1 (abs h1)) )
(while (< i1 361)
(setq ctaWk (* cta i1))
(setq x2 (* r1 (cos ctaWk)) y2 (* r1 (sin ctaWk )) )
(setq x22 (* r2 (cos ctaWk)) y22 (* r2 (sin ctaWk )) )
(command "line" (list x2 y2 0) (list x22 y22 h1) "" )
(setq i1 (+ 1 i1))
)
(command "zoom" "e" "")
(command "vpoint" "1,-1,1" "")
(setq delR (- r2 r1) z2 0 x1 0 y1 0 x2 0 y2 0 x22 0 y22 0 )
(setq c1 (/ (+ r1 r2) 2) s1 (/ (* r1 h1) delR) )
(setq tanValue (/ h1 delR ))
(setq i1 0 ctaWk 0 )
(command "color" "red" "")
(while (< i1 361)
(setq ctaWk (* cta i1))
(setq x2 (+ c1 (* r3 (cos ctaWk))) y2 (+ 0 (* r3 (sin ctaWk))) )
(setq z2 (- (* (sqrt (+ (* x2 x2) (* y2 y2))) tanValue) s1))
(if (> i1 0 )
(progn
(command "color" "red" "")
(command "line" (list x1 y1 z1) (list x2 y2 z2) "" )
(command "line" (list x1 y1 10) (list x2 y2 10) "" )
(if (= (rem i1 6 ) 0 )
(progn
(command "color" "green" "")
(command "line" (list x2 y2 10) (list x2 y2 z2) "" ) ))))
(setq x1 x2 y1 y2 z1 z2)
(setq i1 (+ 1 i1))
)
)
AuotLISP的啟動結果:
在輸入(r1=)10 (r2=)30 (h1=)5 (r3=)8等數值後,便得可到下圖 :
看起來不大像洋芋片,重新輸入別的數值看看 : (r1=)10 (r2=)40 (h1=)25 (r3=)12等數值後,又得可到下圖 :
嗯,倒是有像瓜子了,這個瓜子輪廓如何倒角呢 ? 請待下文分曉了
http://tw.myblog.yahoo.com/cu01joe/article?mid=1970&prev=1997&next=1960
留言
張貼留言