Quantcast
Channel: Windows Forms General forum
Viewing all articles
Browse latest Browse all 12583

Using Arc Tan in C#

$
0
0

I'm trying to convert a complex number from rectangular form to polar. Using the old school method (pencil and calculator) i get:

25 + j20 Rectangular

32<38.66 polar

the following is the code i'm using:

   

        static void Main(string[] args)
        {
            Complex RA = new Complex(25, 20);
            Console.WriteLine("{0} + i{1}", RA.Real, RA.Imaginary);

            double r, q;
            r = Math.Sqrt((RA.Real * RA.Real) + (RA.Imaginary * RA.Imaginary));
            q = Math.Atan(RA.Imaginary/RA.Real);
            Console.WriteLine("{0} < {1}", r, q);
            Console.ReadLine();
        }

And the console is printing 

25 + i20

32 < 0.674

Can anyone help me to get the correct answer from the Atan function?


Viewing all articles
Browse latest Browse all 12583

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>