[FFT] Polar to Rectangular and vice versa


Hi guys,

I’m trying to write a couple of functions to transform Real and Imaginary data to Magnitude and Phase.
As far as I know, the formulas are

Magnitude: sqrt(re * re + im * im)
Phase: atan2(im, re)

Real: Mag * cos(Ph)
Im: Mag * sin(Ph)

Unfortunately, when I try them I don’t get Re and Im correctly back from Mag and Ph.
Any advice?



You can do it all with the functions available through std::complex, unless you have a particular reason for wanting to roll your own solution?


ops, I missed that! Thanks!