| 1 | #pragma once |
| 2 | |
| 3 | #include <cmath> |
| 4 | |
| 5 | |
| 6 | inline double interpolateLinear(double min, double max, double ratio) |
| 7 | { |
| 8 | return min + (max - min) * ratio; |
| 9 | } |
| 10 | |
| 11 | |
| 12 | /** It is linear interpolation in logarithmic coordinates. |
| 13 | * Exponential interpolation is related to linear interpolation |
| 14 | * exactly in same way as geometric mean is related to arithmetic mean. |
| 15 | * 'min' must be greater than zero, 'ratio' must be from 0 to 1. |
| 16 | */ |
| 17 | inline double interpolateExponential(double min, double max, double ratio) |
| 18 | { |
| 19 | return min * std::pow(max / min, ratio); |
| 20 | } |
| 21 | |