VEX: Select lowest point (Y) of each primitive?

   293   5   0
User Avatar
Member
138 posts
Joined: April 2017
Offline
Hi!

I used a copy-to-point to distribute a line (2 points per line) on a curve and I would like to select all the lowest points of each primitive so I can snap them to the ground.

Is this a for-each thing?

Thanks.

-Olivier

Attachments:
get_lowest_point_per_prim.JPG (21.0 KB)

User Avatar
Member
1319 posts
Joined: Sept. 2011
Offline
In an attrib vop/wrangle running over primitives, you can loop over the points in the current primitive (there is a function that returns an array of points associated with a primitive number) and in the loop find the point with the lowest y coordinate. This would work in the most general case.

In your case, you can probably assume some facts about the input. Maybe you know that the point with no neighbors is always the lowest point. Maybe you can assume that the last/first vertex of the line is the lowest point. In these cases, there is no need to loop over all of the points.
User Avatar
Staff
2966 posts
Joined: July 2005
Offline
doesn't answer your question but…
when building procedural things it's very handy to use groups - in this case groups on your line before its copied would allow you to do stuff to the group after…
Michael Goldfarb | www.odforce.net
Senior Technical Director
SideFX
www.sidefx.com
User Avatar
Member
346 posts
Joined: Oct. 2011
Offline
Before you copy the line to the points, give the last point of the line an attribute that you can access later, like “last_point=1”
Or you can use the bounding box to find the position of the lowest point in a wrangle like this:
vector min;
vector max;
getbbox(0, min, max);
float y_component = min.y;

if(@P.y < y_component + chf('Threshold') && @P.y > y_component - chf('Threshold')){
   @a = 1;
}
And then set a threshold of 0.001.

-b
http://www.racecar.no [racecar.no]
User Avatar
Member
127 posts
Joined: Feb. 2017
Offline
not VEX.. but just a proof of concept
Edited by vusta - March 2, 2018 16:36:51

Attachments:
BottomToGround.hipnc (67.3 KB)

User Avatar
Member
138 posts
Joined: April 2017
Offline
Ahh! ok ok.

The idea of making a group before making copies or, simply using a group range and selecting every 2 would work nicely!

I'll try to do the vex(primitive) thing also, just to understand it more.

Thanks for all the ideas. I learn stuff every day!

-Olivier
  • Quick Links