Help with Attractor-Repellant Point Cloud in Grasshopper

Hello,

I’m working on a visualization where a cloud of points hovers above a map of Cairo. The cloud’s density is influenced by attractor and repellent points that I define on the map. The idea is that the resulting diagram could reveal spatial insights about the city based on where density accumulates.

I have a rough Grasshopper script that partially works, but I’m facing two issues:

  1. I’m unsure how to implement repellent points in addition to attractors.
  2. With just five test points, my file is already running very slowly.

Is there an alternative approach that allows for many input points while maintaining reasonable performance? I’m relatively new to Grasshopper, so any guidance would be greatly appreciated.

Thanks!



points_density_2021Apr15a (1).gh (24.8 KB)

you didn’t internalize geometries in the gh file

but I tell you in advance, the main reason that simple definition is running slow is because of this Sphere component :slight_smile:

replace that with Mesh Spheres or eventually with Symbols, and you won’t have performance issues anymore

2 Likes

Thank you so much! That seems to have fixed the performance issue. Do you have any insight on how to build repel functionality into the script? Also, is the current way I’m bringing in pts the most efficient or is there a better way to plug multiple points into the function?

in your definition the way points are being attracted is literally “each point is influenced only by its closest attractor, any other attractor point is ignored” (and that depends on the “Closest” option of the Pull Point component)

what kind of attraction behavior are you looking for?

Essentially, the points represent areas in Cairo that people are either drawn to or avoid. I currently have these locations as point objects in Rhino. My goal is to visualize a point cloud above Cairo that becomes denser in areas with a high concentration of attraction points.

Repellent points, on the other hand, should influence the spread of the cloud by pushing points away, creating zones of lower density. Ideally, the final visualization would reveal pockets of high-density points, which could serve as key sites for further study.

Right now, the points in my script simply move directly toward the nearest attractor. However, instead of acting like direct pull points, the attractors should behave more like magnets—exerting a field of influence rather than just a nearest-point relationship. The density of points wouldn’t necessarily be directly above a point but attracted by it.

Sorry for the lack of grasshopper knowledge, but I’ve been struggling to find examples of what I’m trying to make online.

this is a very basic setup of static attraction/repulsions, but I think you are probably looking for a dynamic simulation, which is just a slightly different variation of this, will show it at the end

in a basic setup, for instance:

  • points in the green area are pulled toward the green circle center, the farther from the circle center the more pull
  • points in the blue area are pushed away from the blue circle center, the closer to the circle center the more push
  • points in the yellow area are subject to push/pull from both
  • points outside of any circle are just not influenced by anything

if I turn on the Vectors preview, you can see the forces visualized as arrows, which makes them much easier to understand:

once you have calculated all the forces that act for each point, you can sum those up into a final movement vector:

so the final result would look something like this, also increasing the number of attraction/repulsion points:

attraction-repulsion-points_inno.gh (20.5 KB)

the main problem of this sort of static simulation is that, in order to have some sort of noticeable movement of each given point, you might want to increase the multiplier of each vector by a lot… which would just make stuff a little bit funky and create islands of points, like:

usually in this situation you want to use very small vector multipliers, and iterate through various stages of the simulation in a loop, where you iteratively update the position of any given point depending on its position

for instance, using Anemone plugin:

and of course you can stop the simulation and for instance change the radius of influence of attractor/repulsion points, then start the simulation again

a radius of influence that changes during the simulation might indicate (just making an example) neigborhoods that you want to avoid at night but you are fine to visit with daylight, or pubs that are open only at a certain time… I mean, you can also hard-core change the influence of each point and graph it in such a way it changes with the simulation, during the simulation itself :slight_smile: so you have infinite opportunities

stupid example to animate attractors with graphs, could be something like this:

and the very same way you can animate repulsion:

Loop_attraction-repulsion-points_inno.gh (30.6 KB)

consider that you can have attraction/repulsion points moving during the simulation, you can have their force parametrized over time both in intensity and behavior… I mean, possibilities are endless, just define their behavior, split it in as many frames as the simulation iterations are, and use List item to pick the right one for each step (or if they follow functions, they can just be calculated depending on iteration)

a closing thought, this stuff might come much easier via code :slight_smile: because if you have many different attraction/repulsion points, where for each you define its private behavior, spaghetti can become very messy very fast :slight_smile:

1 Like

Very cool.

This is amazing. It’s exactly the sort of behavior I was looking for. Thank you so much.