def Main():
strcir=rs.GetObject ("select a circle to start a tornado")
mvnt=rs.GetReal ("type distance",1)
rotation=rs.GetReal ("type rotation",30)
gens=rs.GetInteger ("type number of generations",100)
strptcl=rs.DivideCurve(strcir,10)
CurGen=[]
CurGen.append(strcir)
for i in range(gens):
NewGen=[]
for circle in CurGen:
Newcircle= transmition(circle,mvnt,rotation)
Newptcld=rs.DivideCurve(Newcircle,10)
NewGen.extend(Newcircle)
多谢Jorin...我们改进了一些。下面的代码模拟点云形成的龙卷风,准备加上trail,显示龙卷风的轨迹。。我们还没有考虑消散的问题:)
import rhinoscriptsyntax as rs
def Main():
#GET CENTER
Points=rs.GetObjects("get your agents to start a tornado",rs.filter.point)
rotation=rs.GetReal ("type rotation",15)
gens=rs.GetInteger ("type number of generations",5)
#CurGen=[]
#CurGen.extend(Points)
###get cener axis center point z direction) vec=([Cenx,Ceny,0],[0,0,0])
PtCoordsx=[]
PtCoordsy=[]
PtCoordsz=[]
for pt in Points:
PtCoord=rs.PointCoordinates(pt)
PtCoordsx.append(PtCoord[0])
PtCoordsy.append(PtCoord[1])
PtCoordsz.append(PtCoord[2])
Cenx=sum(PtCoordsx)/len(PtCoordsx)
Ceny=sum(PtCoordsy)/len(PtCoordsy)
Cenz=sum(PtCoordsz)/len(PtCoordsz)
Centercoord=[Cenx,Ceny,Cenz]
Center=rs.AddPoint([Cenx,Ceny,Cenz])
attr=rs.PointAdd(Centercoord,[0,0,-100])
for i in range(gens):
for pt in Points:
newpt=movement(pt,attr,Centercoord,rotation)
Points.remove(pt)
Points.append(newpt)