Ejemplo n.º 1
0
        /// <summary>
        /// Puts into variables FindMin and FindMax the minimal and maximal values of the function FOP on the lattice NDiv*Ndiv at the area Area
        /// </summary>
        /// <param name="FOP"></param>
        /// <param name="Area"></param>
        /// <param name="NDiv"></param>
        /// <param name="FindMin"></param>
        /// <param name="FindMax"></param>
        static public void FindExtrema(FuncOnPoint FOP, RectangleF Area, int NDiv, ref double FindMin, ref double FindMax)
        {
            MyPointDouble LeftUpCor = new MyPointDouble(Area.Left, Area.Top, 0.0);
            MyPointDouble HorizStep = new MyPointDouble(Area.Width / NDiv, 0.0, 0.0);
            MyPointDouble VertStep  = new MyPointDouble(0.0, Area.Height / NDiv, 0.0);
            MyPointDouble PtIter    = LeftUpCor + 0.5 * HorizStep + 0.5 * VertStep;

            FindMin = FOP(PtIter.x, PtIter.y);
            FindMax = FOP(PtIter.x, PtIter.y);

            double heightl = Area.Height / NDiv;
            double widthl  = Area.Width / NDiv;

            for (int i = 1; i <= NDiv; i++)
            {
                for (int j = 1; j <= NDiv; j++)
                {
                    PtIter = LeftUpCor + (i - 0.5) * HorizStep + (j - 0.5) * VertStep;
                    if (FOP(PtIter.x, PtIter.y) < FindMin)
                    {
                        FindMin = FOP(PtIter.x, PtIter.y);
                    }
                    if (FOP(PtIter.x, PtIter.y) > FindMax)
                    {
                        FindMax = FOP(PtIter.x, PtIter.y);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        /// <summarly>
        ///  Makes the color plot of the function whose values at the polygon polygons[i-1] is values[i-1]
        /// </summary>
        /// <param name="graphl">the object at which the plot will be drawn</param>
        /// <param name="polygons">the table of polygons</param>
        /// <param name="values">the table of values</param>

        /* static public void ColorAreas(ref Graphics graphl, List<MyPolygon> polygons, double[] values, MyGraphOperations.ColorsFunc ColFunc)
         * {
         *
         *   if (graphl == null) throw new ArgumentNullException();
         *   if (polygons.Count() != values.Count()) throw new ArgumentException("The number of elements in polygons is not equal to the number of elements in values");
         *   for (int Iterator = 1; Iterator <= polygons.Count(); Iterator++)
         *   {
         *
         *       graphl.FillPolygon(BrushForColor(ColFunc, values[Iterator - 1]), polygons[Iterator - 1].Apexes());
         *   }
         * }*/

        /// <summary>
        /// Makes the color plot of the function FunVal in the area Area at the Graphl - the number of divisions along each from both axes is NDiv
        /// </summary>
        /// <param name="FunVal"></param>
        /// <param name="ColFunc"></param>
        /// <param name="Area"></param>
        /// <param name="TrMatrix">The matrix which will be used for making transformations of coordinates from the Area to the coordinate system in which the function will be drawn   </param>
        static public void ColorFunc(ref Graphics Graphl, FuncOnPoint FOP, MyGraphOperations.ColorsFunc ColFunc, RectangleF Area, int NDiv, Matrix TrMatrix)
        {
            MyPointDouble LeftDownCor = new MyPointDouble(Area.Left, Area.Top, 0.0);
            MyPointDouble HorizStep   = new MyPointDouble(Area.Width / NDiv, 0.0, 0.0);
            MyPointDouble VertStep    = new MyPointDouble(0.0, Area.Height / NDiv, 0.0);

            MyPointDouble LeftDownCorPlot = LeftDownCor;

            MyPointDouble HorizStepPlot = HorizStep;
            MyPointDouble VertStepPlot  = VertStep;


            MyPointDouble PtIter     = new MyPointDouble(0.0, 0.0, 0.0);
            MyPointDouble PtIterPlot = new MyPointDouble(0.0, 0.0, 0.0);

            MyDrawing.TransformPoint(TrMatrix, ref LeftDownCorPlot);
            MyDrawing.TransformVector(TrMatrix, ref HorizStepPlot);
            MyDrawing.TransformVector(TrMatrix, ref VertStepPlot);

            double heightl = Area.Height / NDiv;
            double widthl  = Area.Width / NDiv;


            //Matrix AddTransf = new Matrix(1.0F, 0.0F, 0.0F, 1.0F, 0.0F, 50.0F);

            for (int i = 1; i <= NDiv; i++)
            {
                for (int j = 1; j <= NDiv; j++)
                {
                    PtIter     = LeftDownCor + (i - 0.5) * HorizStep + (j - 0.5) * VertStep;
                    PtIterPlot = LeftDownCorPlot + (i - 1.0) * HorizStepPlot + (j - 1) * VertStepPlot;
                    //TransformPoint(AddTransf, ref PtIterPlot);
                    RectangleF RecLoc = new RectangleF((float)(PtIterPlot.x), (float)(PtIterPlot.y), (float)HorizStepPlot.x, (float)VertStepPlot.y);
                    Graphl.FillRectangle(BrushForColor(ColFunc, FOP(PtIter.x, PtIter.y)), RecLoc);
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// The homologue of ColorFuncNorm for the case of the array of polygons with values with the use of the default function DefColFunc
        /// </summary>
        /// <param name="Graphl">the object at which the plot will be drawn</param>
        /// <param name="polygons">polygons delimiting regions</param>
        /// <param name="values">values of the function at polygons</param>

        /*  static public void ColorTableNorm(ref Graphics graphl, List<MyPolygon> polygons, double[] values)
         * {
         *    ColorTableNorm(ref graphl,  polygons, values, DefColFunc);
         * }*/



        /// <summary>
        /// The homologue of ColorFuncNorm for the case of the array of polygons with values
        /// </summary>
        /// <param name="Graphl">the object at which the plot will be drawn</param>
        /// <param name="polygons">polygons delimiting regions</param>
        /// <param name="values">values of the function at polygons</param>
        /// <param name="ColFunc">the function used for finding colors</param>

        /*static public void ColorTableNorm(ref Graphics graphl, List<MyPolygon> polygons, double[] values, ColorsFunc ColFunc)
         * {
         *  if (graphl == null) throw new ArgumentNullException();
         *  if (polygons.Count() != values.Count()) throw new ArgumentException("The number of elements in the list polygons is different from the number in the list values");
         *  DefColFuncMax=values.Max();
         *  DefColFuncMin = values.Min();
         *  ColorAreas(ref graphl, polygons, values, ColFunc);
         * }*/

        /// <summary>
        /// Makes the "normalized" color plot of the function FunVal in the area Area at the Graphl  with the help of the function DefColFunc- the number of divisions along each from both axes is NDiv
        /// </summary>
        /// <param name="Graphl"></param>
        /// <param name="FOP"></param>
        /// <param name="ColFunc"></param>
        /// <param name="Area"></param>
        /// <param name="NDiv"></param>
        /// <param name="TrMatrix">The matrix which will be used for making transformations of coordinates from the Area to the coordinate system in which the function will be drawn   </param>
        static public void ColorFuncNorm(ref Graphics Graphl, FuncOnPoint FOP, MyGraphOperations.ColorsFunc ColFunc, RectangleF Area, int NDiv, Matrix TrMatrix)
        {
            FindExtrema(FOP, Area, NDiv, ref DefColFuncMin, ref DefColFuncMax);
            ColorFunc(ref Graphl, FOP, DefColFunc, Area, NDiv, TrMatrix);
        }