Exemple #1
0
def add_particle_at(mx: ti.f32, my: ti.f32, mass: ti.f32):
    mouse_pos = tl.vec(mx, my) + tl.randND(2) * (0.05 / kResolution)

    particle_id = alloc_particle()
    if ti.static(kDim == 2):
        particle_pos[particle_id] = mouse_pos
    else:
        particle_pos[particle_id] = tl.vec(mouse_pos, 0.0)
    particle_mass[particle_id] = mass
Exemple #2
0
def init():
    for i in x:
        x[i] = (tl.randND(3) * 2 - 1) * (bound - radius)
        v[i] = tl.randUnit3D() * 4
Exemple #3
0
 def on_start(self):
     for i in self.pos:
         self.pos[i] = ts.randND(2)
         self.vel[i] = ts.randSolid2D()