| 329 | |
| 330 | // Remap a value that is in sourceRange into targetRange. |
| 331 | template <class T> T inline Remap(const T value, |
| 332 | const T sourceMin, const T sourceMax, |
| 333 | const T targetMin, const T targetMax) { |
| 334 | if (sourceMin == sourceMax) |
| 335 | return sourceMin; |
| 336 | |
| 337 | return (value - sourceMin) |
| 338 | * (targetMax - targetMin) |
| 339 | / (sourceMax - sourceMin) |
| 340 | + targetMin; |
| 341 | } |
| 342 | |
| 343 | inline bool IsValid(float a) { |
| 344 | return !isnan(a) && !isinf(a) && (a >= 0.f); |