I'm trying to write a simulator for neoballs. I'm doing only 2D for a start, in which each ball has a magnetic moment, m, that is in the x-y plane.
The simulator will use time-step integration at 60 fps, and typical collision detection stuff. For the magnetism I intend to compute force and torque between each pair of balls on every frame.
I think it will be ok to approximate each little ball as a "point dipole". What is the formula for force and torque?
For the force I have this from wikipedia
${\displaystyle \mathbf {F} (\mathbf {r} ,\mathbf {m} _{1},\mathbf {m} _{2})={\frac {3\mu _{0}}{4\pi r^{5}}}\left[(\mathbf {m} _{1}\cdot \mathbf {r} )\mathbf {m} _{2}+(\mathbf {m} _{2}\cdot \mathbf {r} )\mathbf {m} _{1}+(\mathbf {m} _{1}\cdot \mathbf {m} _{2})\mathbf {r} -{\frac {5(\mathbf {m} _{1}\cdot \mathbf {r} )(\mathbf {m} _{2}\cdot \mathbf {r} )}{r^{2}}}\mathbf {r} \right]}$
But I think it gives the wrong answer. No matter what the direction of $\mathbf{m} _{1}$ or $\mathbf{m} _{2}$, I think the force must be always parallel to r to conserve angular momentum. However, suppose $\mathbf{m} _{1}$ is parallel to r and $\mathbf{m} _{2}$ is perpendicular:
All terms except the first vanish, and F is in the direction $\mathbf{m} _{2}$, which is not possible? Common sense tells me F should be zero in this case! What am I doing wrong?
Also I need a formula for the torque. I know $ \mathbf{\tau=m\times B } $, and on the same wiki page I got
${\displaystyle \mathbf {B} (\mathbf {m} ,\mathbf {r} )={\frac {\mu _{0}}{4\pi r^{3}}}\left(3(\mathbf {m} \cdot {\hat {\mathbf {r} }}){\hat {\mathbf {r} }}-\mathbf {m} \right)}$
(I dropped the dirac term, because I don't need it).
I haven't tried it yet, but I think I can compute the the torque around the center of mass of $\mathbf{m} _{2}$ with $ \mathbf{\tau=m _{2}\times B(m _{1}, r) } $ where r is position of $\mathbf{m} _{2}$ relative to $\mathbf{m} _{1}$. Since all the balls have identical mass and magnetism, the torque on $\mathbf{m} _{1}$ is the same but with opposite sign.
Does that look reasonable?
EDIT: the above force formula seems to be rubbish, but the flux density(B) is reasonable. I'm wondering if I can just use $ \mathbf{\tau=m\times B } $ for torque and $ \mathbf{F=(m\cdot B)\hat {\mathbf {r} } } $ for force. It has a nice symmetry, and gives good results in the simulation.
EDIT2 Another curious contradiction. According to this wiki page, the potential energy of a magnetic field is given by:
${\displaystyle H=-{\frac {\mu _{0}}{4\pi |{\mathbf {r}}|^{3}}}\left(3({\mathbf {m}}_{1}\cdot {\hat {\mathbf {r}}})({\mathbf {m}}_{2}\cdot {\hat {\mathbf {r}}})-{\mathbf {m}}_{1}\cdot {\mathbf {m}}_{2}\right)}$
And this implies as long as m2 is perpendicular to m1 and r, the potential energy is ZERO. Since force is the gradient of potential over space, then the force must be also zero in that case. What am I misunderstanding?