New to VEX.
I try to remap data generated from rand(@ptnum) to the bounds of 0 to 1 using the fit() function.
The fit() function requires original bounds to be input, then I get this idea, what if I don't know the bounds of original data, and just don't like to make it into an attribute and see the Geometry Spreadsheet?
Is there any way I can determine the bounds of data inside VEX code?
animatrix_
2023年3月27日 15:39:13
If the code is running in parallel (Run Over is not set to Detail), then you can't know the bounds until the execution finishes.
You can still get the min and max of scalar values using setdetailattrib:
https://www.sidefx.com/docs/houdini/vex/functions/setdetailattrib.html [
www.sidefx.com]
But this will also require the code to finish execution.
jsmack
2023年3月27日 19:26:28
Quan
I try to remap data generated from rand(@ptnum) to the bounds of 0 to 1 using the fit() function.
The fit() function requires original bounds to be input, then I get this idea, what if I don't know the bounds of original data, and just don't like to make it into an attribute and see the Geometry Spreadsheet?
rand() already generates data in the bounds of 0 to 1, so no fit is required.
GOgraphR
2023年4月27日 20:18:54
Hey Quan,
if you don't mind using two additional SOPs then I'd suggest to use attribute promote, unset Delete original, set change new name the target class would be set to detail and use one to get the maximum and another to get the minimum of your attribute.
Then you can get them bounds in your vex code detail(0,"xMax,0)
and detail(0,"xMin",0)
if you insist staying within VEX, you have to loop over all points and do the Min/Max explicitly.
Min=(v<=Min) ? v:Min
Max=(v>=Max) ? v:Max
Thats a so called "trigraph". which is exactly the same as an if (v<=Min) then {Min=v} else {Min=Min}