ftxi / epicycles

A small program to display epicycles with given image using Fourier Transform.
https://sclereid.github.io/epicycles
GNU General Public License v3.0
22 stars 4 forks source link

ask - doubt about rot and omg #8

Open rafaelcb21 opened 2 years ago

rafaelcb21 commented 2 years ago

Hi sclereid, amazing work, congratulations!!! I was studying your code and I had a doubt in the function get_circle_fft() There is a part of the function that you find the rotation (rot) and the frequency (omg) There are many ways to find these values on the internet but you used a unique way.

I would like to know how this is possible? What would be the mathematical reference to be able to say that half of the rotation will be negative and half of the frequency will also be negative? e.g:

N = 10
omg = [0, 1, 2, 3, 4, 5, -4, -3, -2, -1]
rot = [1, 1, 1, 1, 1, 1, -1, -1, -1, -1]

Could you help me understand?

def get_circle_fft(array):
    ...
    if i > N/2 :
        rot = -1
            omg = len(z)-i
        else :
            rot = 1
            omg = i  
ftxi commented 1 year ago

Both Negative and positive rotations gives the resulting curve strictly passing the required points. However, if all rotations are on one side, the animation is bumpy and spreading the trace all along the screen, which is not pleasing.

For mathematical reference, take a look at my introduction github io page. The discrete Fourier transform of evenly spaced n points on a curve tends to the Fourier transform of that curve when n->infinity, and the Fourier transform coefficient of a curve tends to zero as frequency increases. So the what that actually matters are circles of frequencies on both sides (namely, excluding the middle). In practice, they work well when treated as rotations on opposite directions.

I believe a more strict proof on convergence is possible, but I won't bother to write one unless someone is interested in reading it.