Results 1 to 10 of 10
  1. #1
    Atriamax is offline Member
    Join Date
    Sep 2009
    Posts
    41
    Rep Power
    0

    Default 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.

  2. #2
    gafa's Avatar
    gafa is offline Senior Member
    Join Date
    Jun 2010
    Posts
    107
    Rep Power
    0

    Default

    Show us the problem code or error message please

  3. #3
    colpwd is offline Member
    Join Date
    Aug 2010
    Posts
    25
    Rep Power
    0

    Default

    What are you using to measure the rate of gravitation (movement) of the circles?

  4. #4
    Atriamax is offline Member
    Join Date
    Sep 2009
    Posts
    41
    Rep Power
    0

    Default

    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.

  5. #5
    Zack's Avatar
    Zack is offline Senior Member
    Join Date
    Jun 2010
    Location
    Destiny Islands
    Posts
    692
    Rep Power
    5

    Default

    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.

  6. #6
    paul pasciak is offline Senior Member
    Join Date
    Jul 2008
    Posts
    125
    Rep Power
    0

    Default 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.

  7. #7
    Atriamax is offline Member
    Join Date
    Sep 2009
    Posts
    41
    Rep Power
    0

    Default

    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!

  8. #8
    Atriamax is offline Member
    Join Date
    Sep 2009
    Posts
    41
    Rep Power
    0

    Default

    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.

  9. #9
    al_Marshy_1981 is offline Senior Member
    Join Date
    Feb 2010
    Location
    Waterford, Ireland
    Posts
    748
    Rep Power
    5

    Default

    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.

  10. #10
    paul pasciak is offline Senior Member
    Join Date
    Jul 2008
    Posts
    125
    Rep Power
    0

    Default Nice video

    The video looks pretty neat.
    The problem moves by too quickly
    to notice enough of it for me to
    form an opinion of what causes it.

Similar Threads

  1. Josephu's Circle
    By Pyrexkidd in forum New To Java
    Replies: 8
    Last Post: 08-01-2010, 09:44 AM
  2. Check The Collisions
    By Luff in forum AWT / Swing
    Replies: 7
    Last Post: 06-23-2010, 01:30 PM
  3. Circle arrays
    By n00b in forum New To Java
    Replies: 15
    Last Post: 05-05-2010, 06:04 PM
  4. Circle and line
    By c_walker in forum New To Java
    Replies: 1
    Last Post: 01-27-2010, 04:56 AM
  5. How to write numbers around a circle
    By pheonix in forum New To Java
    Replies: 8
    Last Post: 06-11-2009, 11:20 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •