DEV Community

Cover image for Fourier Series visualization using Unity
Contra
Contra

Posted on

4

Fourier Series visualization using Unity

"Coding Druid" series is my horizontal programming practice notes, each part around a topic like mathematical, physics, electronic, graphics, sound, etc., implemented in several programming languages.


Coding Druid
Part: Math
Chapter: Fourier Series
Section: Unity

In the previous Chapter, I visualized Trigonometric function (Sine and Unit Circle) separately using MaxMSP, JavaScript (React), Python, and Unity:

sine-unity-croped

This chapter I implement Fourier Series curve visualization.
And Unity this section.
When it comes to Fourier transform or Fourier analysis, it is usually divided into two parts: Fourier series and Continuous Fourier transform. This chapter focuses on the Fourier series.

In mathematics, a Fourier series is a periodic function composed of harmonically related sinusoids, combined by a weighted summation.
(wikipedia)

For example, suppose there is a square wave, and it can be interpreted into sine waves.
The more sine waves you have, the preciser square wave you will get:

More graphic explanations and formula derivation, see the previous section: Fourier Series Visualization Using React Hooks .

The effect of the previous section:

fs-js-5

Now let's try Unity.

Have written an note Sine function visualization using Unity3D. So on the basis of its code, the drawing formula can be modified from the trigonometric function to the lower Fourier series:

fs-mathshot

code

The full code can be seen later.

Final effect:

fs-unity

References


Talk is cheap. Show me the code!

This demo and the Coding Druid series is open source here:
https://github.com/avantcontra/coding-druid

You may buy me a coffee in my Patreon. There are many articles, patches, source code and some advanced Patron-only content there.

Also you can get some free patches/codes in Gumroad shop.

Your encouragement is my driving energy!

Cheers~

Contra

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →