View Single Post
  #2  
Old 02-28-2007, 12:16 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
I've attached a script that generates a set of random points around a center point within a certain radius. You can use the GenerateRandomPoint(x,y,radius) function in your script. Just pass it the center point and radius and it will return a 2D point within the circle. Hope this helps.
Code:
import viz
import math
viz.go()

def GenerateRandomPoint(x,y,radius):
	r = vizmat.GetRandom(0,radius)
	a = vizmat.GetRandom(0,2*math.pi)
	return math.sin(a)*r + x , math.cos(a)*r + y
	
viz.startlayer(viz.POINTS)
for x in range(1000):
	x,y = GenerateRandomPoint(0,1.8,1)
	viz.vertex(x,y,5)
viz.endlayer()
Reply With Quote