Magnetic interaction

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

Magnetic interaction

Post by juanpi »

Hello people,

I have implemented magnetic forces between two bodies. I use all what I posted before, Long range interaction and Verlet velocity integration.
I will post the equations for force in wikipedia and my blog http://www.lavidasegunjuanpi.blogspot.com in a few days.
Meanwhile enjoy the videos :D
http://www.youtube.com/watch?v=0K-RD60Rloc
http://www.youtube.com/watch?v=0J4ld6X8I6U
http://www.youtube.com/watch?v=K-2uitdJDNg

Cheers,
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: Magnetic interaction

Post by slembcke »

Nifty.

I was thinking about magnets the other day after watching your video with the electrostatic charges. Definitely makes for some interesting videos.
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: Magnetic interaction

Post by juanpi »

hi all,
You can find a formula for the forces here

http://en.wikipedia.org/wiki/Magnetic_moment

I checked it a few times, but if somebody finds a mistake feel free to correct.

I would like to prepare a demo on long range interaction and how to change the integrator without changing Chipmunk source code...Do you find this useful or not? Nonetheless i cannot give a date for the release of such tutorial.

Cheers,
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: Magnetic interaction

Post by slembcke »

Yeah, go for it. I'm sure someone would find it useful. I've thought about adding some electrical charge puzzles to one of my upcoming games actually. Could be a nifty idea.

Speaking of which, I really need to get that Chipmunk wiki put up...
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: Magnetic interaction

Post by juanpi »

slembcke wrote:Yeah, go for it. I'm sure someone would find it useful. I've thought about adding some electrical charge puzzles to one of my upcoming games actually. Could be a nifty idea.
Hey, I am also working in a puzzle game (hinged dissection of polygons or in other words folding puzzles). For the moment without physics...maybe we can share some ideas. PM me if you are interesting in sharing some brainstorming...and a flash sub-demo, jejej
coolman
Posts: 45
Joined: Fri Feb 27, 2009 7:59 am
Contact:

Re: Magnetic interaction

Post by coolman »

Hi juanpi,

Can you share some source code?

I would like to see how is done the magnets in Xcode.
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: Magnetic interaction

Post by slembcke »

I've added his example as a new demo in the trunk version of Chipmunk.

You can see it here: http://code.google.com/p/chipmunk-physi ... Electric.c
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
coolman
Posts: 45
Joined: Fri Feb 27, 2009 7:59 am
Contact:

Re: Magnetic interaction

Post by coolman »

Great!

Thanks,

Pablo
ioannis
Posts: 6
Joined: Fri May 29, 2009 3:09 pm
Contact:

Action-Reaction patch (not ready yet)

Post by ioannis »

I've tried to make use of the action-reaction principle to reduce the computational load. I've uploaded the patch here.
The CPU load is reduced, however, there seems to be a problem, most likely with the torques. I'm not very familiar with the equations or the inner workings of Chipmunk, so probably some assumptions I made are wrong.

One such assumption (which relates to how Chipmunk works), is that the force functions are invoked for each body in order (as found in the cpSpace::bodies)

can someone please check this patch?

EDIT: patch removed. look below
Last edited by ioannis on Wed Nov 18, 2009 11:12 am, edited 1 time in total.
ioannis
Posts: 6
Joined: Fri May 29, 2009 3:09 pm
Contact:

Action-Reaction patch

Post by ioannis »

ok, I think I found the error. The sign of the forces was wrong. I'm including here the revised patch. Please do check it as well, see if it does behave as expected.
Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests