3
$\begingroup$

This is kind of a follow-up to Compute on all points in geometry nodes and How to calculate an attribute for each point which depends on every other point with the new for each zone.

I have two sets of points: a grid and a circle. I'd like to store an attribute on the point domain of the grid so that, for each grid point, the attribute would store the sum of all the inverted distance to each point of the circle.

I tried the following node tree but it does not work (I can disconnect the link between the capture node and the distance node and nothing changes).

node tree

Is the accumulate field the wrong approach here? How can I solve the issue (the goal here is to compute an electric potential that requires to sum 1/PM over the distribution, points P of the circle, for each point M of the grid)?

$\endgroup$
1

2 Answers 2

3
$\begingroup$

For each point of the grid, evaluate "Attribute Statistic" for the entire circle, which sums reciprocals of distances from circle points to currently evaluated grid point:

Alternative image hosting:

$\endgroup$
1
  • $\begingroup$ Thanks (+1). That does the trick! And thanks for the linked answer in comments. $\endgroup$
    – cjorssen
    Commented Oct 10 at 13:57
4
$\begingroup$

So, the problem seemed to be trying to measure distances between two arrays at the same time (one array for the grid, another for the points).

Since the grid is your target, I moved the foreach (in my case a repeat zone, since I don't have experimental Blender) to the circle instead and accumulated the potentials manually:

enter image description here

I tested the values by adding a viewer node reading from toto. I also added a translation to the circle just to make sure it was working properly.

With a "for each" node, you wouldn't need the "sample", you could probably "capture" position from the "element" instead. Then you would not need "iterations" value, and also woudn't need the "index".

The file is attached here

$\endgroup$
6
  • $\begingroup$ Thanks for your time (+1). Your alternative seems to work as well. $\endgroup$
    – cjorssen
    Commented Oct 10 at 13:56
  • $\begingroup$ Someone should benchmark and see if the foreach solution is faster, hopefully a lot faster, otherwise it's just a small QoL feature... $\endgroup$ Commented Oct 10 at 14:35
  • $\begingroup$ Probably faster, but even though it's not, it still saves lots of edit time, so..... What i'd love to see is a "loop while" node. $\endgroup$ Commented Oct 10 at 15:04
  • $\begingroup$ @DanielMöller Yes I think this is the only real code flow element that is missing, You can kind of emulate a while loop (repeat zones are slow, and that one is much slower) using this workaround: blender.stackexchange.com/q/320815/60486 $\endgroup$ Commented Oct 10 at 16:46
  • $\begingroup$ @MarkusvonBroady, can we really do a foreach "element" using the repeat zone? $\endgroup$ Commented Oct 18 at 17:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .