Ich bin kürzlich darüber gestolpert: ich wollte das Model "perfectly elastic collison of hard-spheres (in 2D)" implementieren, think Billiardkugeln. Alle Partikel haben die gleiche Masse und so gilt dass der Impuls der Kugel A beim Zusammenstoss auf die Kugel B übergeht und Impuls von B auf A (vektoriell).
Code: Alles auswählen
#Exchange velocities
xvel[i] = xvel[j]
yvel[i] = yvel[j]
#Take over velocities
xvel[j] = xvel[i]
yvel[j] = yvel[i]
Code: Alles auswählen
tempXi = xvel[i]
tempYi = yvel[i]
#Exchange velocities
xvel[i] = xvel[j]
yvel[i] = yvel[j]
#Take over velocities
xvel[j] = tempXi
yvel[j] = tempYi