voronoi cells for disks

This commit is contained in:
Ian Jauslin 2024-02-22 16:31:10 -05:00
parent fd61a4620f
commit 7e44418829

View File

@ -282,3 +282,16 @@ class Element_circle(Element):
def move_along(self,delta,element):
x=element.pos-self.pos+delta
return x/l_2(x)*(element.size+self.size)/2+self.pos-element.pos
# for use with lattices
# list of lattice points covered by square
def lattice_points(self,lattice):
out=[]
dx=math.floor(0.5*self.size/lattice.spacing)
for i in range(-dx,dx+1):
for j in range(-dx,dx+1):
if i*i+j*j<=2*dx*dx:
out.append(Point(self.pos.x+i*lattice.spacing,self.pos.y+j*lattice.spacing))
return out