コード例 #1
0
        private static Complex multiplyAndDivide(Complex x, Complex y, bool division)
        {
            double pi = MAL.Pi();
            double resultantModulus;
            double resultantArgument;

            if (division)
            {
                resultantModulus  = x.modulus / y.modulus;
                resultantArgument = x.argument - y.argument;
            }
            else//This occurs when division is false
            {
                resultantModulus  = x.modulus * y.modulus;
                resultantArgument = x.argument + y.argument;
            }
            if (resultantArgument > pi)
            {
                resultantArgument -= 2 * pi;
            }
            if (resultantArgument < -pi)
            {
                resultantArgument += 2 * pi;
            }
            Complex resultantNumber = new Complex(resultantModulus, resultantArgument, true);

            return(resultantNumber);
        }
コード例 #2
0
        public double getArgument()
        {
            double Pi = MAL.Pi();

            if (real == 0)
            {
                if (imaginary < 0)
                {
                    return(-Pi / 2);
                }
                else if (imaginary > 0)
                {
                    return(Pi / 2);
                }
                else
                {
                    return(0);
                }
            }
            double x     = MAL.Modulus(imaginary / real);
            double angle = MAL.Arctan(x);

            if (real < 0 && imaginary < 0)
            {
                angle = angle - Pi;
            }
            else if (real < 0)
            {
                angle = Pi - angle;//This is the part that has changed - the geometry is now correct.
            }
            else if (imaginary < 0)
            {
                angle = -angle;
            }
            return(angle);
        }