Jump to content
kiryha

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); 
    }

LinesCircle_01.PNG

circlesBetweenLines_002.hipnc

Share this post


Link to post
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);
    int pt = addpoint(0, pos);
    setpointattrib(0, "pscale", pt, size * 0.5, "set");
}

 

iterate_copies.hipnc

  • Like 1

Share this post


Link to post
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 this post


Link to post
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.

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×