Sin
Task
Draw an image with 5 sinusoidal waves coming out from the center of the screen. The waves should be based on the distance from each pixel to the center. Adjust the sine values to a range from 0 to 1, and use these values to control the brightness of the red color. This will create a repeating pattern of peaks and troughs of the waves. Use 3.14 as the approximate value for $π$.
Theory
The sin function returns a numeric value from -1.0 to 1.0 that represents the sine of the passed (in radians) angle.
Function Signature
float sin(float angle);
Period
The sine function has a period of $2\pi$, which means that it repeats itself every $2\pi$ units. To create a full sine cycle along the x-axis using uv coordinates, you need to multiply the x-coordinate by $2\pi$:
float angle = uv.x * 2.0 * PI;
Frequency
To display multiple sine cycles across the screen, scale the x-coordinate before mapping it to $2\pi$:
float angle = uv.x * frequency * 2.0 * PI;
Here, frequency controls how many cycles fit across the screen. For example:
frequency = 1.0: one full cycle.
frequency = 2.0: two cycles.