In creative coding, sin and cos can be used for:
- Draw a wave
- Arrange items in circles and spirals
- Generate smooth periodic motion
- An ingredient of “fields”, that fill a line or space with a pattern that determines color, shape, or other qualities of drawing or motion that appears in that space.
- Getting Started with p5.js, “Circular’, pp. 162–172
- Course notes:
The Nature of Code
"Trigonometry is a sine of the times." - Anonymous In Chapters 1 and 2, we carefully worked out an object-oriented structure to make something move on the screen, using the concept of a vector to represent location, velocity, and acceleration driven by forces in the environment.
Trigonometry - The graphs of sin and cos
Being able to visualize the trigonometric functions is important. This video will get you up to speed by showing you the basic graph for sine and cosine. Y...
sin() basics for Creative Coding
This is a sine wave. In p5, it is produced by plotting y = sin(x), where y loops from 0 to width. It's useful for drawing, for example, a wave shape: sin() can also be used to add periodic motion to an object: You can see the relationship between the motion (where sin() is a function of time), and the wave shape (where sin() is a function of $x$), by animating a trace of the shape position.