Visualization Behind "Fit Range" VOP Node !!!

   1182   6   1
User Avatar
Member
34 posts
Joined: 12月 2018
Offline
plz someone explain me the workings of fit range vop node and if it's possible plz share the mathematical formulae if it's helpful in visualization . keywords - “mechanics of fit range vop node”
User Avatar
Member
310 posts
Joined: 2月 2017
Offline
Hey papon,

“fit range” takes values from one range for example from -1 to +10 and “fits” them into a new range for example 0 to 1.
So a value that used to be -1 is 0 after the operation.

Cheers
CYTE
User Avatar
Member
34 posts
Joined: 12月 2018
Offline
CYTE
nge” takes values from
can you elaborate the mechanics behind it ? then it might be helpful .
User Avatar
Member
5460 posts
Joined: 7月 2007
Offline
papon
can you elaborate the mechanics behind it ? then it might be helpful .
it's just math so while I'm not sure what exact math is behind houdini fit function it will be along these lines
https://rosettacode.org/wiki/Map_range [rosettacode.org]

just note that fit() function (Fit Range VOP) returns clamped results while efit() function (Fit Range Unclamped VOP) will not clamp the results
Edited by tamte - 2019年7月22日 11:09:21
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
23 posts
Joined: 6月 2021
Offline
CYTE
Hey papon,

"fit range" takes values from one range for example from -1 to +10 and "fits" them into a new range for example 0 to 1.
So a value that used to be -1 is 0 after the operation.

Please tell me, where and how to look at the description of the FitRange nodes?
Here is a description on the site: https://www.sidefx.com/docs/houdini/nodes/vop/fit.html [www.sidefx.com]

But, I do not see a description of the Input parameters, what types they are and what the fit range node returns.
Is there such a description? or should I guess myself what the houdini developers did there?
Sidefx
User Avatar
Member
555 posts
Joined: 2月 2017
Offline
here's a visualisation, I used VEX fit in a wrangle but it should be the same as a VOP (if you view the code in the VOP you'd see it calls vop_fit(), how you drill down further I don't know, you'd probably reach unreadable machine code)

Anyway, visually it remaps your min/max to newmin/newmax...

Adjust MinX, MaxX, NewMinX, NewMaxX and observe...try NewMinX = 4 and NewMaxX = -1 and you'll see it crosses over itself.

So here's my reverse engineering

mathematically: (it's just ratio)

x / (MaxX - MinX) = new x /(NewMaxX - NewMinX)

therefore, the fit is getting the new x value by:

new x = x * (NewMaxX - NewMinX) / (MaxX - MinX)

just my guess...don't sue me if your computer explodes.

ps: I'm quite confident on my logic as I had to write my own remap in MCG (hush....3dsMax!) and that's what I used..it worked fine I think.
Edited by vusta - 2021年6月13日 18:13:55

Attachments:
vu_fit.hipnc (93.9 KB)
fit.jpg (132.7 KB)

User Avatar
Member
555 posts
Joined: 2月 2017
Offline
ah, spotted a little detail, here's a file that has the fit and also the math
so in the math. I needed to offset between old and new starting points and that's it, switch between the fit and math nodes and they should be the same.

Attachments:
vu_fit2.hipnc (131.0 KB)

  • Quick Links