NTNUJAVA Virtual Physics Laboratory
Enjoy the fun of physics with simulations!
Backup site http://enjoy.phy.ntnu.edu.tw/ntnujava/
December 17, 2017, 08:35:25 pm *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
Never too late. Never too early. ...Wisdom
Google Bookmarks Yahoo My Web MSN Live Netscape Del.icio.us FURL Stumble Upon Delirious Ask FaceBook

Pages: [1]   Go Down
  Print  
Author Topic: multiple collisions with gravity  (Read 9774 times)
0 Members and 1 Guest are viewing this topic. Click to toggle author information(expand message area).
frecka
Newbie
*
Offline Offline

Posts: 1

«
Embed this message
on: December 31, 2008, 03:01:37 pm »

I've recently become interested in programming physics simulations and played around with elastic collisions of balls using java.  A natural extension of this for me was to add gravity and see how the coding for collisions between pairs of balls works with larger numbers of balls.  In particular, I was hoping to get a simulation in which I could throw a bunch of balls together and have them stack up on the ground in a realistic manner.

I have an applet online with what I have so far at:
http://cfb.qqnoobs.com/Balls/

As you can see for yourself by adding enough balls to fill a significant portion of the virtual room (with gravity on), the stacking of balls works to some extent.  But balls eventually get pushed together and stuck overlapping and frozen in space for a while, which is obviously a problem.  My question is if you have any ideas for a good way to implement the collisions of multiple balls during the course of one frame of motion.

The way I handle it right now is just cycling through each pair of balls once per frame to see if each pair collides. If a pair is found to collide, I move the two balls to where they are located the instant before they collide (ie 1 pixel separation) and change the speeds accordingly for the elastic collision of equal masses. In subsequent checks for collisions, I use the new ball speeds and positions. So if a ball collides multiple times in a cycle, it'll end up in the last place it collided, which may very well be overlapping with another ball.

I've experimented with also moving the ball after colliding according to new velocities, which just makes the overlapping problem much worse. I've also tried looping the collision cycle in each frame to run as long as there are still two balls colliding, but then it gets stuck in infinite loops when balls just don't become separated.

I also have one last side question. Right now collisions between two balls are completely elastic, and collisions between a ball and a wall have a coefficient of restitution of 0.8. How would I go about making the balls lose energy when colliding with each other so that they don't constantly bounce around like they're undergoing Brownian motion? Can I just multiply their speeds after collision by a similar coefficient of restitution, or will the directions change because of this? (I tried using a restitution coefficient, which has an annoying effect of making balls get stuck together earlier and frozen in space instead of rolling off each other.)

That's all I have for now, thanks for any suggestions you have!
Logged
Fu-Kwun Hwang
Administrator
Hero Member
*****
Offline Offline

Posts: 3080



WWW
«
Embed this message
Reply #1 on: January 24, 2009, 06:06:36 pm »

I think the problem is coming from the way you treat the collision.
Try to treat two balls stick together when the relative speed between two balls is smaller than some minimum value (instead of always treat it as collision!).
Logged
Femida
Newbie
*
Offline Offline

Posts: 0

«
Embed this message
Reply #2 on: March 04, 2015, 02:33:53 am » posted from:,,Satellite Provider

What necessary phrase... super, remarkable idea
Logged
Pages: [1]   Go Up
  Print  
Never too late. Never too early. ...Wisdom
 
Jump to:  


Related Topics
Subject Started by Replies Views Last post
collisions
Questions related to EJS
Ka-lolek 3 8093 Last post August 19, 2008, 10:03:44 pm
by lookang
Ball line collision and response. multiple collisions at once
Request for physics Simulations
slayer 64 4 13190 Last post November 10, 2010, 08:55:50 pm
by lookang
Multiple Slit Diffraction
optics
ahmedelshfie 1 7944 Last post June 26, 2010, 12:45:27 am
by ahmedelshfie
How many images (Multiple Reflection from two plane mirrors)
optics
ahmedelshfie 0 9087 Last post May 20, 2010, 01:25:53 am
by ahmedelshfie
help for Rigid Body Collisions
Request for physics Simulations
sandeep1024 5 5020 Last post January 19, 2012, 07:40:51 am
by Fu-Kwun Hwang
Powered by MySQL Powered by PHP Powered by SMF 1.1.13 | SMF © 2006-2011, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 0.095 seconds with 23 queries.since 2011/06/15