2

试图将一个数字从矩形转换为极坐标形式,即从 20+j25 到 32<38.66

这是我到目前为止所拥有的:

    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();
    }

这给了我答案 20, 25. 是矩形的。我将如何制作这个极地?

谢谢

编辑:好的,我做了一些更改,但仍然无法得到正确的答案。使用代码:

    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();
    }

我得到 32 < 0.647... 答案应该是 32<38.66。谁能解释为什么我的角度不对?谢谢

4

1 回答 1

0

知道了。必须将弧度转换为度数。感谢大家的帮助!

    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();
    }
于 2012-12-02T18:55:58.147 回答