Exemplo n.º 1
0
        public void ReTabulate(DoubleFunction3d fxy,
                               float x1, float x2,
                               float y1, float y2,
                               float StepX, float StepY)
        {
            // release memory or do something!
            // ...

            pts = Tabulate(fxy, x1, x2, y1, y2, StepX, StepY);
        }
Exemplo n.º 2
0
 public Graphic3D(DoubleFunction3d fxy,
                  float x1, float x2,
                  float y1, float y2,
                  float Step)
 {
     x_min = x1;
     x_max = x2;
     y_min = y1;
     y_max = y2;
     pts   = Tabulate(fxy, x1, x2, y1, y2, Step, Step);
 }
Exemplo n.º 3
0
        public Point3d[][] Tabulate(DoubleFunction3d fxy,
                                    float x1, float x2,
                                    float y1, float y2,
                                    float StepX, float StepY)
        {
            if (StepX < float.Epsilon)
            {
                throw new ArgumentOutOfRangeException("StepX", "Step is too small");
            }
            if (StepY < float.Epsilon)
            {
                throw new ArgumentOutOfRangeException("StepY", "Step is too small");
            }

            if (fxy == null)
            {
                throw new ArgumentNullException("fx");
            }

            List <Point3d>   dots = new List <Point3d>();
            List <Point3d[]> surf = new List <Point3d[]>();

            float z;

            for (float x = x1; x <= x2; x += StepX)
            {
                for (float y = y1; y <= y2; y += StepY)
                {
                    try
                    {
                        z = (float)fxy(x, y);

                        if ((z > int.MaxValue) || (z < int.MinValue))
                        {
                            throw new ArithmeticException();
                        }
                        if (float.IsInfinity(z) || float.IsNaN(z))
                        {
                            throw new ArithmeticException();
                        }
                    }
                    catch (ArithmeticException)
                    {
                        z = 0;
                    }

                    dots.Add(new Point3d(x, y, z));
                    if (z_max < z)
                    {
                        z_max = z;
                    }
                    if (z_min > z)
                    {
                        z_min = z;
                    }
                }

                surf.Add(dots.ToArray());
                dots.Clear();
            }
            return(surf.ToArray());
        }