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.
Find minimum attribute value in vop
13732 10 2- Soothsayer
- Member
- 874 posts
- Joined: Oct. 2008
- Offline
- mattis
- 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]
- Antoine Durr
- 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
- Soothsayer
- 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:
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
Jobless
- Antoine Durr
- Member
- 321 posts
- Joined: July 2005
- Offline
SoothsayerNot sure what's clumsy about two attribpromotes.
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.
SoothsayerThe 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!):
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?
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.
- Soothsayer
- Member
- 874 posts
- Joined: Oct. 2008
- Offline
- anna_waldon
- 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.
Thanks.
- Pagefan
- Member
- 519 posts
- Joined:
- Offline
- anna_waldon
- Member
- 52 posts
- Joined: March 2008
- Offline
- chia
- Member
- 1 posts
- Joined: Sept. 2012
- Offline
- Solitude
- 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