p5-matter-examples
p5-matter-examples copied to clipboard
Magnet class doesn't behave like a magnet
We (@b-g and me) used the magnet class in the "attractor duo" example and noticed that it might not behave like an actual magnet 😆
I think in reality once an element comes closer to one magnet, it would snap towards that magnet, because pull force is not linear to distance.
Apparently the pull force of a magnet follows the "inverse square law".
Maybe you know more @ByronStar
I have added Newton's Law of Gravity to the Magnet class as defined in https://github.com/liabru/matter-attractors/blob/master/build/matter-attractors.js libaru's MatterAttractor plugin. The attractor duo example is changed accordingly. The static bodies need mass defined - otherwise ist is Infinite. Please have a look @stephanbogner and comment if this is not the desired result.
@ByronStar
Thanks for fixing this 👍
I renamed the example back to magnet
and magnet-duo
and reexported the docs
The static bodies need mass defined - otherwise ist is Infinite. That is good to know too!