顯示具有 程式 標籤的文章。 顯示所有文章
顯示具有 程式 標籤的文章。 顯示所有文章

2011年1月13日 星期四

flowing rain trace as an adjustable formation



i took a bus the other day. it was raining and freezing in taipei. i looked outside through the window to see the cityscape. to some degree, a bus window is an excellent observing tool to experience the city life and culture. due to the rain fall and the uneven bus roof, so there came a continuing little "river" flowing vertically passing on the window surface. i am so attractive to this tiny urban spectacle, more charming than the taipei 101 fire work at the new year eve, that i was suddenly isolated from the other city events and focused on the changeable water trace i was witnessing. what is more graceful and astonishing is the story the rain and bus scriped together, sharing the same key structure to the generation of animated forms, vivid forms, or the forms with life. from an embryo in a womb to the landscape of earth, from the baking bread in the oven to the rushing stream of the boiled water demostrates the process of form making and its moveable nature in form. i have to say it is a tiny opening ocasionally happening in daily life, but also a deep insight that sees through the apprearance of the enormous structure that functions steadily in the universe.

2010年11月19日 星期五

珊瑚練習




日前經grasshopper的練習捕捉珊瑚生物機制的造型演練,這是階段性的成果,持續演化中...

2009年2月25日 星期三

Rhino Script Excise09



aim: add one new vertex in the middle position of every two continuous existing vertices of a polyline.


Option Explicit
'Script written by Jeong-der ho, based on Robert McNeel & Associates Rhino script tutorial
'Script copylefted by de place
'Script version 2009年2月18日 上午 11:25:38

Call DividePolyline()
Sub DividePolyline()
Dim strOriPolyline
strOriPolyline = Rhino.GetObject("Select a Polyline sample", 4, True, True)
If IsNull(strOriPolyline) Then Exit Sub

Dim arrPolyVertices
arrPolyVertices = Rhino.PolylineVertices(strOriPolyline)

Dim arrNewVertices
arrNewVertices = SubDividePolyline(arrPolyVertices)

Dim strNewPolyline
Dim arrStart : arrStart = Array(0,0,0)
Dim arrEnd : arrEnd = Array(10,0,0)

strNewPolyline = Rhino.AddPolyline (arrNewVertices)
Call Rhino.MoveObject(strNewPolyline, arrStart, arrEnd)
End Sub

Function SubDividePolyline(ByRef arrV)
Dim arrSubD() : ReDim arrSubD(2 * UBound(arrV))
Dim i

For i = 0 To UBound(arrV)-1
'copy the original vertex location
arrSubD(i * 2) = arrV(i)
'compute the average of the current vertex and the next one
arrSubD(i * 2 + 1) = Array( (arrV(i)(0) + arrV(i+1)(0)) / 2.0, _
(arrV(i)(1) + arrV(i+1)(1)) / 2.0, _
(arrV(i)(2) + arrV(i+1)(2)) / 2.0)
Next

'copy the last vertex (this is skipped by the loop)
arrSubD(UBound(arrSubD)) = arrV(UBound(arrV))
SubDividePolyline = arrSubD
End Function

2009年2月18日 星期三

Rhino Script Excise08




Option Explicit
'Script written by
'Script copyrighted by
'Script version 2009年2月18日 上午 11:14:27
'Script function 選取隨意繪製的polyline,電腦回饋長度。'

Call CalPolylineLength
Sub CalPolylineLength
Dim strPolyline
strPolyline = Rhino.GetObject("select a polyline sample", 4, True, True)

Dim arrPolyVertices
arrPolyVertices = Rhino.PolylineVertices(strPolyline)

Dim dblPolylineLength
dblPolylineLength = PolylineLength(arrPolyVertices)
Call Rhino.print("PolylineLength = " & dblPolylineLength)
End Sub

Function PolylineLength(ByRef arrVertices)
PolylineLength = 0.0
Dim i
For i = 0 To UBound(arrVertices) - 1
PolylineLength = PolylineLength + Rhino.Distance(arrVertices(i), arrVertices(i+1))
Next
End Function

2009年2月14日 星期六

Rhino Script Excise07



Call Main()
Sub Main()
Dim strSurfaceID
strSurfaceID = Rhino.GetObject("Select a surface to sample", 8, True)
If IsNull(strSurfaceID) Then Exit Sub

Dim strCurveID
strCurveID = Rhino.GetObject("Select a curve to measure", 4, True, True)
If IsNull(strCurveID) Then Exit Sub

Dim arrPts : arrPts = Rhino.DivideCurve(strCurveID, 500)
Dim i

