Math - Manipulating Sine Waves

In this lecture we learnt how to alter the amplitude and frequency of our standard sine wave and also looked at how to move the curve on the x- and y- axes.

We applied our modified curves to the head of a turret and to a blinking light, but you can apply them to pretty much anything.

What are some of your favorite uses of the sine wave?

Before this lecture I would have said my favorite use for sine waves was moving platforms (except I wouldn’t have actually known sine waves were involved per se). Now I think turret range of motion is a cooler application, but I really love them both.

Also, does this apply in 2D as much as in 3D? If I wanted to make a platformer with moving platforrms and turrets, I could implement and manipulate them using sine waves?

1 Like

You can absolutely use them in 2D. In fact, all the math we covered was looking at sine waves from a 2D perspective.
If you think about a platform that moves horizontally back and forth, you’re only moving it on the 1 axis, so it makes no difference whether you’re working in 2D or 3D.

The only functionality you really lose in 2D vs 3D is something that we didn’t actually cover in the lecture, and that’s the ability to make spirals.

Here’s a nice diagram that that shows what I’m talking about:
image

1 Like

Oh, that’s super cool. Are there any good online resources that break this down? Would be awesome to implement this in a game.

That image actually makes it look way more complicated than it really is.
If you ignore all the fancy formulas and math terms, it’s really just a logical extension of what we looked at in previous lectures.

We know that, as you move around the circumference of a circle, you’re changing the x-coordinate by cos(theta) and the y-coordinate by sin(theta).

Now, to turn the circle into a spiral, you just need to start moving it forward.
So if you also increase your z-position at a constant rate, you’ll end up stretching out that circle into a spiral.

This is why you can do it in 3D but not in 2D. You need that third dimension in order to push the circle forward and turn it into a spiral.

1 Like

I have a background in theatrical lighting, and most of the effects in the consoles are built on sine waves. You use them to build pan/tilt effects on moving heads/ color effects by cycling/offsetting RGB channels in LED fixtures and controlling the amplitude and x/y offset to control the start end values. I’ve literally created the same thing as used in the flashing light example to control color, then run a sequence of those lights on a sine wave for intensity as well to create a chase (either for something like marquee lights or for an effect like windows on a train). The naming is different, but the idea is the same.

1 Like