Lerps within a given range.
Let's say you have to ranges that you want to make a linear association to.
The easiest way to imagine this is imagine two ranges.
0 Range1 100|------10------------|0 Range2 200|-------------?-------------------------| Copy
0 Range1 100|------10------------|0 Range2 200|-------------?-------------------------|
range1: 0 - 100 range2: 0 - 200
You have the value of 20 on range1 and want to know what the value would be on range2.
The above would return 20 since 10% of 200 = 20.
mathf.interpolateRange(0, 0, 100, 0, 200); // 0mathf.interpolateRange(10, 0, 100, 0, 200); // 20mathf.interpolateRange(30, 0, 100, 0, 200); // 60 Copy
mathf.interpolateRange(0, 0, 100, 0, 200); // 0mathf.interpolateRange(10, 0, 100, 0, 200); // 20mathf.interpolateRange(30, 0, 100, 0, 200); // 60
A practical example. Here when the screen width is 300, the padding is 0 and when it's 1200, the padding is 500 and everything it clculates everything between.
let padding = mathf.interpolateRange( screenWidth, 300, 1200, 0, 500); Copy
let padding = mathf.interpolateRange( screenWidth, 300, 1200, 0, 500);
Lerps within a given range.
Let's say you have to ranges that you want to make a linear association to.
The easiest way to imagine this is imagine two ranges.
range1: 0 - 100 range2: 0 - 200
You have the value of 20 on range1 and want to know what the value would be on range2.
The above would return 20 since 10% of 200 = 20.
A practical example. Here when the screen width is 300, the padding is 0 and when it's 1200, the padding is 500 and everything it clculates everything between.