Long Range Interaction or Variable Force

Share your projects and Chipmunk enhancements.
Post Reply
User avatar
juanpi
Posts: 24
Joined: Wed Jan 30, 2008 3:52 pm
Contact:

Long Range Interaction or Variable Force

Post by juanpi »

Hi every body,
Finally I got a humble result. The idea is simple, to program a group of methods fro solving long range interactions as electric, magnetic, and gravitational forces between the body in Chipmunk.
I did it but there are still somethings to polish a bit more.
  • At the moment the loop for calculating the net force over each body implies a loop over all other N-1 bodies. The idea is to use the action reaction principle to go only over N*N/2 elements.
  • The radio of interaction covers all the space. It would be nice to define an effective range. Maybe one can use cpShape for this...or just a simple filter with cpArray methods.
  • I have problems with interprenetration and i can not get intuition on how to fill the size of the spatial hashes...help!!
http://www.youtube.com/watch?v=GMEigIkd_x8

Ok, I hope you find this interesting.

To achieve this I added two fields to the cpBody structure, two methods on cpSpace and modified cpSpaceStep to calculate the force before updating the velocity. Do you have a better idea? please tell me.

P.S.: I am adding a kind of thermal noise to the bodies, that is why they move kind of randomly. Also there is noise in the angular speed...equipartition of the energy, uh. But this feature is not well implemented yet, Iam working on it.
User avatar
juanpi
Posts: 24
Joined: Wed Jan 30, 2008 3:52 pm
Contact:

Re: Long Range Interaction or Variable Force

Post by juanpi »

This is another video...

http://www.youtube.com/watch?v=ikLGmk9FDF8

I am testing different configurations. Speed is still ok, even not using the action-reaction principle.
The property ruling the long range interaction was added in cpBody->q, but now i see that maybe is better to include it as a new shape, so one can add many of this properties to a body...
In the video I am using a kind of eletrical interaction
F=-q1 *q2/r^2
Where q1 and q2 are the properties of two bodies. In this case the property can be called charge.
If we link the charge as a new shape (so the field cpBody->q is moved to cpShape->q) we have to think that the charge is a property of the shape and not of the body...mmm...sounds good. I will try.
Ezequiel
Posts: 8
Joined: Thu Jan 10, 2008 1:50 pm
Contact:

Re: Long Range Interaction or Variable Force

Post by Ezequiel »

There seems to be a glitch on how fast the little circles bounce on the big one.

Why do you think it is?
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: Long Range Interaction or Variable Force

Post by slembcke »

Very interesting. Now I have a national museum exhibit and some academic work using Chipmunk. :)

To answer your question about a better way to update the interaction forces. A couple things to consider, there is a data pointer that allows you to attach custom data to shapes (and bodies in the trunk version). Also in the trunk version bodies have user definable integration functions. They default to just the normal integration functions, but you can redefine them to provide new behavior like this. I had intended them as a way to provide custom gravity and and interactions like applying spring forces. So this fits right in.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
juanpi
Posts: 24
Joined: Wed Jan 30, 2008 3:52 pm
Contact:

Re: Long Range Interaction or Variable Force

Post by juanpi »

Ezequiel wrote:There seems to be a glitch on how fast the little circles bounce on the big one.

Why do you think it is?
Basically the problem is that the charge property is in the cpBody structure. This means that the static ball in the middle is not a staticBody but a body that is moved back in place after each time step. All the calculations of impulse exchage between the small balls and the big one are solved using the "moving big ball" so the bouncing is increased a little. I will fix this soon.

Slembcke: I will take a closer look to the trunk version. Thanks for the pointers.

We are on the move...
:D
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests