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

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

Communication without noise

Communicating information is perhaps the highlight of the 21st century; the obvious example is the boom in internet and smartphone use in the last 20 years or so; everything is well connected and messages get sent within a fraction of a second. A less obvious example of communicating information is through reading information stored in physical object prone to damage. For example, a CD could be scratched slightly but still, all the relevant information can be recovered properly.  How did we arrive at such a resilient communication? Let's take communicating with your partner as  an example. Without sounding too much like a family consultant, the key here is to send your message as clearly as possible to avoid misunderstanding. Let's say you are an intelligent being who can formulate a proper and grammatically correct sentence, and you wanted to say "I want pizza". You could say the sentence face to face, and hopefully, your crave for pizza would be communicate...