Implement bilinear interpolating function in utils.