Ejemplo n.º 1
0
        private static int[] getPattern(int index)
        {
            int n = (int)Math.Pow(index, (1.0 / 3.0));

            index -= (n * n * n);
            int[] p = new int[3];
            foreach (int i in LinearAlgebra.range(p.Length))
            {
                p[i] = n;
            }

            if (index == 0)
            {
                return(p);
            }
            index--;
            int v = index % 3;

            index = index / 3;
            if (index < n)
            {
                p[v] = index % n;
                return(p);
            }
            index     -= n;
            p[v]       = index / n;
            p[++v % 3] = index % n;
            return(p);
        }
Ejemplo n.º 2
0
        public static Dictionary <int, int> binDataOne(List <double> data, int numBins)
        {
            Dictionary <int, int> dataBins = new Dictionary <int, int>();

            foreach (int i in LinearAlgebra.range(numBins))
            {
                dataBins.Add(i, 0);
            }
            return(binDataOne(data, dataBins));
        }
        protected void PlotLines(Graphics gfx, int extendX, int extendY)
        // PlotLines – performs all the drawing operations needed to visualize the density vectors.
        { // widths and heights are mixed up
            drawBackground(gfx, extendX, extendY);

            float lineWidth = 2f;

            //if (data.Count > drawAreaWidth / stripHeight)
            stripHeight = (float)drawAreaWidth / (data.Count) - stripSpacing;

            SolidBrush brush = new SolidBrush(Color.Black);

            int maxLabels = (int)numLabels.Value;

            int skipLabel = (labels.Count + maxLabels - 1) / maxLabels;

            foreach (int i in LinearAlgebra.range(data.Count))
            {
                int maxLines = (int)(data[i].Count * (float)numYmax.Value);
                int minLines = (int)(data[i].Count * (float)numYmin.Value);

                lineWidth = (float)drawAreaHight / (maxLines - minLines);
                float x = drawAreaX + (i * (stripHeight + stripSpacing));

                for (int j = minLines; j < maxLines; j++)
                {
                    setBrush(ref brush, data[i][j]);

                    float y = lineWidth + drawAreaY + lineWidth * (j - minLines);

                    gfx.FillRectangle(brush, x, (drawAreaHight + 2 * drawAreaY) - y, stripHeight, lineWidth);
                }

                //if (!labelsAdded) VLabel(labels[i], x , labelY);
                if (i % skipLabel == 0) // skip excessive labels
                {
                    VLabel(gfx, labels[i], x, labelY, true);
                }
            }
            //drawBrush.Dispose();
            //drawFont.Dispose();
            //this.Update();
            labelsAdded = true;
        }
Ejemplo n.º 4
0
        protected virtual void PlotLines(float R, float G, float B)
        // PlotLines – performs all the drawing operations needed to visualize the density vectors.
        {
            drawBackground();

            int lineWidth = 2;

            if (data.Count > drawAreaHight / stripHeight)
            {
                stripHeight = drawAreaHight / (data.Count + 2);
            }

            foreach (int i in LinearAlgebra.range(data.Count))
            {
                lineWidth = drawAreaWidth / data[i].Count;
                int y = drawAreaHight + drawAreaY - stripHeight - (i * (stripHeight + stripSpacing));

                foreach (int j in LinearAlgebra.range(data[i].Count))
                {
                    int color = (int)(255 * ((double)data[i][j] * (double)numGain.Value));
                    if (color > 255)
                    {
                        color = 255;
                    }
                    SolidBrush brush = new SolidBrush(Color.FromArgb((int)(R * color), (int)(G * color), (int)(B * color)));

                    //Console.WriteLine("i: " + i + "j: " + j);
                    int x = 2 + drawAreaX + lineWidth * j;

                    graphics.FillRectangle(brush, x, y, lineWidth, stripHeight);
                }

                if (!labelsAdded)
                {
                    addLabel(y, labels[i]);
                }
            }
            this.Update();
            labelsAdded = true;
        }