public override IBaseMathOperator CalculateSimplyfy()
        {
            var variable = new VariableXMathOperator();

            switch (A)
            {
            case ConstantMathOperator _ when B is VariableXMathOperator:
                variable.SetMultiply(((VariableXMathOperator)B).GetMultiply() * A.Result());
                return(variable);

            case VariableXMathOperator @operator when B is ConstantMathOperator:
                variable.SetMultiply(@operator.GetMultiply() * B.Result());
                return(variable);
            }
            if (A is ConstantMathOperator && Math.Abs(A.Result()) < 0.000001 ||
                B is ConstantMathOperator && Math.Abs(B.Result()) < 0.000001)
            {
                return(new ConstantMathOperator(0));
            }

            if (A.Simplyfy() is ConstantMathOperator && Math.Abs(A.Result() - 1) < 0.000001d)
            {
                return(B.Simplyfy());
            }
            if (B.Simplyfy() is ConstantMathOperator && Math.Abs(B.Result() - 1) < 0.000001d)
            {
                return(A.Simplyfy());
            }
            return(base.CalculateSimplyfy());
        }
Exemple #2
0
        public override IBaseMathOperator CalculateSimplyfy()
        {
            if (Math.Abs(multiply) < 0.00001d)
            {
                return(new ConstantMathOperator(0));
            }
            var temp = new VariableXMathOperator();

            temp.SetMultiply(multiply);
            temp.SetXValue(value);
            return(temp);
        }