If one ever wants to work with graphics, then familiarity with the trignometry functions, Understanding the Sine (sin) and Cosine (cos) are necessary. A sine wave or sinusoid is a mathematical curve that describes a smooth periodic oscillation.
Sine and Cosine waves have a lot of uses. One of them is the famous SOHCAHTOA mnemonic that allows one
to calculate the sides of a right-angled triangle if an angle is known if the angle θ is known.
Coversely, if you know the sides of a right angled triangle, it is possible to calculate the sine and
cosine θ values. The below canvas is used to demonstrate this.
If you are thinking, "the hypotenuse is the nothing but the radius of the circle..." you are absolutely right.
And this is by far the most use of the sine and cosine functions in graphics. If you know the radius and an angle, it
is possible to plot the point on a circle using sine and cosine.
Essentially it helps us convert values from a polar co-ordinate system to cartesian co-ordinates.
I have this implemented in several places. Here are
some experiments you can see this implemented. Deflection Demo,
Double Pendulum, Lorenz Attractor,
Simple Pendulum, and Supershapes 2D.
Below is another canvas showing the relationship between Sine and Cosine. As you can see, these two functions are 90°
apart from each other.
And finally, to drive he point further of sine and co-sine functions, here's a neat
Lissajous curve table. You can read more about this here.
The source codes of all of these canvas animations are available below and are properly commented. Do feel free to reach out to me
if you have any questions.