Saturday 31 August 2013

Expand

The expand() function does the exact opposite of compress(): It remaps the values by pushing the values to a higher position in a value graph.

float expand(float x, float lo, float hi) {
                     float retval = 0;
                     if (lo == hi)
                         retval = x < lo ? 0 : 1;
                    else
                         retval = (x-lo) / (hi-lo);
                    

                    return retval;
}



s with no compression



















Applying an expand() function with the values expand(s,0.5,1) will leave 0 and 1 untouched, remapping 0.5 to 0. This means that the value of 0 is shifted up to the position of 0.5, therefore remapping 0.5 to 0.

s with (0.5,1) expanded. what used to be 0.5 is now 0



















Using the values expand(s,0,2) will leave 0 untouched while remapping 1 to 0.5, because the value of 1 will be shifted up to the position of 2.

s with (0,2) expanded. what used to be 1 is now 0.5






No comments:

Post a Comment