Call Rhino.EnableRedraw(False)
For i = 0 To UBound(arrPts)
Call EvaluateDeviation(strSurfaceID, 5.0, arrPts(i))
Next
Call Rhino.EnableRedraw(True)
End Sub

Function EvaluateDeviation(strSurfaceID, dblThreshold, arrSample)
EvaluateDeviation = Null

Dim arrR2Point
arrR2Point = Rhino.SurfaceClosestPoint(strSurfaceID, arrSample)
If IsNull(arrR2Point) Then Exit Function

Dim arrR3Point : arrR3Point =Rhino.EvaluateSurface(strSurfaceID, arrR2Point)
If IsNull(arrR3Point) Then Exit Function

Dim dblDeviation : dblDeviation = Rhino.Distance(arrR3Point, arrSample)
If dblDeviation <= dblThreshold Then
EvaluateDeviation = True
Exit Function
End If

Call Rhino.AddPoint(arrSample)
Call Rhino.AddLine(arrSample, arrR3Point)
EvaluateDeviation = False
End Function

2009年2月12日 星期四

Rhino Script Excise06



This is a script which adds points according to a specific interval from R1 parameters to R3 spatial positions.

Call Main()
Sub Main()
Dim strCurveID
strCurveID = Rhino.GetObject("select a curve to sample", 4, True,True)
If IsNull(strCurveID) Then Exit Sub

Dim t
Call Rhino.EnableRedraw(False)
For t = 0.0 To 1.0 Step 0.002
Call AddPointAtR1Parameter(strCurveID, t)
Next
Call Rhino.EnableRedraw(True)
End Sub

Function AddPointAtR1Parameter(strCurveID, dblUnitParameter)
AddPointAtR1Parameter = Null

Dim crvDomain : crvDomain = Rhino.CurveDomain(strCurveID)
If IsNull(crvDomain) Then Exit Function

Dim dblR1Param
dblR1Param = crvDomain(0) + dblUnitParameter * (crvDomain(1) - crvDomain(0))
Dim arrR3Point : arrR3Point = Rhino.EvaluateCurve(strCurveID, dblR1Param)
If Not IsArray(arrR3Point) Then Exit Function

Dim strPointId : strPointID = Rhino.AddPoint(arrR3Point)
Call Rhino.ObjectColor(strPointID, ParameterColour(dblUnitParameter))
AddPointAtR1Parameter = strPointID
End Function

Function ParameterColour(dblParam)
Dim RedComponent : RedComponent = 255 * dblParam
If (RedComponent < 0) Then RedComponent = 0
If (RedComponent > 255) Then RedComponent = 255

ParameterColour = RGB(RedComponent, 0, 255 - RedComponent)
End Function

2009年1月14日 星期三

tobacco mosaic virus



模擬菸草嵌紋病毒在酸鹼性不同的濃度時,表面蛋白質單元打開壁體,讓病毒RNA捲體進入結合。

嘗試用rhino script撰寫完成。

Option Explicit
'Script written by
'Script copyrighted by
'Script version 2009年01月13日 下午 08:28

Call TMV()
Sub TMV()

Dim z, a
Dim x, y
Dim pi, dblTwistAngle
pi = Rhino.Pi()
dblTwistAngle = 0.0

Call Rhino.EnableRedraw(False)


For z = 0.0 To 12.0 Step 0.5

If (z >= 0 And z < 2) Or (z >= 6 And z < 8) Or (z >= 10 And z < 12) Then

dblTwistAngle = dblTwistAngle + (pi/30)

For a = 0.0 To 2*pi Step (pi/15)
x = 5 * Sin(a + dblTwistAngle)
y = 5 * Cos(a + dblTwistAngle)
Call Rhino.AddSphere(Array(x,y,z), 0.5)
Next

End If

Next


Dim t
For t = 2 To 10 Step 0.05
If (t >= 2 And t < 6) Then

x = 5 * Sin(3*t)
y = 5 * Cos(3*t)
z = t
Call Rhino.AddSphere(Array(x,y,z), 0.5)

End If

If (t >=8 And t < 10) Then

x = 5 * Cos(3*t)
y = 5 * Sin(3*t)
z = t
Call Rhino.AddSphere(Array(x,y,z), 0.5)

End If

Next


Dim u
For t = 0 To 12 Step 0.05

x = 2 * Cos(3*t)
y = 2 * Sin(3*t)
z = t
Call Rhino.AddSphere(Array(x,y,z), 0.5)

Next

Call Rhino.EnableRedraw(True)
End Sub

2008年11月10日 星期一

Rhino Script Excise05



