Here's how to interpolate a value from one range to another:
Range 1: 100.....550.....1000 Range 2: 300..... x .....3000
This formula will do it:
public static float Interpolate(this float value, float minValue, float maxValue, float minScale, float maxScale) => (((value - minValue) / (maxValue - minValue)) * (maxScale - minScale)) + minScale; float x = 550.Interpolate(100, 1000, 300, 3000); //x = 1650
Try it
Range 1 | |||
---|---|---|---|
Range 2 | ... |
No comments:
Post a Comment