[Physics] Creating a 2d magnet simulator

electromagnetismmagnetic fields

I need to create a "simple" magnet simulator, unfortunetely I have little to no physics knowledge.

The best way to describe my idea is, imagine a hockey table. There's a disk and I need to throw it around. So far no problems, I just have to calculate the disk acceleration and position along the time based on an initial force.

Now, let's suppose it's a magnetic disk and I want some fixed magnetic disks around the table. Now I want to throw the disk around the table again, but it have to have it's route modified when it goes near another disk(either by being repelled or attracted).

I have been looking for a few hours but I can't wrap my head around these formulas and how to put them together. Can someone please enlighten me on how would I go about solving this problem?

Best Answer

You probably want to simulate electrostatic charges for attraction and repulsion. See a simple simulation I made using JavaScript: http://jsfiddle.net/UbP7g/4/. Feel free to play around with the code and try changing some of the variables (such as the masses and charges of the particles).