Image:
Author: FRA32 Group: Default Filesize: 52.29 kB Date added: 20200108 Rating: 6.8 Downloads: 1979 Views: 231 Comments: 6 Ratings: 5 Times favored: 0 Made with: Algodoo v2.1.0 Tags:

After many months and years, I finally fullfill XRay's ironic suggestion: Calculating the Fourier Series of an arbitrary curve!
What is a Fourier Series? It's is a series of sine waves, whose amplitude and initial angle are calculated in such a way that the sum of the waves is a close approximation of some given curve. They allow breaking up any curve into a multitude of frequencies and amplitudes, which is used, amongst other things, in signal processing to seperate a sound into its individual components. In this scene, these sine curves have been split up into cosine and sinewaves to avoid dealing with the initial angle during calculation.
The difference between a discrete and continuous Fourier series is whether you only calculate using a selected few points(discrete) or from an infinite amount with infinitesimal width(continuous), which requires the curve to be expressable as a combination of equations.
How to use? The primary object in the scene is the area between the two red lasers. This is the active interval. Any curve drawn inside this area will be analysed and the corresponding fourrier series will be calculated. You can move these 2 lasers as long as the dark laser remains on the left side. The Drawing area will be resized accordingly, leaving some excess width to the left and right to display continuity later on. Please do note only the upper edge of your shape will be read, so if you want to read the lower edge, create a negative of your shape and cut away the upper half.
Alternatively, you can make use of the "Formula Mode". Toggle the button for it and edit the green bar's formula using the script menu in the fashion y=f(x). Note that x goes from 0 to 1 as the scanner moves from the left edge to the right edge. This allows you to create the Fourier Series of exact mathematic Formula's as opposed to geometric bodies.
To begin the process, left click the green box at the topleft. After your curve has been scanned and the series been calculated, the various degrees will begin drawing inside the interval, starting at red for the lower frequency and up to magenta for the highest. Additionally, the fourier series itself will be drawn in white. The amplitudes will also be shown in the diagram at the very bottom. A bright dot equals the amplitude of the sine wave, a dark dot the cosine wave, and a large dot the combination of both sine and cosine(the angle of the circle cake equals the initial angle of the combined wave)
You can change the details of the fourrier series using the two text boxes at the top right:
Degree  The amount of frequencies getting calculated. A higher degree means a better resolution with more attention to high frequencies, but also increases required processing power. Default: 50
Sample size  The amount of "samples" being collected for calculation. More samples allows more precise shape analysis, but also increases the time it takes before the calculation finishes. Default: 300
UPDATE: Performed some aesthetic improvements, added Formula mode, fixed some remaining Bugs. 