From 02bae15b84c5598257cf630199bf72c603e4a515 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Fri, 20 Jan 2006 06:21:07 +0000 Subject: [PATCH] add interp() --- stepmania/src/RageUtil.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/stepmania/src/RageUtil.h b/stepmania/src/RageUtil.h index fa750f17a6..4127f54aa5 100644 --- a/stepmania/src/RageUtil.h +++ b/stepmania/src/RageUtil.h @@ -41,6 +41,13 @@ inline unsigned long max( unsigned long a, unsigned int b ) { return a > b? a:b; // Do the multiply before the divide to that integer scales have more precision. #define SCALE(x, l1, h1, l2, h2) (((x) - (l1)) * ((h2) - (l2)) / ((h1) - (l1)) + (l2)) +// Like SCALE(x, 0, 1, L, H); interpolate between L and H. +template +inline U interp( T x, U l, U h ) +{ + return U(x * (h - l) + l); +} + inline bool CLAMP( int &x, int l, int h ) { if (x > h) { x = h; return true; }