12.07.2015 Views

Lode's Computer Graphics Tutorial Fourier Transform

Lode's Computer Graphics Tutorial Fourier Transform

Lode's Computer Graphics Tutorial Fourier Transform

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Calculates the amplitude of *gRe and *gIm and puts the result in *gAmpvoid calculateAmp(int n, double *gAmp, double *gRe, double *gIm){for(int x = 0; x < n; x++){gAmp[x] = sqrt(gRe[x] * gRe[x] + gIm[x] * gIm[x]);}}The output of this program is as follows:The red function is the input function, which is a sine, and the black funtion at the bottom is theamplitude of it's spectrum, which is calculated by the DFT function. The green curves are theimaginary parts.The Fast <strong>Fourier</strong> <strong>Transform</strong>The above DFT function correctly calculates the Discrete <strong>Fourier</strong> <strong>Transform</strong>, but uses two for loops ofn times, so it takes O(n²) arithmetical operations. A faster algorithm is the Fast <strong>Fourier</strong> <strong>Transform</strong> or

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!