public void CalculateTest(double arOne, double expected)
        {
            var calculator   = new Cotangens();
            var actualResult = calculator.Calculate(arOne);

            Assert.AreEqual(expected, actualResult, 0.001);
        }
Exemple #2
0
        public ViewModel()
        {
            _plot = new Plots();

            Cosinus cosinus = new Cosinus();

            cosinus.PropertyChanged += (s, e) => { RaisePropertyChanged("Amplitude_Cos"); };
            MyFunction.Add(cosinus);

            Sinus sinus = new Sinus();

            sinus.PropertyChanged += (s, e) => { RaisePropertyChanged("Amplitude_Sin"); };
            MyFunction.Add(sinus);

            Tangens tangens = new Tangens();

            tangens.PropertyChanged += (s, e) => { RaisePropertyChanged("Amplitude_Tan"); };
            MyFunction.Add(tangens);

            Cotangens cotangens = new Cotangens();

            cotangens.PropertyChanged += (s, e) => { RaisePropertyChanged("Amplitude_Cot"); };
            MyFunction.Add(cotangens);

            plotModel = new PlotModel();
            plotModel = _plot._PlotModel;
        }
        /// <summary>
        ///     Function expression
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override Function VisitFunction(CalculatorParser.FunctionContext context)
        {
            Function res = null;

            //Trigonometric functions
            if (FunctionMap[context.fun.Type] is Sinus)
            {
                res = new Sinus(Visit(context.expr()));
            }
            if (FunctionMap[context.fun.Type] is Cosinus)
            {
                res = new Cosinus(Visit(context.expr()));
            }
            if (FunctionMap[context.fun.Type] is Tangens)
            {
                res = new Tangens(Visit(context.expr()));
            }
            if (FunctionMap[context.fun.Type] is Cotangens)
            {
                res = new Cotangens(Visit(context.expr()));
            }

            //Elementary functions
            if (FunctionMap[context.fun.Type] is Sqrt)
            {
                res = new Sqrt(Visit(context.expr()));
            }
            if (FunctionMap[context.fun.Type] is Logarithm)
            {
                res = new Logarithm(Visit(context.expr()));
            }
            if (FunctionMap[context.fun.Type] is Exponenta)
            {
                res = new Exponenta(Visit(context.expr()));
            }

            //Inverse Trigonometric functions
            if (FunctionMap[context.fun.Type] is ArcSinus)
            {
                res = new ArcSinus(Visit(context.expr()));
            }
            if (FunctionMap[context.fun.Type] is ArcCosinus)
            {
                res = new ArcCosinus(Visit(context.expr()));
            }
            if (FunctionMap[context.fun.Type] is ArcTangens)
            {
                res = new ArcTangens(Visit(context.expr()));
            }
            if (FunctionMap[context.fun.Type] is ArcCotangens)
            {
                res = new ArcCotangens(Visit(context.expr()));
            }

            //Hyperbolic functions
            if (FunctionMap[context.fun.Type] is HypSinus)
            {
                res = new HypSinus(Visit(context.expr()));
            }
            if (FunctionMap[context.fun.Type] is HypCosinus)
            {
                res = new HypCosinus(Visit(context.expr()));
            }
            if (FunctionMap[context.fun.Type] is HypTangens)
            {
                res = new HypTangens(Visit(context.expr()));
            }
            if (FunctionMap[context.fun.Type] is HypCotangens)
            {
                res = new HypCotangens(Visit(context.expr()));
            }

            return(res);
        }