Magnetic attraction/repulsion

I’m trying to simulate magnets in grasshopper using kangaroo. I found that magnetic snap is not suitable for my need because it does not work in real time. For example I’ve two points and I need them to act like ‘like poles’. Using magnetic snap(with negative strength) and bouncy solver, the simulation only runs once and the points reach their equilibrium state. Now, if I move one of the points closer to the other, there is no effect of the repulsion. I have to reset the simulation to see any effect. Is it possible to simulate my requirement in kangaroo?(real time magnetic attraction/repulsion)

Here’s an example of an attraction/repulsion goal.
PLaw_example.gh (14.8 KB)
(you’ll need to set the referenced assembly location of KangarooSolver.dll when you open it - usually this will be in
C:\Program Files\Rhino 6\Plug-ins\Grasshopper\Components
if you are on 6, or
C:\Program Files\Rhino WIP\Plug-ins\Grasshopper\Components
if you are using the WIP)

You can make it negative for repulsion or positive for attraction.
The exponent controls how quickly the force falls off with distance.

3 Likes

Playing a bit more with this using pointclouds:


attraction.gh (10.0 KB)
3 Likes

Did you try the file in the first link? (PLaw_example.gh)
That is a goal that lets you set the interaction between pairs of particles.

1 Like

Thanks a lot Daniel! After a few modifications the first link was really helpful.
Btw, just started using Rhino, grasshopper and kangaroo and I feel its a great piece of software, kudos for that!