def rvs( self ):
if self.ss == 0:
x = random.random() * self.w
y = random.random() * self.h
self.set_point( x, y )
while self.qs:
x_idx = int( random.random() * self.qs )
s = self.queue[ x_idx ]
for y_idx in range( self.n ):
a = 2 * scipy.pi * random.random()
b = scipy.sqrt( self.A * random.random() + self.r2 )
x = s[0] + b*scipy.cos( a )
y = s[1] + b*scipy.sin( a )
if( x >= 0 )and( x < self.w ):
if( y >= 0 )and( y < self.h ):
if( self.distance( x, y ) ):
self.set_point( x, y )
del self.queue[x_idx]
self.qs -= 1
sample = list( filter( None, self.grid ) )
sample = scipy.asfarray( sample )
return sample
poisson_disk_sampling.py 文件源码
python
阅读 41
收藏 0
点赞 0
评论 0
评论列表
文章目录