Changing the phase of sinusoidal motion on the fly