# Inelastic circle collisions

• 08-24-2010, 04:08 AM
Atriamax
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.
• 08-24-2010, 04:29 AM
gafa
Show us the problem code or error message please
• 08-24-2010, 05:41 AM
colpwd
What are you using to measure the rate of gravitation (movement) of the circles?
• 08-24-2010, 06:26 AM
Atriamax
gafa, theres no error message, It just doesn't work.
as for the rate of gravitation, i use the standard force of gravity
I use acceleration = (mass of other object) / (distance between them)^2
then multiply it by a constant. to get a nice real looking rate.

each ball is on its own thread that checks its own acceleration towards other objects, and checks if its intersecting other circles.
• 08-24-2010, 06:43 AM
Zack
Without samples of your code that are relevant to the actual program, we cannot help. That formula looks like it would work, but it's hard to tell exactly how exactly it affects the program in general without seeing the big picture.

At the very least, an actual video of the outcome would be helpful.
• 08-25-2010, 01:12 AM
paul pasciak
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.

• 08-25-2010, 01:35 AM
Atriamax
Interesting, I think i will try locking them like you mentioned. as of now, they dont intersect eachother, because they are instantly moved to the outside of the circle, but now they jitter and still accelerate in a random direction. I do have momentum and it works good when bunches hit other bunches, its just the fact that the bunches are accelerating in random directions. If I "lock" them into the bunch i could treat it as a whole.
ill try doing that. ill do a little video of what it looks like, I think its pretty neat so far!
• 08-26-2010, 09:49 PM
Atriamax
K i created a little screen cap of my program. You can really see the problem with the very first thing I do, then also again at 1:44. When I zoom out they are still moving, but its so far away so it doesnt really make a difference.