Inelastic circle collisions
Hey I'm creating a gravity-physics type simulator that consists of circles that gravitate toward each other. It works pretty good so far except for the collisions. I want the collisions to be inelastic so the circles bunch up nicely. Right now, 2 circles will work alright, they will bunch up and act as one. But what happens with more than 2 is the circles pull each other through other circles. Then the jumbled blob will accelerate in a random direction because the gravity of one pulls on the other, but they move as a unit. The collision detection im using is a simple distance of centers vs sum of radii. I need some way to keep the circles from intersecting, but still be effected by the gravity. Im thinking that they can be held together by the gravity force, but I dont know any good method to keep them repelled. any suggestions on how to approach this?
thanks.
Geometry and physics that can get complex
I think your goal is much more complex
than you may be aware.
I think you want the circles to clump together
without overlapping. You want some way to
halt their movement once the circles touch.
Or something like that.
Keep in mind the following suggestion
is only a part of many formulas that
may simulate some of the laws of physics.
My idea is that you lock a circle into
position in a cluster once it contacts
the boundary of TWO other circles.
Make this condition the one that halts
that circle's movement and causes a
recalculation of the cluster's momentum
(if you are using momentum in your
project).
This works because the contact of the
three circles together creates a triangle
with the centers of each of the circles,
which is rigid, and the circles don't
overlap.
Your algorithm will be watching for,
or even promoting the production of
these triangles.
Possibly, through random motion, the
anticipated positions of the circles
will never occur.
To force this event to happen in a
timely manner, you can make a circle,
upon collision, divide into two minor
circles, then have that pair lock
together with the circle it impacted
with.
I hope this is helpful.