For gravitation field, the potential energy is U(r)=-GMm/r (gravity field=-GMm/r[sup]2[/sup]).
For electric field, the potential energy is U(r)=KQq/r (electric field=KQq/r[sup]2[/sup]).

So the above gravity field simulation will be similar to one free charge moving around another fixed (and oppositive)charge.
If two charge are the same polarity, they will repel each other instead of attract with each other.
I will try to create another simulation which two particle moving around their center of mass.

But I do not understand what do you mean about "[b]magnetic particle[/b]"?

I hope the following simulation is what you want.
You can change the position and velovity for each change particle, however, under the constraint that:
The center of mass is at x=0,y=0 and the velocity for center of mass is zero. Otherwise, both particles will move out the simualtion region gradually.

Remember: particle actually moving in the x-y horizontal plane. The trajectory in the simulation is not the real trajectory for those particle. Projection of their trajectory to x-y plane is the real trajectory. The change in the z-coordinate in the simulation is used to show how the potential energy change (i.e. Z is the potential energy)

VIEW or DOWNLOAD ejs xml source
then click to translate strings for selected locale.


Press the Alt key and the left mouse button to drag the applet off the browser and onto the desktop.