# Per point distance VEX

## Recommended Posts

I am not able to get per point distance (parallel processing?), got the value from the last iteration in the loop for each point.

```// Mesure distance between pairs of point in each line
// Return as a @distance attribute
int allPoints[] =  expandpointgroup(0, "!*");
f@distance;

foreach (int currentPoint; allPoints){
vector pointPosition_L = point(0, 'P', currentPoint);
vector pointPosition_R = point(1, 'P', currentPoint);
@distance = distance(pointPosition_L, pointPosition_R);
}```

circlesBetweenLines_002.hipnc

##### Share on other sites

You can avoid parallel computing by setting the wrangle to detail or to numbers. A custom loop can then add up some offset value. Here is a rough sketch:

```float offset = 0.0;
for(int i = 0; i < @elemnum; i++){
float size = rand(i + 123);
vector pos = set(0, 0, offset);
offset += size * 0.5;
pos += set(0, 0, offset);
setpointattrib(0, "pscale", pt, size * 0.5, "set");
}```

iterate_copies.hipnc

• 1

##### Share on other sites

Thanks, Konstantin!
A very cool hint is setpointattrib(), I was looking for a way to add point attribute in detail mode!

##### Share on other sites

If you only want to know the distance of the same point id in input 1 you can keep the point wrangle type and the advantages of parallel execution:

`f@dist = length(@P - point(1, "P", @ptnum));`

Of course this only works if the input 1 has the same number of points as the first input.

• 1

##### Share on other sites

my approach using one liners...

vu_CurveLerp.hipnc

• 1

## Create an account

Register a new account