import rhinoscriptsyntax as rs from random import * iter = 5000 class Ball(object): def __init__(self, position, color): self.position = position self.color = color self.vel = [randrange(0,10),randrange(0,10),0] self.size = 3. self.display_list = None self.trace = [] self.colors = [] def update(self): """one tick of speudo physics""" if self.position[2]+self.size/2 < 0: self.position[2]=-self.size/2 #refloction + shock absoption self.vel[2] = self.vel[2]*-.90 #print "bounce" # pseudo gravitiy self.vel[2]= -0.5 # some friction #self.vel= self.vel*.99 # acceleration self.position = rs.VectorAdd(self.position,self.vel) #self.display_list = None #self.color = .7-self.vel #self.trace.append(self.position) #self.colors.append(self.color) ball = Ball([30,30,100.],(0.1,0.1,.5,)) while iter >0: iter +=-1 ball.update() print ball.position rs.AddPoint(ball.position)