2010年7月2日 星期五

Tree_Column II ( Rhinoscript )

Video inside


video

此次採用RhinoScript來進行樹枝狀的造形
第一代用Grasshopper來製作
This time we use Rhinoscript to create the L-System tree.
We try to use Grasshopper to make the first generation


運用的是Recursive的觀念
像樹枝一般
由一根枝幹延伸兩枝分枝
再延伸兩枝分枝
這樣的方式
所以 1 會生 2
2會生4
以此類推
The concept of this project is "Recursive"
The L-System means to make 1 into 2
2 into 4
etc...
and the function of Recursive
will help us to make this goal


先畫線
畫線完以第一條線的終點為第二條線的起點
向左右具角度的分枝
再做PIPE
PIPE的部分直接在SCRIPT裡面呼叫PIPE指令
並提供PIPE指令兩端點的直徑寬度

Draw a line and use the end point of the first line
as the start point of the second line to make branches
After all, we pipe the lines
by using the "Pipe" command in rhinoscript.
in this way, we could even countrol the radius of
the oppisite side of the pipes 

程式如下:
the program as follow:

Dim A : A = 20 '分枝出去的z方向的轉折 the angle spreading out from the Z-Axis
Call Rhino.EnableRedraw(False)
Call Tree_02(0,0,0,0,0,20,0,4) '主程式 若改4這個數字過大恐跑不動或跑很久
'4 is the number controlling the times you want to branch, don't make it over 4
Call Rhino.EnableRedraw(True)

Sub Tree_02(x1,y1,z1,x2,y2,z2,angle,n)
'主程式及要輸入進去的變數
'第一點位置(x1,y1,z1)第二點位置(x2,y2,z2) 起始的角度angle 做n次Recursive
'The main program, the first point(x1,y1,z1) and the second point(x2,y2,z2)
'and the starting angle(angle) n=times of the recursive

If n > 0 Then
Call Rhino.AddLine(Array(x1,y1,z1),Array(x2,y2,z2)) '畫線 draw lines

 
Dim strcmd '定義字串 define the string command


 'Pipe功能要打的東西 1 還有 0.5可改數字 the string which need for the pipe function
Rhino.Command strcmd '執行Pipe功能 run the pipe function

Dim D
D = Rhino.Distance(Array(x1,y1,z1),Array(x2,y2,z2))
'得到兩點間的距離 get the didtance between 2 point

Dim x3,y3,z3,i,r
'定義第三點及類旋轉的角度r Define the thirs point and the angle of rotate "r"r=90

For i = 1 To 360/r
y3 = y2 + Sin(i*(r/180*pi))*Sin((Angle-A)/180*pi)*D*0.95
x3 = x2 + Cos(i*(r/180*pi))*Sin((Angle-A)/180*pi)*D*0.9
z3 = z2 + Cos((Angle-A)/180*pi)*D*0.95
Call Tree_02(x2,y2,z2,x3,y3,z3,Angle-A,n-1)
Next


strcmd = "pipe " & "sellast 0.5 1 enter enter"
Rhino.Command strcmd


End If
End Sub


紅色字部分為可更改處
若將程式復製貼上至Rhinoscript Edit有問題
請將中文刪除後再貼上
Recursive較為複雜及難以說明
將會在他章補上
the red color numbers are changable



以下圖片中有的A N R即為上面變數之改變
changing the number of A, N, R to
get the result
 

再來是去玩PIPE裡面兩端圓柱直徑大小
Plaing with the radius numbers of pipe 
in the oppisite side  
下粗上細
wide to narrow
下細上粗
narrow to wide
非常粗到非常細
very wide to verry thin

最後試著將其角度加大
下彎至接近地面
產生如Pavilion之形態
trying to change the angle
which control the branches spreading
to the ground
as a Pavilion



沒有留言:

張貼留言