Beispiel #1
0
 private void UpdateLimit(double i, double d, double f, FunctionPoint p, bool condition)
 {
     if (condition)
     {
         p.Set(i, d, f);
     }
 }
Beispiel #2
0
        private void EvaluateIntersection(double i1, double i2)
        {
            if (ordered.Index(i1, 0) != ordered.Index(i2, 0))
            {
                int ia = ordered.Index(i1, 1);
                int ib = ordered.Index(i1, 0);

                double da1 = functions[ia].Evaluate(i1);
                double db1 = functions[ib].Evaluate(i1);

                double da2 = functions[ia].Evaluate(i2);
                double db2 = functions[ib].Evaluate(i2);

                if (IsInvalid(da1) || IsInvalid(db1) || IsInvalid(da2) || IsInvalid(db2))
                {
                    PlotArea();
                    return;
                }

                FunctionPoint root = FunctionLine.Intersection(i1, da1, db1, i2, da2, db2);

                if ((decimal)root.i >= (decimal)i1 && (decimal)root.i <= (decimal)i2)
                {
                    AddTopAreaPoint(root);
                }

                PlotArea();

                if ((decimal)root.i < (decimal)i2)
                {
                    AddTopAreaPoint(root.i, root.d);
                }
            }
        }
Beispiel #3
0
 protected override void AfterPlot(double a, double b, FunctionPoint minI, FunctionPoint maxI,
                                   FunctionPoint minD, FunctionPoint maxD, FunctionPoint minF, FunctionPoint maxF)
 {
     if (!closed)
     {
         area = double.NaN;
     }
 }
Beispiel #4
0
        public static double GetYValue(this SortedSet <FunctionPoint> function, int xValue)
        {
            var yValue = function.FirstOrDefault(e => e.X == xValue).Y;

            if (!function.Any(e => e.X == xValue))
            {
                var leftPoint  = function.GetViewBetween(new FunctionPoint(double.NegativeInfinity), new FunctionPoint(xValue)).Max;
                var rightPoint = function.GetViewBetween(new FunctionPoint(xValue), new FunctionPoint(double.PositiveInfinity)).Min;
                yValue = FunctionPoint.Interplate(leftPoint, rightPoint, xValue);
            }
            return(yValue);
        }
Beispiel #5
0
        public static int GetXValue(this SortedSet <FunctionPoint> function, double yValue)
        {
            var sortedSet = new SortedSet <FunctionPoint>(function.Select(e => new FunctionPoint(e.Y, e.X)));
            var xValue    = (int)function.FirstOrDefault(e => e.Y == yValue).X;

            if (!function.Any(e => e.Y == yValue))
            {
                var leftPoint  = sortedSet.GetViewBetween(new FunctionPoint(double.NegativeInfinity), new FunctionPoint(yValue)).Max;
                var rightPoint = sortedSet.GetViewBetween(new FunctionPoint(yValue), new FunctionPoint(double.PositiveInfinity)).Min;
                xValue = (int)Math.Round(FunctionPoint.Interplate(leftPoint, rightPoint, yValue), MidpointRounding.ToEven);
            }
            return(xValue);
        }
Beispiel #6
0
        protected FunctionPlotter(GameObject parent, Mesh lineMesh, Material axisMaterial,
                                  Material functionMaterial, Material planeMaterial)
        {
            this.parent            = parent;
            this.lineMesh          = lineMesh;
            this.axisMaterial      = axisMaterial;
            this.functionPoints    = new List <List <Point> >();
            this.functionMaterials = new Material[LineColor.Count()];
            this.planeMaterials    = new Material[PlaneColor.Count()];
            this.axisEnabled       = new Dictionary <Axis, bool>();

            axisEnabled[Axis.x] = axisEnabled[Axis.y] = axisEnabled[Axis.z] = true;

            minI = new FunctionPoint();
            maxI = new FunctionPoint();
            minD = new FunctionPoint();
            maxD = new FunctionPoint();
            minF = new FunctionPoint();
            maxF = new FunctionPoint();

            CreateMaterials(functionMaterial, planeMaterial);
        }
 protected override void AfterPlot(double a, double b, FunctionPoint minI, FunctionPoint maxI,
                                   FunctionPoint minD, FunctionPoint maxD, FunctionPoint minF, FunctionPoint maxF)
 {
     CalculateVolume(a, b);
 }
Beispiel #8
0
 protected virtual void AfterPlot(double a, double b, FunctionPoint minI, FunctionPoint maxI,
                                  FunctionPoint minD, FunctionPoint maxD, FunctionPoint minF, FunctionPoint maxF)
 {
 }
Beispiel #9
0
 private void AddBottomAreaPoint(FunctionPoint fp)
 {
     bottomAreaPoints.Add(fp.ToPoint(independent, dependent));
 }
Beispiel #10
0
 private void AddTopAreaPoint(FunctionPoint fp)
 {
     topAreaPoints.Add(fp.ToPoint(independent, dependent));
 }