--
-- interpolation routines
--

function interpolate_towards (Cur, Want, Rate, T)

   local Delta = math.abs (Want - Cur)
   local Sign = 1
   if (Want < Cur) then Sign = -1
   end

   -- move up to the amount that is lacking, in total
   Delta = math.min (Delta, Rate * T)
   return Cur + Delta * Sign
end
