/WOGYT.github.io

Primary LanguageJavaScriptMIT LicenseMIT

Fourier_Transform

Draw something using the Draw.py file and open the Fourier.html to see it redrawn using Discrete Fourier Transform (DFT)

Preview on pascaaaal.com/Fourier

How is it working ?

The Draw.py file:

This python file is composed of a window in which you can draw the design you want to transform. The program get the coordinates of the mouse while drawing which are then write in a file

The fourier.js file:

To redrawn the design we are using a Descrete Fourier Transform (DFT). The DFT transform a sequence of number (in our case the coordinates of each point of the drawing) into a sequence of sinus and cosinus called Fourier Coefficients (FC). The DFT is defined by:

equation

The sketch.js file:

As we can see, each FC is a complexe number, a + bi, where a and b are real number and where a is called the real part and bi the imaginary part. In our program, the real part is noted "re" and the imaginary part is noted "im". The real and imagninary parts are defined by:

equation

equation

In order to avoid doing calculations with real numbers, we are drawing the x and y separately. To visualize the path of the design we are using circles. There are as many circles as there are fourier coefficients. To draw those circles, we need the frequency, which is the speed at which the circle will turn, noted "freq".

equation

We also need the amplitude, which is the radius of the circle. The amplitude is defined by:

equation

Finally, we need the phase, which is the angle at which the circle wil started drawing. The phase is defined by:

equation

Installation