Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int inMax = 0,
- inMin = 0,
- translMax = 1024,
- translMin = 0;
- rangeMax = getMaxValue();
- rangeMin = getMinValue();
- //Calculate 4 of these (xpos xneg ypos yneg)
- float slope = 1.0 * (translMax - translMin) / (rangeMax - rangeMin);
- int translate(int inputVal, int outputMin, int inputMin, double slope){ return outputMin + slope * (inputVal - inputMin); }
- //use the correct slope depending on if x & y > centerValue (if xpos or ypos, start from centerValue and not 0 = translMin)
- translatedValue = translate(inValue, translMin, rangeMin, slope);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement