def add_particles_sphere(self, center, radius, particle_type, **kwargs): positions = tc_core.points_inside_sphere( tc_core.make_range(.25 * self.delta_x, self.res[0] * self.delta_x, self.delta_x / self.sample_rate), tc_core.make_range(.25 * self.delta_x, self.res[1] * self.delta_x, self.delta_x / self.sample_rate), center, radius) samples = [] for p in positions: u = p.x v = p.y particle = self.create_particle(particle_type) self.modify_particle(particle, kwargs, u, v) particle.position = Vector(p.x / self.delta_x, p.y / self.delta_x) samples.append(particle) self.add_particles(samples)
def add_particles_polygon(self, polygon, particle_type, **kwargs): positions = tc_core.points_inside_polygon( tc_core.make_range(.25 * self.delta_x, self.resolution[0] * self.delta_x, self.delta_x / self.sample_rate), tc_core.make_range(.25 * self.delta_x, self.resolution[1] * self.delta_x, self.delta_x / self.sample_rate), make_polygon(polygon, 1) ) samples = [] for p in positions: u = p.x v = p.y particle = self.create_particle(particle_type) self.modifty_particle(particle, kwargs, u, v) particle.position = Vector(p.x / self.delta_x, p.y / self.delta_x) samples.append(particle) self.add_particles(samples)