It’s partly being familiar with the formulas and partly trial and error.
Start by remembering the formula:
amplitude * sin(frequency * x + xOffset) + yOffset
As an example, let’s take the more complex third example and I can walk you through some of the thought process…
Here, I’m modelling some sort of damaged light. This means I really don’t care too much about the final formula and just want it to look decent enough.
I want it to flicker on and off but a pure sign wave is too predictable - I’m going to need to add a few waves together.
I know that multiply
x will modify the frequency. So let’s pick there numbers that will put it reasonably out of phase to create something interesting. Here I think I arbitrarily picked 1/10, 3/10, and 1/16.
Ok we’ve made a wobbly line now but it’s still too smooth.
However, I know that multiplying on the outside will alter the frequency, so let’s pick some prime numbers, so that they don’t overlap too often. Here I picked 1, 5, 7.
Right, now we’re cooking. It looks interesting and the repetition isn’t super obvious.
But, our light only accepts values between 0-1 and this is ranging around ±11, so a lot of our details will currently be lost.
Well, if I can fix the amplitude by multiplying, so lets wrap everything we have in parentheses and divide the whole lot to make the numbers smaller. I picked 25 because it did the job and I didn’t need to be particularly precise with my output. It’s supposed to be a broken light, so there’s no set goal other than “does it look broken yet”.
You could also adjust your earlier amplitude numbers here but just dividing everything is easier.
Great, my light looks pretty broken but it’s off for extended periods of time and I only want it to be off occasionally, so that it looks like it’s still in the process of failing and not randomly sparking back to like out of nowhere.
Well, for this I just need to raise it up a bit. Again, the amount doesn’t need to be precise for this example and I don’t mind if it occasional falls below 0 or peaks at 1 for a bit, so I added 0.5.
So that’s a rough thought process for something that didn’t need to be precise.
The first and second examples were a lot more deliberate but they are also much easier to visualize because they’re much more obviously repetitive.
If you want to get a more precise outcome then you need to learn a little more math.
If you’re interested, check out more on Fourier series, which was unfortunately beyond the scope of this course.
You may also be interested in checking out the formulas for constructing construct things like; triangle waves, square waves, and sawtooth waves.
You can even do some cool stuff by constructing your functions piecewise. This is how some common easing functions like “bounce” or “elastic” work.