Kami – Recursive function practice

02 stacked spheres

 

import math
import rhinoscriptsyntax as rs


def stacktheSpheres():
pi = math.pi
dblTwistAngle = 0.0
#the z coordinate for all sphere centers
#rs.frange is the float version of range function
#rs.frange(start, stop, step)
for z in rs.frange(0.0, 5.0, 0.5):
dblTwistAngle = dblTwistAngle + (pi/30)
#this is for the twisting as it loops upwards

for a in rs.frange(0.0, 2*pi, (pi/15)):
x = 5 * math.sin(a + dblTwistAngle)
y = 5 * math.cos(a + dblTwistAngle)
rs.AddSphere([x,y,z], 0.5) #the center and radius
#this is for the first ring of spheres

stacktheSpheres()

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s