Esempio n. 1
0
        private double Integrate(int index, double a, double b)
        {
            IFunction function = functions[index];

            if (!IsInvalid(function.Evaluate(a)) && !IsInvalid(function.Evaluate(b)))
            {
                return(integrator.Integrate(function, a, b).value);
            }

            return(0);
        }
        private void CalculateVolume(double a, double b)
        {
            if (!continuous)
            {
                PlanePlotter.ClearActions();
                volume = double.NaN;
            }
            else
            {
                IFunction vFunction;

                if (rotate == independent) // disc method
                {
                    vFunction = functions[0].Generate("(function)^2");
                    volume    = Math.PI * integrator.Integrate(vFunction, a, b).value;
                }
                else // washer method
                {
                    vFunction = functions[0].Generate(independent.ToString() + "*(function)");
                    volume    = 2 * Math.PI * integrator.Integrate(vFunction, a, b).value;
                }
            }
        }