Skip to main content

Mathematics as an art: Fourier epicycle library


If you are remotely interested in mathematics, you'd probably heard of Fourier, or Joseph Fourier. His name comes to mind whenever a physicist, electronic engineer or any technical person deals with frequencies. I don't need to praise Fourier anymore because there are tons of videos and articles about him all over the internet. 

In this article, I will be talking about Fourier series and epicycles (Foucycle), seemingly two distinct branches of mathematics if you're unaware of Euler's famous formula.

Epicycles are essentially circles within circles, they have been studied extensively by astronomers because it was thought planets' motion was perfectly circular (Not to mention how they were convinced the earth was the centre of the universe) until the inverse-square law of planet motion was introduced by Keppler and Newton. Fourier series is essentially a way to approximate any function as the infinite sum of scaled sins and cosines, simple yet revolutionary. 


As always, 3Blue1Brown produced an amazing video on Fourier art which, to be honest, inspired this article. I won't dive into explaining the mathematics behind how this all works because there are plenty of materials online. I have created a python library based on the work of this repository that makes it easy for anyone using python to generate beautiful epicycles of any picture they want! (Well, nearly).
 

How to generate Fourier art

First, make sure you have anaconda installed, then create a new environment
conda create -n epicycle python==3.8
Then activate the environment
conda activate epicycle
Then make sure ffmpeg library is installed to create the videos
conda install -c conda-forge ffmpeg
Lastly, download the library I have created using pip, all the dependencies will be automatically installed:
pip install photoepicycle
And we are done! To test it, download the test picture in the example and save it in a place you know well. Then run the library as a script.

python -m picycle -p /path/to/your/picture.jpg

and voila! you should get a video like below on the same path and the following message:
completed: epicycle.mp4
Done
 



What not to try

By far, the hardest part is extracting traceable edges of the uploaded picture. The code works well with silhouette images, and that's about it. Trying to create a traceable path of photographs quickly turns into a travelling salesman problem, which is expensive even for sub-optimal solutions.


Comments

Popular posts from this blog

Modelling mycelium growth

  Why material science? Since material names are used to define periods of civilisations of the past (Stone Age, Bronze Age, etc ...), material science is considered, in my opinion, one of the species-defining endeavours. Civilizations that mastered smelting iron ended up victorious. All of a sudden, enemies had to deal with stronger swords and implantable shields. The same applies today, countries that managed to master silicon chip manufacturing ended up economically victorious. With the advent of biotechnology, largely with the help of artificial intelligence tools such as AlphaFold, there could be a promise of a new class of materials that are grown instead of manufactured. Bio-composite materials offer an alternative solution to create materials inspired by nature and can returned to it at the end of their lifespan. Such materials will tremendously accelerate reaching our sustainability goals. Mycelium Composites One such material is mycelium, which is considered nature's solu...

Engineered Patterns in Biology I: Intro to Turing Pattern Formation

What is this post about? This post will cover an overview of pattern formation, specifically Turing pattern formation in a non-mathematical way. The whole point here is to appreciate the beauty of what can Turing's reaction-diffusion model describe. If you are excited enough about the topic and want to cover some technicalities, a subsequent post will cover my Master's thesis work on the design of genetic circuits from first principles that makes use of Turing's reaction-diffusion model. Pattern formation in Biology It is best to start by explaining pattern formation in biology. The easiest and most obvious way to see patterns is within animals. Zebras; fish; cheetahs are some of the few animal examples that exhibit pigment patterns on their skin [1]. If you accept the fact that pigments are no more than proteins expressed within a group of cells [2], one can reasonably ask the question: How can cells determine their relative position to other cells so they end up ex...

Butlerian Jihad: The crusade against AI and hidden tech

Image 1: Mdjourney generated picture using the prompt: "cartoon of human soldiers fighting a small robot. it shows the defeated robot in the middle and human soldiers aiming their rifles at the robot" "We must negate the machines-that-think. Humans must set their own guidelines. This is not something machines can do. Reasoning depends upon programming, not on hardware, and we are the ultimate program! Our Jihad is a "dump program." We dump the things which destroy us as humans!" ' ― Minister-companion of the Jihad. [6] That quote will be recognizable if you have read Dune by Frank Herbert . I found it suitable to bring the novel up during the extreme mixture of excitement and fear among people given the recent advance in artificial intelligence. Even an open letter was signed by many extremely influential people to halt the progress of artificial intelligence research to avoid a situation like in the cartoon above in image 1 (which is ironically AI ...