freq=5; amp= 360; snapto = 90; // snaps to multiples of this Math.round(wiggle(freq,amp)/snapto)*snapto;