예제 #1
0
        private static double Function_if(TreeNodeCollection Arguments, ArgumentsMap ArgsMap)
        {
            CheckArguments(Arguments, "if", 3);

            double condition = TreeNodeCalculator.Calculate(Arguments[0], ArgsMap);

            if (condition == 1)
            {
                return(TreeNodeCalculator.Calculate(Arguments[1], ArgsMap));
            }

            return(TreeNodeCalculator.Calculate(Arguments[2], ArgsMap));
        }
예제 #2
0
        public double Calculate(params Argument[] Arguments)
        {
            ArgumentsMap arguments = new ArgumentsMap();

            if (Arguments != null)
            {
                for (int i = 0; i < Arguments.Length; ++i)
                {
                    Argument arg = Arguments[i];
                    arguments[arg.Name] = arg.Value;
                }
            }

            return(TreeNodeCalculator.Calculate(node, arguments));
        }
예제 #3
0
        private static double Function_abs(TreeNodeCollection Arguments, ArgumentsMap ArgsMap)
        {
            CheckArguments(Arguments, "abs", 1);

            return(Math.Abs(TreeNodeCalculator.Calculate(Arguments[0], ArgsMap)));
        }
예제 #4
0
        private static double Function_log(TreeNodeCollection Arguments, ArgumentsMap ArgsMap)
        {
            CheckArguments(Arguments, "log", 1);

            return(Math.Log10(TreeNodeCalculator.Calculate(Arguments[0], ArgsMap)));
        }
예제 #5
0
        private static double Function_random(TreeNodeCollection Arguments, ArgumentsMap ArgsMap)
        {
            CheckArguments(Arguments, "random", 2);

            return(TreeNodeCalculator.Calculate(Arguments[0], ArgsMap) + rnd.NextDouble() * (TreeNodeCalculator.Calculate(Arguments[1], ArgsMap) - TreeNodeCalculator.Calculate(Arguments[0], ArgsMap)));
        }
예제 #6
0
        private static double Function_min(TreeNodeCollection Arguments, ArgumentsMap ArgsMap)
        {
            CheckArguments(Arguments, "min", 2);

            return(Math.Min(TreeNodeCalculator.Calculate(Arguments[0], ArgsMap), TreeNodeCalculator.Calculate(Arguments[1], ArgsMap)));
        }