sin() + cos()
general description, what is it and what is it for
The simple logic behind the sinewave can be found everywhere: From nature to technology and in between.
This chapter is all about wave-motion with sin() and cos() in Processing.
To put it simply: Both functions output a wave motion which is moving between the values 1 and -1. By mapping or multiplying those values, we create stunning waves that can be used in numerous cases.
particular function / technique description with code and comments
The anatomy of the sin()-function
Let's take a closer look on the actual function:
wavemotion = sin(angle) * amplitude
This function is all we need to create the wave.
angle
controls the position on the wave. It has to be a growing value, to make the motion of the wave visible.
The variable amplitude
controls the amplitude / height of the wave. If we multiplay the value by two, we get the exact peak to valley ratio.
A collection of examples using mainly techniques covered in the current chapter and the chapters before. with images/animations as examples.
Examples
Increasing amplitude
Increasing angle
How to create Perfect loops?
How to get a perfect loop? How can i adjust the length (time) of a wave and use it to make perfect loops?
I work a lot with exporting gif files from Processing and that's why i was asking myself how i can get the full control of the length of the waves during a predefined timespan...
...
Transition to the next chapter
Okay, sinus is cool. But what about the cosinus?
Now we know how to draw some waves, but what does that cos()-function do and why do we need it? Doesn't it have the same functionality as the sin()-function anyway? Browse to the next chapter to see, what we can do with both waves in combination.