from math import hypot class GasSim: def __init__(self, particle_radius, particle_compressibility, particle_friction, substeps): self.particle_radius = particle_radius self.particle_compressibility = particle_compressibility self.particle_friction = particle_friction self.substeps = substeps self.particles = [] self.walls = [] def add_particle(self, pos, vel = (0, 0)): self.particles.append([pos, vel]) def cursor_particle_collide_test(self, cursor_pos, cursor_radius): for particle in self.particles: if hypot(particle[0][0] - cursor_pos[0], particle[0][1] - cursor_pos[1]) <= cursor_radius + self.particle_radius: return True def add_wall(self, start, end): self.walls.append((start, end))