Find minimum attribute value in vop

   13749   10   2
User Avatar
Member
874 posts
Joined: Oct. 2008
Offline
In a vopsop, is there an simple way to find the minimum value of an attribute, and the corresponding point that holds that value?

I tried using a detail attribute just before the vopsop but it seems I can only import point attributes? In any case I'd have to get the point number, and its getting messy.
--
Jobless
User Avatar
Member
17 posts
Joined: Oct. 2009
Offline
I don't know about doing it inside a VOP network, but couldn't you just do it with a attributePromote node - to find the minimum and then a delete node to get rid of all the other points. You could pipe the result into the VOP SOP, this may not be the best way to do it though. : :roll:
Portfolio / Tech. blog: http://www.theprocedure.se [theprocedure.se]
User Avatar
Member
321 posts
Joined: July 2005
Offline
Soothsayer
In a vopsop, is there an simple way to find the minimum value of an attribute, and the corresponding point that holds that value?

I tried using a detail attribute just before the vopsop but it seems I can only import point attributes? In any case I'd have to get the point number, and its getting messy.

It can probably be done, but will be very expensive. You'd have to put a for-loop around an import(), and compare each value to find the minimum. The problem is that you'd be doing this same loop for *every* point, rather than doing it once via a pair of attributepromotes (one to promote to detail using minimum, and the second to promote it back to a point attribute so that the same valule is available on every point).

– Antoine
Antoine Durr
Floq FX
antoine@floqfx.com
_________________
User Avatar
Member
874 posts
Joined: Oct. 2008
Offline
I've tried mattis method but in order to keep track of the point I need to copy it's minimum status back to the original geometry with an attribute transfer (the whole geometry needs to be kept intact because it resides in a dop network and values are updated every timestep.). So it works, but it's a bit clumsy.

What I don't understand about Antoine's method is how to compare each value with every other point? And how do I tag the minimum?

I wonder if there is a better way with the point cloud nodes. Some aren't documented but I wonder if they could be coaxed to work on incoming geometry points?

I am not so much interested in speed as in ease of use. :wink:
--
Jobless
User Avatar
Member
321 posts
Joined: July 2005
Offline
Soothsayer
I've tried mattis method but in order to keep track of the point I need to copy it's minimum status back to the original geometry with an attribute transfer (the whole geometry needs to be kept intact because it resides in a dop network and values are updated every timestep.). So it works, but it's a bit clumsy.
Not sure what's clumsy about two attribpromotes.
Soothsayer
What I don't understand about Antoine's method is how to compare each value with every other point? And how do I tag the minimum?
The resulting vex would look something like this (not tested, no Houdini in front of me, so don't sue me if it doesn't work!):

float minval = 1e6; # start big
float ptval = 0; # a place for result of import()
for (float i = 0; i<npt; i++) {
import(0, i, ptval, “attribute_of_interest”);
minval = min(minval, ptval);
}
# minval is now the minimum of attribute_of_interest


I am not so much interested in speed as in ease of use. :wink:

You might be when you realize that this is O(n^2) and you have a big, heavy geometry.
Antoine Durr
Floq FX
antoine@floqfx.com
_________________
User Avatar
Member
874 posts
Joined: Oct. 2008
Offline
Thanks, both methods for fine for my purpose. The vex one is indeed much slower for large meshes.
--
Jobless
User Avatar
Member
52 posts
Joined: March 2008
Offline
Could you possibly post an example with two attributePromote nodes as described above? I am managing to create/promote attributes fine them fine but do not know how to use them. E.g., what if I wanted to draw a line from an arbitrary point to the point with the maximum length attribute? How do I select that particular one? Or delete the rest? Or something else?

Thanks.
User Avatar
Member
519 posts
Joined:
Offline
If you have point or primitive attributes you can find minimum or maximum values (and average values and a lot more) by using an attributepromote SOP. Pipe in the geometry with the attributes, set the new class to (for example) detail and the promotion method to whatever you need.
User Avatar
Member
52 posts
Joined: March 2008
Offline
Thank you, I have done this. I am just not sure how to use the result of this promotion.
User Avatar
Member
1 posts
Joined: Sept. 2012
Offline
anna_waldon
Thank you, I have done this. I am just not sure how to use the result of this promotion.

I think you can use a group SOP and an expression like:
$ATTRIBNAME==detail(“../attribpromote1”,“min_attribname”,0)
to filter this point out.

Not sure if you still need this after such a long time:p
User Avatar
Member
373 posts
Joined: March 2009
Offline
Soothsayer
I tried using a detail attribute just before the vopsop but it seems I can only import point attributes? In any case I'd have to get the point number, and its getting messy.

I was able to import a detail attribute with no problem using a parm node in a vop (don't use import attribute). As for getting the point that matches, should be simple enough by just checking if the values are equal, but obviously depending on what you're doing, more than one point can match that minimum value (ie: you're looking for minimum velocity, and 1/2 the points have a v of 0,0,0 you will get 1/2 the point coming back as equal).
Ian Farnsworth
  • Quick Links