Option Explicit
'Script written by David Rutten
'Script copyrighted by Robert McNeel & Associates
'Script version 2008年11月10日 下午 09:50:44

Call IterativeShortenCurve()
Sub IterativeShortenCurve()
Dim strCurveID : strCurveID = Rhino.GetObject("Open curve to smooth", 4, True)
If IsNull(strCurveID) Then Exit Sub
If Rhino.IsCurveClosed(strCurveID) Then Exit Sub

Dim dblMin, dblMax, dblGoal
dblMin = Rhino.Distance(Rhino.CurveStartPoint(strCurveID), Rhino.CurveEndPoint(strCurveID))
dblMax = Rhino.CurveLength(strCurveID)
dblGoal = Rhino.GetReal("Goal Length", 0.5*(dblMin + dblMax), dblMin, dblMax)
If IsNull(dblGoal) Then Exit Sub

Do Until Rhino.CurveLength(strCurveID) < dblGoal
Call Rhino.EnableRedraw(False)
strCurveID = SmoothCurve(StrCurveID, 0.1)
If IsNull(strCurveID) Then Exit Do
Call Rhino.EnableRedraw(True)
Loop
End Sub

2008年11月4日 星期二

Rhino Script Excise04


Option Explicit
'Script written by David Rutten
'Script copyrighted by Robert McNeel & Associates
'This script will compute a bunch of cross-product vector based on a pointcloud
'Script version 2008年11月2日 下午 12:13:07

Call VectorField()
Sub VectorField()
Dim strCloudID
strCloudID = Rhino.GetObject("Input pointcloud", 2, True, True)
If IsNull(strCloudID) Then Exit Sub

Dim arrPoints : arrPoints = Rhino.PointCloudPoints(strCloudID)
Dim ptBase : ptBase = Rhino.GetPoint("Vector field base point")
If IsNull(ptBase) Then Exit Sub

Dim i
For i = 0 To UBound(arrpoints)
Dim vecBase
vecBase = Rhino.VectorCreate(arrPoints(i), ptBase)

Dim vecDir : vecDir = Rhino.VectorCrossProduct(vecBase, Array(0,0,1))

If Not IsNull(vecDir) Then
vecDir = Rhino.VectorUnitize(vecDir)
vecDir = Rhino.VectorScale(vecDir, 2.0)

Call AddVector(vecDir, arrPoints(i))
End If
Next
End Sub

2008年10月30日 星期四

Rhino Script Excise03


Option Explicit
'Script written by David Rutten
'Script copyrighted by Robert McNeel & Associates
'Script version 2008年10月30日 上午 12:31:12

Call PointSpiral()
Sub PointSpiral()
Dim arrPoint(2)
Dim t, pi
pi = Rhino.Pi()

Call Rhino.EnableRedraw(False)
For t = -5 To 5 Step 0.025

arrPoint(0) = t * Sin(5*t)
arrPoint(1) = t * Cos(5*t)
arrPoint(2) = t

Call Rhino.Print(Rhino.Pt2Str(arrPoint, 3))
Call Rhino.AddSphere(arrPoint, 0.5)
Next
Call Rhino.EnableRedraw(True)
End Sub

2008年10月19日 星期日

Rhino Script Excise02


利用迴圈作圖

Option Explicit
'Script written by
'Script copyrighted by
'Script version 2008年10月19日 下午 10:35:27

Call TwistAndShout()
Sub TwistAndShout()
Dim z, a
Dim pi, dblTwistAngle
pi = Rhino.Pi()
dblTwistAngle = 0.0

Call Rhino.EnableRedraw(False)
For z = 0.0 To 5.0 Step 0.5
dblTwistAngle = dblTwistAngle + (pi/30)

For a = 0.0 To 2*pi Step (pi/15)
Dim x, y
x = 5 * Sin(a + dblTwistAngle)
y = 5 * Cos(a + dblTwistAngle)
Call Rhino.AddSphere(Array(x,y,z), 0.5)
Next
Next
Call Rhino.EnableRedraw(True)
End Sub

Rhino Script Excise01


loop exercise:根據迴圈做圖。

Option Explicit
'Script written by David Rutten
'Script copyrighted by Robert McNeel & Associates
'Script version 2008年10月19日 下午 09:42:22

Call DrawsSineWave()
Sub DrawsSineWave()
Dim x, y
Dim dblA, dblB, dblStep

dblA = -8.0
dblB = 8.0
dblStep = 0.01

For x = dblA To dblB Step dblStep
y = 2*sin(x)

Call Rhino.AddPoint(Array(x, y, 0))
Next

End Sub