Friday, April 27, 2012

Fibonacci spiral with respect to the Nautilus Shell


import rhinoscriptsyntax as rs
from math import *
import math as m

a = 1
b = 0.2
pts1 = []
pts2 = []
pts3 = []

for t in range(0, 30):
    x = a * m.exp(b*t) * m.cos(t)
    y = a * m.exp(b*t) * m.sin(t)
    pts1.append(rs.AddPoint(x/4,y/4,0))
    pts2.append(rs.AddPoint(x/1.3,y/1.3,15))
    pts3.append(rs.AddPoint(x,y,30))

curve1 = rs.AddInterpCurve(pts1)
curve2 = rs.AddInterpCurve(pts2)
curve3 = rs.AddInterpCurve(pts3)


# LOFTING SURFACE
strSurf = rs.AddLoftSrf([curve1, curve2, curve3])

listcurves = []
for i in range(0, 23):
    pointcoord1=rs.PointCoordinates(pts3[i])
    pointcoord1a=rs.PointCoordinates(pts3[i+1])
    
    pointcoord2=rs.PointCoordinates(pts3[i+6])
    pointcoord2a=rs.PointCoordinates(pts3[i+7])
    
    pointcoord3=rs.PointCoordinates(pts1[i])
    pointcoord3a=rs.PointCoordinates(pts1[i+1])
    
    pointcoord4=rs.PointCoordinates(pts1[i+6])
    pointcoord4a=rs.PointCoordinates(pts1[i+7])
    
    topcrv = rs.AddCurve([pointcoord2a, pointcoord2, pointcoord1, pointcoord1a])
    
    interpolcrv1 = rs.AddInterpCrvOnSrf(strSurf, [pointcoord1, pointcoord3])
    rs.ObjectColor(interpolcrv1,[255,0,0])
    interpolcrv2 = rs.AddInterpCrvOnSrf(strSurf, [pointcoord4, pointcoord3])
    rs.ObjectColor(interpolcrv2,[0,0,255])
   rs.AddLoftSrf([interpolcrv1, topcrv])

No comments:

Post a Comment