8.2.09
phillotaxis
I created a script based on Fibonacci spiral. Spiral are created along a curve selected by the user. Radius of the tube-shaped surface on which are settled spirals is influenced from the distance between curve and a selected point.
This is my first attempt...I’m working to improve it!!
Option Explicit
'Script written by andrea bugli
' http://andbug.blogspot.com
'Script version venerdì 6 febbraio 2009 19.54.31
Call fibonacci
Sub fibonacci
Dim strBpts
Dim arrcircle, strN
strN = 200
Dim strcurve: strcurve = rhino.GetObject("select a curve", 4, True, True)
Dim strpoints: strpoints = rhino.DivideCurve(strcurve, strN, False, True)
' rhino.addpoints(strpoints)
ReDim arrcircle(ubound(strpoints))
Dim ptparam: ptparam = rhino.GetObject("select a point")
Dim ptcoord: ptcoord = rhino.PointCoordinates(ptparam)
Dim i
Dim ptrot
Dim pt
Dim ptcurve
ReDim ptrot(ubound(strpoints))
rhino.EnableRedraw(False)
For i = 0 To ubound(strpoints)
Dim strPoncurve: strPoncurve = rhino.CurveClosestPoint(strcurve, strpoints(i))
Dim strframe: strframe = rhino.Curveperpframe(strcurve, strPoncurve)
Dim tang: tang = rhino.curvetangent(strcurve, strPoncurve)
Dim dist: dist = rhino.Distance(strpoints(i), ptcoord)
arrcircle(i) = rhino.addcircle(strframe, dist/8)
ptcurve = rhino.CurveStartPoint(arrcircle(i))
pt = rhino.addpoint(ptcurve)
ptrot(i) = rhino.RotateObject(pt, strpoints(i), 137.52*i, tang, true)
rhino.Deleteobject(pt)
Next
'Call rhino.AddLoftSrf(arrcircle)
rhino.enableredraw(True)
call rhino.DeleteObjects(arrcircle)
Dim j, v
Dim pointfib()
Dim arrcurve1(4)
Dim dom1
Dim countfib
Dim crvcurv1
Dim plane1
Dim circle1
Dim tube1(4)
For v = 0 To 4
countfib = 0
For j = v To ubound(ptrot) Step 5
ReDim Preserve pointfib(countfib)
pointfib(countfib) = rhino.PointCoordinates(ptrot(j))
countfib = countfib+1
Next
arrcurve1(v) = rhino.addcurve(pointfib)
dom1 = rhino.Curvedomain(arrcurve1(v))
crvcurv1 = rhino.curvecurvature(arrcurve1(v), dom1(0))
plane1 = rhino.PlaneFromNormal(rhino.CurveStartPoint(arrcurve1(v)),crvcurv1(1))
circle1 = rhino.AddCircle(plane1, 0.2)
tube1(v) = rhino.AddSweep1(arrCurve1(v), circle1)
Erase pointfib
Next
Dim k, h
Dim pointfib2()
Dim arrcurve2(7)
Dim dom2
Dim crvcurv2
Dim plane2
Dim circle2
Dim tube2(7)
Dim countfib2
For h = 0 To 7
countfib2 = 0
For k = h To ubound(ptrot) Step 8
ReDim Preserve pointfib2(countfib2)
pointfib2(countfib2) = rhino.PointCoordinates(ptrot(k))
countfib2 = countfib2+1
Next
arrcurve2(h) = rhino.addcurve(pointfib2)
dom2 = rhino.Curvedomain(arrcurve2(h))
crvcurv2 = rhino.curvecurvature(arrcurve2(h), dom2(0))
plane2 = rhino.PlaneFromNormal(rhino.CurveStartPoint(arrcurve2(h)),crvcurv2(1))
circle2 = rhino.AddCircle(plane2, 0.2)
tube2(h) = rhino.AddSweep1(arrCurve2(h), circle2)
Erase pointfib2
Next
Call rhino.DeleteObjects(ptrot)
End Sub
Subscribe to:
Post Comments (Atom)
Good Job Andrea!
ReplyDeleteJust a couple of suggestions:
- don't keep all the eyecandies for youself, post some of the good renders here... ;-)
- take a look at the Euplectella aspergyllum (Venus' flower basket)