# 02262016 class assignment Junya Huang

```import rhinoscriptsyntax as rs
import math

def initialcurve():
st = 0,0,0
ed = 10, 0,0
return crvid

def endingcondition(crvid):
st = rs.CurveStartPoint(crvid)
ed = rs.CurveEndPoint(crvid)
length = rs.Distance(st, ed)

if length &gt; 1:
return True
else:
False

def dosomething(crvid):
pts = rs.DivideCurve(crvid, 3)

center = pts[1]
angle = 60
crv2 = rs.RotateObject(crv2, center, angle)

center = pts[2]
angle = -60
crv3 = rs.RotateObject(crv3, center, angle)

rs.DeleteObject(crvid)

return crv1, crv2, crv3, crv4

def recursion(crvid):
cond = endingcondition(crvid)
newid = dosomething(crvid)

if cond == True:
recursion(newid[0])
recursion(newid[1])
recursion(newid[2])
recursion(newid[3])

def rotate():
crv = rs.AllObjects()
st = 0,0,0
ed = 10, 0,0
center = st
angle = 60
crv2 = rs.RotateObject(crv, center, angle, None, True)
center = ed
angle = -60
crv3 = rs.RotateObject(crv, ed, angle, None, True)
crv3 = rs.MirrorObjects(crv, st, ed, False)

def copy():
crv = rs.AllObjects()
st = 0,0,0
ed = 10, 0,0
y = math.tan(y)
ned = 10,10*y, 0
trans = rs.VectorSubtract(ned, st)
crv2 = rs.CopyObjects(crv, trans)

crv = rs.AllObjects()
y = math.tan(y)
nst = ned
ned = 10,10*y, 0
trans = rs.VectorSubtract(ned, nst)
crv3 = rs.CopyObjects(crv, trans)
crv4 = rs.CopyObjects(crv, trans*2)

crv = rs.AllObjects()
nst = st
ned = 2*10, 0,0
trans = rs.VectorSubtract(ned, nst)
crv5 = rs.CopyObjects(crv, trans)

def main():
crvid = initialcurve()
recursion(crvid)
rotate()
copy()

main()
```