Search code examples
mathfftpolar-coordinates

Faster way to go from cartesian to polar in C?


My C code for discrete Fourier transform needs to output polar values, amplitude and angle. I have a fast algorithm that outputs cartesian values, x and y.

Is there a faster way of converting (f.e. 1024) cartesian values to polar than just:

int x, y;
float amplitude, angle;
...
amplitude = sqrt( x*x + y*y);
angle = atan2( y, x );

?


Solution

  • There are two approaches:

    (1) Perform the common 2D FFT, and then complete the cartesian to polar conversion by yourself.

    (2) Use the so called "polar FFT" directly. Actually, the "polar FFT" is also based on the interpolation.