Skip to content

gyanantaran/fourier-series

Repository files navigation

fourier-series

fourier zoomed-fourier

Contributing

Contributions are welcome! Feel free to open a pull request or submit an issue if you find any bugs or have any suggestions for new features.

Introduction

Fourier Series is a fascinating mathematical concept that can be used to break down signals into their component harmonics, in a variety of complex situations -- in our case 2D drawings. By simulating these systems, we can gain a better understanding of how the calculation for fourier-series works and how order (drawings) emerge from clockwork chaos (precise cycloids).

This project is a simulation of fourier-series approximation of arbritrary 2D drawings, with cycloids that combined with each other, trace out the approximation to a given drawing. In this simulation, one can start off with a low number of harmonics and a simple drawn images (svgs) that are nice and easy to approximate (infinity sign, twitter logo). Then one after the other one may start adding more harmonics and see the approximations get better drawn, reactively. At the end we find that even with an extremely small number of harmonics (50 for example), the approximation are good enough and that the motion of the tip of cycloids (the very last cycloid) is seeming chaotic but exactly, scriplty organised.

Some example demos

fourier.mp4
milestone1-video2.mp4
milestone1-video1.mp4

Instruction to build the project

Here are the instructions to build and run the project:

Note: this project uses cmake, make sure that is installed, the minimum version for cmake is specified inside the CMakeLists.txt

cd fourier-series
cmake -DCMAKE_BUILD_TYPE=Release -S . -B ./build/
cd ./build/
make
cd ..
./build/fourier_series

Logs and Bugs

The following registers the interesting bugs and milestones I came over the way.

sampling bug - sample are very unevenly distributed in commit #607989e

fourier-crudesampling-1 fourier-crudesampling-2

weird bug - cycloids follow the cursor lazily in commit #8dae5c9

weirdbug-laggingcycloid2

weirdbug-laggingcycloid1

plotting and first tries at the analysis equation and final synthesis in commits before 872ba9f

Screenshot 2024-04-06 at 11 12 53 PM

Screenshot 2024-04-06 at 11 14 36 PM

cycloids and user input added in commit #c429433

cycloids-added

sketch-added

Additional explorations for autodidacts and builders

If you want to further study and understand fourier-series and fourier transform, here are the resources I used:

  1. But what is a Fourier series? - 3b1b
  2. 2D Signal approximation ... - Pezzza's Work
  3. But what is the Fourier Transform? - 3b1b
  4. The more general uncertainty principle ... - 3b1b

Licence

This project is licensed under the Creative Commons License. See the LICENSE file for more information.

zoomed-fourier fourier