def diffuse(self, pixels, delta_t):
self.pixels.append(np.empty([self.X_MAX, self.Y_MAX], dtype=float))
if delta_t < 5:
return
v = self.diffusion_constant
h0 = self.pixels[1]
h, idx = self.hCalc()
hDiff = (h - h0 * idx)
h = hDiff * delta_t * v + h0
# pylint: disable=no-member
pix = np.array(pixels[:, :][:], dtype=np.int64)
color = (pix[:, :, 0] << 16) | (pix[:, :, 1] << 8) | (pix[:, :, 2])
f = np.where(color == 0xFF0000, 0xFFFF, np.where(color == 0xFF00, 0 - 0xFFFF,
0))[:self.X_MAX, :self.Y_MAX]
h = h + f
h = np.clip(h, 0, 0xFFFF)
self.pixels[2] = np.clip(h, 0, 0xFFFF)
##
# This is the differences between node i,j and it's closest neighbors
# it's used in calculateing spatial derivitives
#
finite_difference.py 文件源码
python
阅读 24
收藏 0
点赞 0
评论 0
评论列表
文章目录