
My Fourier Epicycles - signa11
https://www.myfourierepicycles.com/
======
encypruon
Shameless plug: A friend of mine and I made a game[1] for a jam that works the
other way around. The goal is to manually fiddle with the coefficients to
recreate a given shape.

It gives an easy way to play with the coefficients and hopefully allows the
player to gain some intuitions. For example how some combinations of
frequencies lead to rotational symmetry and why negative frequencies are
necessary.

It's not very polished, though. I made a mistake while writing the algorithm
that checks whether the shape is matching. It causes some false negatives in
certain situations. There might also be some issues with dragging the controls
on Mac OS.

[1]
[https://coldiv.itch.io/fouriershaper](https://coldiv.itch.io/fouriershaper)

------
bargle0
It would be cool to have a slider or something to hide cycles, starting with
the highest frequency. Basically, a way to visualize lossy compression.

------
fnord77
I tried to stump it with this SVG. I didn't expect it to really work, but it
failed fairly spectacularly

[https://upload.wikimedia.org/wikipedia/en/a/a4/Flag_of_the_U...](https://upload.wikimedia.org/wikipedia/en/a/a4/Flag_of_the_United_States.svg)

------
loa_in_
Why does it use two sets of vectors?

One sum of vectors is enough to trace any continuous line.

~~~
hinkley
Perhaps so the animations are outside of the drawing area?

~~~
golem14
And I would guess you get fewer artifacts - the version linked in a sibling
comment with just one end has a lot of factors and yet is not very accurate.

------
lurquer
Brilliant demonstration!

As you undoubtedly know, there is nothing essential about using sin waves with
Fourier stuff... it can work with any shaped curve. A cool modification would
be use a combination of the users input to generate a circle instead of the
other way around. That is, if I draw a square, a multitude of squares of
different sizes and phases, each tracing their contour, will generate the X,Y
values for a circle.

------
ndr
This is fun but I think it's a bit buggy.

Trying to draw lines parallel and close to more than one border generates a
lot of nonsense. Try with a square almost as big as the canvas.

~~~
ladberg
Same thing happens when I try (emphasis on try, it wasn't that good) to draw a
circle, which should be the easiest shape.

------
cgufus
As I understand a "time series" is created for both x und y coordinates, then
these are fourier transformed for the spectral components. Then when
redrawing, only the real parts are used.

Is it necessary to do it for x and y separated? Couldn't you just take x for
the real part and y for the imaginary part of the time series and do the
Fourier transform on that?

edit: monday morning typos.

------
bldavies
For those interested, I explain some of the math involved in computing
epicycles from sample data here: [http://bldavies.com/blog/computing-
epicycles/](http://bldavies.com/blog/computing-epicycles/)

------
NiceWayToDoIT
Nice one, despite understanding inner workings all I can think of is the song
title "A Kind of Magic"

------
m3kw9
Could this be a way to compress vectors?

~~~
vladTheInhaler
Depending on what you mean by vectors, yes. I don't know how it, if at all, it
would apply to svg files, but you can absolutely take a vector and take its
Fourier transform, and only keep the first few components to get a compressed
representation. That is one way to do image compression.

------
gus_massa
The second pass makes the line darker. Is it on purpose or just a numeric
error?

~~~
ReactiveJelly
It may also be a result of the canvas drawing anti-aliased lines. Since an
anti-aliased line contains some partially transparent pixels, drawing exactly
the same line a second time will darken those pixels.

