2d and 3d Fourier transforms


Recently, I’ve been playing with multidimensional Fourier transforms, which is something that I’ve meant to do for awhile but finally got around to during a mini-hackathon I participated in with Fred Manby and his group members. The left hand panel above shows the function z(x,y) = cos(0.5πx + 1.5πy) + cos(1.5πx + 0.5πy); the right hand panel shows the 2d discrete FFT of z(x,y). The two peaks visible in the Fourier plot correspond to the wave vectors of each of the cosine functions ([0.5, 1.5] and [1.5, 0.5]). Using the 1d FFT routine in alglib, I wrote some C++ source code and tests to generate the plots shown above; the files testFunctions.h and testFunctions.cpp include routines for both two and three-dimensional Fourier transforms. I haven’t yet worked on optimizing this code, but it’s simple, reasonably fast, and all my tests show that it gives the correct answers!

and here’s another one, just for fun…


Leave a Reply