Results 1 to 10 of 10
Thread: Inelastic circle collisions
- 08-24-2010, 04:08 AM #1
Member
- Join Date
- Sep 2009
- Posts
- 41
- Rep Power
- 0
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 #2
Show us the problem code or error message please
- 08-24-2010, 05:41 AM #3
Member
- Join Date
- Aug 2010
- Posts
- 25
- Rep Power
- 0
What are you using to measure the rate of gravitation (movement) of the circles?
- 08-24-2010, 06:26 AM #4
Member
- Join Date
- Sep 2009
- Posts
- 41
- Rep Power
- 0
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 #5
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 #6
Senior Member
- Join Date
- Jul 2008
- Posts
- 125
- Rep Power
- 0
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.
- 08-25-2010, 01:35 AM #7
Member
- Join Date
- Sep 2009
- Posts
- 41
- Rep Power
- 0
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 #8
Member
- Join Date
- Sep 2009
- Posts
- 41
- Rep Power
- 0
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.
YouTube - Java physics
I dont know how much posting code will help, but the actual collision check and gravitation dont take much more than a 10 lines of code each. The way I got the circles to be rigid is it detects the angle of their centers and displaces it so they are right outside eachothers edges. Any suggestions would be awesome, im stumped at this point. I guess I could have posted this in advanced? :/
Let me know if you have any questions too.
- 08-27-2010, 03:57 AM #9
Senior Member
- Join Date
- Feb 2010
- Location
- Waterford, Ireland
- Posts
- 748
- Rep Power
- 4
Your big circle from what i can gather from the video has no magnetic field, atleast it seems to work that way. if you are sending other small circles towards it you must calculate that circles acceleration towards the big circle and how if at all the big circle can attract it until it settles into a uniform orbit.
- 08-28-2010, 05:55 PM #10
Senior Member
- Join Date
- Jul 2008
- Posts
- 125
- Rep Power
- 0
Similar Threads
-
Josephu's Circle
By Pyrexkidd in forum New To JavaReplies: 8Last Post: 08-01-2010, 08:44 AM -
Check The Collisions
By Luff in forum AWT / SwingReplies: 7Last Post: 06-23-2010, 12:30 PM -
Circle arrays
By n00b in forum New To JavaReplies: 15Last Post: 05-05-2010, 05:04 PM -
Circle and line
By c_walker in forum New To JavaReplies: 1Last Post: 01-27-2010, 03:56 AM -
How to write numbers around a circle
By pheonix in forum New To JavaReplies: 8Last Post: 06-11-2009, 10:20 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks