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

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

Aggressiveness or defensiveness: The best way to play chess, a computer guide

 Different people play chess in different styles, no one knows the best way yet. This guide is perhaps useful to computers more than humans, although feel free to take a piece of life-long advice from this article on human behaviour. Source:  https://ar.casact.org/actuaries-versus-artificial-intelligence-what-do-actuaries-do-what-will-they-do/ The participants of this study are merely two chess programs I wrote. With the best of my abilities, I tried to give them some sort of personality that is reflected in their style of play. To understand how to create a "personality" in a program, it is helpful to understand the most common algorithms used in chess. Broadly speaking, designing a chess engine involves two parts: The Risk Assessment part and The Search part. For the latter, there is a pretty standard and efficient algorithm that searches for the best piece to move called the minimax. Thus I won't be altering the search algorithm much. I will, however, alter the risk as