Collision Response With Circles

Sage
Posts: 1,066
Joined: 2004.07
Post: #1
So thanks to Skorche, I got my basic particle system all working so I began working on collision response. I decided against using just particles so I implemented some circle collisions with lines. It works perfectly with single circles, but when I try and make a constraint with multiple circles, the "shape" just sticks to the ground without bouncing. I'm not sure where the problem is, so I just uploaded the project. If anyone can take a look and find the problem (or guess what might be causing it), I'd appreciate it.

Here's what I know that might help:
I am updating the world 180 times a frame (roughly) and each update does three things: first it updates all the particles, then it calculates the constraints, and then it finds and handles collisions. If that sounds ok, then I'm not sure what the problem is.

Download

Edit: If you push the D key, you can break the constraints in the rope.
Quote this message in a reply
DoG
Moderator
Posts: 869
Joined: 2003.01
Post: #2
It doesnt seem to build correctly on my end, nothing happens, nothing moves. Care to post a binary?
Quote this message in a reply
Sage
Posts: 1,066
Joined: 2004.07
Post: #3
I apologize. I forgot that you have to press P to begin the simulation (to avoid the huge gaps in frame rate during initialization).
Quote this message in a reply
Sage
Posts: 1,403
Joined: 2005.07
Post: #4
it doesnt compile for me eitherr

Sir, e^iπ + 1 = 0, hence God exists; reply!
Quote this message in a reply
Sage
Posts: 1,066
Joined: 2004.07
Post: #5
Odd. Any errors or just doesn't work? I'll get a binary up in a few minutes.

Edit: Binary up: Download (Remember to press P to begin simulation)
Quote this message in a reply
Sage
Posts: 1,482
Joined: 2002.09
Post: #6
Not really sure what the problem is. You want the box to bounce? Are you using a restitution term in your collision equations?

Also, I noticed that you are resolving collisions in the same function where the collision detection is being perfomed. You probably want to consider rearranging your design if you want to support more that circles and lines. A better solution would be to have your collision detection return a list of contact points and their normals. Then you can handle all your collisions in the same manner.

Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
Quote this message in a reply
Sage
Posts: 1,066
Joined: 2004.07
Post: #7
Skorche Wrote:Not really sure what the problem is. You want the box to bounce? Are you using a restitution term in your collision equations?
I'm not sure what a restitution term is so I'll Google that. I do want the box to have a little bounce when it hits the ground.

Quote:Also, I noticed that you are resolving collisions in the same function where the collision detection is being perfomed. You probably want to consider rearranging your design if you want to support more that circles and lines. A better solution would be to have your collision detection return a list of contact points and their normals. Then you can handle all your collisions in the same manner.
That's what I've been working on today sort of. I have a Particle class which has two methods: one for detecting a collision with a line and one for handling that collision. Then I'm using some polymorphism to handle the collisions with the CircleShape class overriding the Particle class's methods. Eventually I'll come up with a base class for the LineShape as well, but for now it's working. I'm not sure if your method would be better performance wise, which seems to be my current issue. I'm trying to find a way that my system can have lots of objects and run quickly and accurately. If I don't do a loop over the world update, it runs very quickly, but isn't as accurate. Any ideas on that?
Quote this message in a reply
Member
Posts: 469
Joined: 2002.10
Post: #8
Your build problem is because you don't have SDL headers in your search path. To fix, do the following:
  1. Expand "Targets" in the project browser's Groups & Files.
  2. Right click the "Spyscroller" target and Get Info (or select and cmd-i)
  3. Search to "User Header Search Path", select, click "Edit"
  4. go to the Finder and find the SDL.framework/Headers in the project folder
  5. drag/drop this folder into the User Header Search Paths sheet. You'll get ""$(SRCROOT)/Frameworks/SDL.framework/Headers". (alternatively you can just type in the preceding in a new entry)
  6. Repeat for SDL_image.framework/Headers
  7. click OK, close the window, and build again.

---Kelvin--
15.4" MacBook Pro revA
1.83GHz/2GB/250GB
Quote this message in a reply
Sage
Posts: 1,482
Joined: 2002.09
Post: #9
I should be more specific what I meant by "restitution term", which was not very correct or helpful. The coefficient of restitution determines how bouncy a collision is. For collisions, the impulse equation would be similar to the one used for calculating joints.
j = (v2 - v1)/(1/m1 + 1/m2)
would become:
j = -(v2 - v1)(e + 1)/(1/m1 + 1/m2)
Where e is the coefficient of restitution. 0 would give you an inelastic collision (no bounce), and 1 would give you a perfectly elastic collision (lots of bounce). You would apply the impulse in the same way however.

As for speed improvements, the biggest thing you can do is to use a spatial data structure of some sort in your collision detection. Your next best bet would be to move to Jakobsen physics. The more I've seen of what you are trying to do suggests to me that you would be better off using that instead. The remaining options that I can think of are significantly more complicated.

Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Collision Response merrill541 7 3,705 Nov 8, 2008 09:14 PM
Last Post: merrill541
  Edge Collision Response Problem Bachus 9 6,320 Mar 21, 2008 03:34 PM
Last Post: Skorche
  Simple 2D collision response Wowbagger 1 4,666 Jul 30, 2007 03:02 PM
Last Post: Skorche
  Collision Detection between 2 circles cheatdeath 10 3,587 Feb 6, 2006 02:04 PM
Last Post: MattDiamond
  Collision Response Question blobbo 30 12,029 Oct 10, 2005 05:19 PM
Last Post: Andrew