map/integrate between 3 values
in
Programming Questions
•
1 year ago
Could someone help me,
i would like to map something between 3 values instand of 2.
It doesn't have to be perfect, i don't send rocket's to the moon.
- float offsetStart = 0;
- float offsetMiddle = 10;
- float offsetEnd = 2;
- // the function should accept a middle value
- float offset = map(i, 0, steps, offsetStart, offsetMiddle, offsetEnd);
In case it helps, this is the normal map function (but i could also imagine a function that reuses the map function in it)
-
static public final float map(float value, float istart, float istop, float ostart, float ostop) { return ostart + (ostop - ostart) * ((value - istart) / (istop - istart)); }
1