周期境界条件
セルを繰り返して、より大きな空間のシミュレーションを行います。
粒子の位置について
def boundary(self): #画面右と左をつなぐ if self.x > gxtox(width): #画面の右端をはみ出した self.x -= grtor(width) #画面の左端に移動 if self.x < gxtox(0): #画面の左端をはみ出した self.x += grtor(width) #画面の右端に移動 if self.y > gytoy(0): #画面の上端をはみ出した self.y -= grtor(height) #画面の下端に移動 if self.y < gytoy(height): #画面の下端をはみ出した self.y += grtor(height) #画面の上端に移動
粒子の表示について
def show(self): #画面に表示 for ix in range(-1,2): #ixを -1, 0, 1で3回繰り返し for iy in range(-1,2): #iyを -1, 0, 1で3回繰り返し pygame.draw.circle(screen, self.color, (xtogx(self.x)+ix*width, ytogy(self.y)+iy*height), rtogr(self.r)) #位置をずらして表示