What it does
Remaps a value from a known range into a new one. fit01 assumes the input is 0..1 and maps it into your min and max; fit11 assumes -1..1, which is exactly what signed noise returns.
When to use it
Use it constantly: turning a 0..1 mask, ramp or rand() into a real-world range, or bringing sin() and Perlin noise (which return -1..1) into a usable range with fit11.
The VEX code
// fit01 maps 0..1 -> min..max; fit11 maps -1..1 -> min..max.
f@a = fit01(@P.x, 0, 10); // careful: @P.x is not guaranteed 0..1
f@b = fit11(sin(@Time), 0, 1); // sin() is -1..1, so fit11 is correct
Inputs and assumptions
- A value whose input range you know: 0..1 for
fit01, -1..1 forfit11. - The new min and max to map into.
- Runs anywhere; shown here in a points wrangle.
Common mistakes
- Feeding
fit01a value that is not actually 0..1 (like raw@P.x) - it clamps, so you lose everything outside the range. Use fullfit(v, omin, omax, nmin, nmax)when the input range is arbitrary. - Using
fit01on signed noise orsin(); those are -1..1, so reach forfit11. - Forgetting that
fitclamps to the new range - useefitif you need values to extrapolate past the ends. - Swapping the min and max, which inverts the mapping (sometimes handy, often a bug).
Frequently asked questions
What is the difference between fit and fit01 in Houdini?
fit remaps from an explicit input range you provide; fit01 assumes the input is already 0..1, so you only pass the new min and max. Use fit when the input range is arbitrary.
Why is fit11 used with noise and sin()?
Signed Perlin noise and sin() return values in -1..1. fit11 maps that range into your target range directly, so you do not have to rescale by hand.