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...

What does flattening the curve mean mathematically?

As of today, most countries are on lockdown; a strategy devised by governments to help slow down the spread of the novel coronavirus COVID-19. Moreover, officials use the term flattening the curve to help the healthcare system cope with the expected large amount of patients, but what does that mean mathematically? I will go on an overview of how to construct a useful toy mathematical model to get a qualitative view of the dynamics of the virus. This is a typical SIR model appearing a lot lately in the media. I will go further to explain how to develop such a model and explain the power and limitations of such models. How to construct SIR models SIR stands for Susceptible, Infectious and Recovered (or Removed) agents. In our example, the agents are humans spreading the disease to each other. To simplify things, we model an agent as a node and the links between nodes represent social connections, as seen in the picture below: Figure 1: Modelling humans as nodes...