Difference between revisions of "workshop01G5:Codefarm"
From CECO
(Created page with "__NOTOC__ __NOTITLE__ <div style="height:30px; width: 850px; margin:0px; padding: 0px; padding-top: 20px; border: 0px;"> <div style="float:left; width: 160px; height 30px; b...") |
|||
(4 intermediate revisions by 2 users not shown) | |||
Line 5: | Line 5: | ||
<div style="float:left; width: 160px; height 30px; border: 1px solid #aaa; margin-right:10px; " align="center">[[workshop01G5:Group|'''Group 5''']]</div> | <div style="float:left; width: 160px; height 30px; border: 1px solid #aaa; margin-right:10px; " align="center">[[workshop01G5:Group|'''Group 5''']]</div> | ||
− | <div style="float:left; width: 160px; height 30px; border: 1px solid #aaa; margin-right:10px;" align="center">[[workshop01G5: | + | <div style="float:left; width: 160px; height 30px; border: 1px solid #aaa; margin-right:10px;" align="center">[[workshop01G5:Past Experiments|'''Past Experiments''']]</div> |
− | <div style="float:left; width: 160px; height 30px; border: 1px solid #aaa; margin-right:10px;" align="center">[[workshop01G5: | + | <div style="float:left; width: 160px; height 30px; border: 1px solid #aaa; margin-right:10px;" align="center">[[workshop01G5:Present to Future|'''Present to Future''']]</div> |
<div style="float:left; width: 160px; height 30px; border: 1px solid #aaa; margin-right:10px;" align="center">[[workshop01G5:Codefarm|'''Code Farm''']]</div> | <div style="float:left; width: 160px; height 30px; border: 1px solid #aaa; margin-right:10px;" align="center">[[workshop01G5:Codefarm|'''Code Farm''']]</div> | ||
Line 15: | Line 15: | ||
</div><br> | </div><br> | ||
− | == | + | ==cell generation== |
− | + | import rhinoscriptsyntax as rs | |
+ | |||
+ | import random | ||
+ | |||
+ | import scriptcontext | ||
+ | |||
+ | |||
+ | |||
+ | def generation(x,strPt): | ||
+ | |||
+ | #have a line so i can use "escape" key | ||
+ | scriptcontext.escape_test() | ||
+ | if x==0: return | ||
+ | else: | ||
+ | for i in range (0,100): | ||
+ | #define the direction the starting point will grow | ||
+ | point=[(0,1,0),(1,0,0),(-1,0,0),(0,-1,0)] | ||
+ | rnd=random.choice(point) | ||
+ | vec=rs.VectorCreate(rnd,(0,0,0)) | ||
+ | strPt=rs.PointAdd(strPt,vec) | ||
+ | strPts.append(strPt) | ||
+ | #form a volume based on the point | ||
+ | rs.AddCircle(strPt,0.5) | ||
+ | print rs.AddPoint(strPt) | ||
+ | strPts=[] | ||
+ | |||
+ | strPt1=rs.AddPoint((0,0,0)) | ||
+ | |||
+ | vec1=rs.VectorCreate((1,0,0),(0,0,0)) | ||
+ | |||
+ | strPt=rs.PointAdd(strPt1,vec1) | ||
+ | |||
+ | generation(3,strPt) | ||
+ | |||
+ | print strPts[3] | ||
+ | |||
+ | |||
+ | [[Image:Group5-cellar automata diagram.jpg|900px]] |
Latest revision as of 14:35, 4 October 2013
cell generation
import rhinoscriptsyntax as rs
import random
import scriptcontext
def generation(x,strPt):
#have a line so i can use "escape" key scriptcontext.escape_test() if x==0: return else: for i in range (0,100): #define the direction the starting point will grow point=[(0,1,0),(1,0,0),(-1,0,0),(0,-1,0)] rnd=random.choice(point) vec=rs.VectorCreate(rnd,(0,0,0)) strPt=rs.PointAdd(strPt,vec) strPts.append(strPt) #form a volume based on the point rs.AddCircle(strPt,0.5) print rs.AddPoint(strPt)
strPts=[]
strPt1=rs.AddPoint((0,0,0))
vec1=rs.VectorCreate((1,0,0),(0,0,0))
strPt=rs.PointAdd(strPt1,vec1)
generation(3,strPt)
print strPts[3]