Trying to convert a number from rectangular to polar form, ie from 20+j25 to 32<38.66
here's what i have so far:
static void Main(string[] args)
{
Complex A = new Complex (0.4, 0.3);
Complex B = new Complex (0.6, 0.7);
Complex C = new Complex (24, 19);
Complex D = A + B + C;
Console.WriteLine (D);
Console.ReadLine();
}
That gives me the answer 20, 25. which is in rectangular form. how would i go about making this polar?
Thanks
EDIT: Ok i've made a few changes but still can't get the right answer. Using the code:
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();
}
I'm getting 32 < 0.647... the answer should be 32<38.66. Can anyone explain why i'm getting the wrong angle? Thanks
Got it. Have to convert radians to degrees. Thanks for the help everyone!
static void Main(string[] args)
{
Complex RA = new Complex(25, 20);
Console.WriteLine("{0} + i{1}", RA.Real, RA.Imaginary);
double r, q, z;
r = Math.Sqrt((RA.Real * RA.Real) + (RA.Imaginary * RA.Imaginary));
q = Math.Atan(RA.Imaginary/RA.Real);
z = (q * (180/Math.PI));
Console.WriteLine("{0} < {1}", r, z);
Console.ReadLine();
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.