**2D Fourier transforms to draw figures**

In this page you can draw a 2D figure that then is drawn using a 2D fft. This is inspired by a video by 3Blue1Brown. I basically just watched the video, then tried to create something similar – and it was definitely not as straight forward as I first thought, and the method I finally used is probably not completely the same as used in the video.

I started with writing an fft-function. This was quite straight forward since I have done that a couple of times before. The idea is then to treat a 2D input as a complex input to the fft.

Then I tried it with some known inputs. One problem is that the fft of a real cos and an imaginary sin are the same. To fix this I did two fft’s. One on the real data and one on the imaginary data, then combining the data.

Next, I added the possibility to draw the data-points, either with a mouse or on a touch screen. This data is then turned to a set of data with a power of two number of data points using interpolation. The fft’s are then done

There are some buttons and one slider on the page:

- Clear: Clears the canvas and resets all data.
- Draw epicycles: Draws the curve constructed by the fft.
- Show circles: Show the circles corresponding to the different frequencies.
- Hide trace: Hides the trace of the curve the outermost vector moves along. I.e., the curve corresponding to the sum of the cos and sin functions determined by the fft’s.
- Show original: Shows the original curve.
- Show Clock: Draws a clock. It is not supposed to show the time, just show the principle that its even possible to draw something as complicated as the numbers on a clock face.
- Then one slider setting the number of circles used/shown. This correspond to the number of terms of the fft’s that are used when drawing the resulting curve.
- Speed – and speed + are used to change the drawing speed.

If the steps between two successive points on the curve are to far from each other the corresponding part of the curve is not drawn. This allows you to draw discontinuous curves, for example texts.

Draw a curve or figure on the screen – rather slowly – then click Show epicycles – and enjoy (^^,)

Up a level : Fast Fourier transformLast modified: