Jump to content

Per point distance VEX


kiryha

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

Link to comment
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
Link to comment
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
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...