# AE Oscillations/Undulations

AE oscillating expressions
#code/js

## Undulations

You can use these wave exressions to simulate an undulating surface.
Apply the following expression to the position property of an object:

``````xAmp = 3; //height of undulations (pixels)
xFreq = .3; //undulations per second
xSpeed = 150; //speed of wave (pixels per second)
wl = xSpeed/xFreq; //wavelength (pixels)
phaseOffset = ((position%wl)/wl)*2*Math.PI;
y = xAmp*Math.sin(2*Math.PI*xFreq*time + phaseOffset);
value + [0,y]
``````

Apply this expression to the rotation property:

``````xFreq = .3; //undulations per second
xSpeed = 150; //speed of wave (pixels per second)
damping = 15; //undulation damping factor
wl = xSpeed/xFreq; //wavelength (pixels)
phaseOffset = ((position%wl)/wl)*2*Math.PI;
theta = Math.atan(Math.cos(2*Math.PI*xFreq*time + phaseOffset));
``````

Adjust xAmp, xFreq, xSpeed, and damping to control the speed and depth of the undulations.
Note that the expressions take into account the original position of the objects, so that objects spread out in the x direction will react at different times as the wave passes by.

## Vibrating Strings

This is a vibrating string simulation that is accomplished with a simple oscillating expression applied to a slider control, which is then linked to the Tangent controls of the Bezier Warp filter (AE Pro version only).

You start by creating a long, narrow solid. You apply a slider control to the solid and apply this expression to it:

``````amp = 15; //amplitude (pixels)
freq = 10; //frequency (cycles per second)
amp*Math.sin(freq*time*Math.PI*2)
``````

Set "amp" to the desired amplitude and "freq" to the desired vibration frequency.

Then apply the Bezier Warp filter and apply this expression to the Top Left Tangent, Top Right Tangent, Bottom Right Tangent, and Bottom Left Tangent:

``````value + [0,effect("Slider Control").param("Slider")]
``````

For this example, I duplicated the solid twice and changed the frequency value for the copies.