Junya Huang class1

2016-03-19 23-10.jpg

</pre>
import rhinoscriptsyntax as rs
import random

pList = []
class plant():
def __init__(self):
op1 = self.maintwig([0,0,0],[0,0,1],3,10,40,70)

n = 0
for i in range (69):
self.subtwig1(op1[n], rs.VectorSubtract(op1[n], op1[n+1]), 5, 50, 45)
self.subtwig2(op1[n], rs.VectorSubtract(op1[n], op1[n+1]), 5, 50, 45)
n+=1

def maintwig(self,pt1, pt2, dist, layer, r, ns):

Spiral = rs.AddSpiral(pt1, pt2, dist, layer, r)
pointlist01 = rs.DivideCurve (Spiral, ns, True, True)
pointlist0102 = rs.AddPoints(pointlist01)
count = 0
for i in pointlist01:

a = random.uniform(-50,50)
b = random.uniform(-50,50)

vector = rs.VectorSubtract([a,b,0],pointlist0102[count])
unitvector = rs.VectorDivide(vector,ns)
nm = random.uniform(-50,50)

vector02 = unitvector*nm
pointlist02 = rs.MoveObject(pointlist0102[count],vector02)
count +=1
pointlist0202 = rs.PointCoordinates(pointlist02)

pList.append(pointlist0202)

maintwig = rs.AddInterpCurve(pList)
return pList

def subtwig1(self,origin, direction, mindist, maxdist, maxangle) :
subtwig1 = rs.VectorUnitize(direction)
subtwig1 = rs.VectorScale(subtwig1, (mindist + maxdist - mindist)*random.random())
plane = rs.PlaneFromNormal(origin,subtwig1)
subtwig1 = rs.VectorRotate(subtwig1,random.random()*maxangle,plane[1])
subtwig1 = rs.VectorRotate(subtwig1, random.random()*360, direction)
endpoint = rs.PointAdd(origin, subtwig1)
subtwig1 = rs.AddArcPtTanPt(origin, random.random()*direction, endpoint)

def subtwig2(self,origin, direction, mindist, maxdist, maxangle) :
subtwig2 = rs.VectorUnitize(direction)
subtwig2 = rs.VectorScale(subtwig2, (mindist + maxdist - mindist)*random.random())
plane = rs.PlaneFromNormal(origin,subtwig2)
subtwig2 = rs.VectorRotate(subtwig2,random.random()*maxangle,plane[1])
subtwig2 = rs.VectorRotate(subtwig2, random.random()*360, direction)
endpoint = rs.PointAdd(origin, subtwig2)
subtwig2 = rs.AddArcPtTanPt(origin, random.random()*direction, endpoint)

p = plant()
<pre>

One thought on “Junya Huang class1

Leave a Reply to Juhong Park Cancel 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