import sys,random,math from pnoise import pnoise import rv import cgkit.noise def writePoint(xyzList): print('Points "P" [') for xyz in xyzList: print('%s %s %s \n'% (xyz[0],xyz[1],xyz[2])) print(']"constantwidth" [0.01]') def addNoise(p,frq,noiseAmount): noise = cgkit.noise noiseAmount *= noise.noise([p[0]*frq,p[1]*frq,p[2]*frq]) noiseAmount *= random.random() vn = noise.vsnoise([p[0]*frq,p[1]*frq,p[2]*frq]) new_x = p[0] + (vn[0] * noiseAmount) new_y = p[1] + (vn[1] * noiseAmount) new_z = p[2] + (vn[2] * noiseAmount) return [new_x,new_y,new_z] #return vn def geRandomPoint(num,radius,noiseAmount,seed): data = [] n=0.0 for e in range(num): random.seed(n+seed) theta = (n)/num * math.pi*2 distance = random.random() p = (rv.on_sphere([0,0,0],radius)) p = addNoise(p,3,noiseAmount) data.append(p) n = n+1 return data args = sys.stdin.readline() while args: values = args.split() pixels = float(values[0]) num = int(values[1]) radius = float(values[2]) noiseAmount = float(values[3]) seed = float (values[4]) #print 'TransformBegin' #print 'Sphere %s %s %s 360' % (rad, -rad, rad) #print 'TransformEnd' writePoint(geRandomPoint(num,radius,noiseAmount,seed)) sys.stdout.write('\377') sys.stdout.flush() # read the next set of inputs args = sys.stdin.readline()