$ 0 0 position = position * 0.9 + newCentroid * 0.1; or any other low pass filter, but this is probably the simplest.