**2D Fourier transforms to draw figures**

On 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 straightforward 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 straightforward 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 into a set of data with the number of data points being a power of two, using interpolation. The fft’s are then done using that set of data.

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: Draw a clock. It is not supposed to show the time, just show the principle that it’s even possible to draw something as complicated as the numbers on a clock face.
- Then one slider sets the number of circles used/shown. This corresponds 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 too 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: