Пример #1
0
 /// <summary>
 /// Update the perspective view parameters and replot
 /// </summary>
 private void UpdatePointOfView()
 {
     _panel.DefaultView.SetDeg(_cameraView.phi, _cameraView.rho, _cameraView.distance);
     hScrollBar_Phi.Value         = (int)(_cameraView.phi * 100.0);
     vScrollBar_Rho.Value         = (int)(_cameraView.rho * 100.0);
     numericUpDown_phi.Value      = (decimal)_cameraView.phi;
     numericUpDown_rho.Value      = (decimal)_cameraView.rho;
     numericUpDown_distance.Value = (decimal)_cameraView.distance;
     _panel.ResetView();
     _panel.Refresh();
 }
Пример #2
0
        void m_timer_Tick(object sender, EventArgs e)
        {
            m_bars.Queue((float)(Environment.TickCount - m_lastTickCount - s_lastDur));
            s_lastDur       = Environment.TickCount - m_lastTickCount;
            m_lastTickCount = Environment.TickCount;

            m_panel.Refresh();
        }
        private static void InitPanel(ILPanel panel, NeuralNetwork ann)
        {
            panel.Scene.Remove(panel.Scene.First <ILPlotCube>());
            int xmin = (int)ann.Instance.Samples[0].Variables[0];
            int xmax = (int)ann.Instance.Samples[ann.Instance.NumSamples - 1].Variables[0];
            int ymin = (int)ann.Instance.Samples[0].Variables[1];
            int ymax = (int)ann.Instance.Samples[ann.Instance.NumSamples - 1].Variables[0];

            ILArray <double> positions = ILMath.zeros <double>(3, ann.Instance.NumSamples);

            int index = 0;

            foreach (var sample in ann.Instance.Samples)
            {
                positions[0, index] = sample.Variables[0];
                positions[1, index] = sample.Variables[1];
                positions[2, index] = sample.Value;
                index++;
            }

            ILPlotCube cube = new ILPlotCube(twoDMode: false)
            {
                // rotate plot cube
                Rotation = Matrix4.Rotation(new Vector3(-1, 1, .1f), 0.4f),
                // perspective projection
                Projection = Projection.Perspective,
                Children   =
                {
                    new ILSurface((x,   y) => 0,
                                  xmin, xmax,                                                       50,
                                  ymin, ymax,                                                       50,
                                  (x,   y) => x * y,
                                  colormap: Colormaps.Autumn)
                    {
                        UseLighting = true
                    },
                    new ILSurface((x,   y) => (float)Convert(ann.Instance.OriginalFunction.ValueAt,x,  y),
                                  xmin, xmax,                                                       50,
                                  ymin, ymax,                                                       50,
                                  (x,   y) => x * y,
                                  colormap: Colormaps.Hsv)
                    {
                        UseLighting = true
                    },
                    // add line plot, provide data as rows
                    new ILPoints {
                        Positions = ILMath.tosingle(positions),
                        Color     = Color.Red
                    }
                }
            };

            panel.Scene.Add(cube);
            panel.Scene.First <ILPlotCube>().Rotation = Matrix4.Rotation(Vector3.UnitX, .8f) * Matrix4.Rotation(Vector3.UnitZ, .6f);
            panel.Refresh();
        }
Пример #4
0
        private ILPanelEditor(ILPanel ilPanel, IPanelEditor editor = null)
        {
            this.ilPanel = ilPanel;
            this.editor = editor ?? new PanelEditorForm(this);
            this.editor.PropertyChanged += (o, args) =>
            {
                OnPropertyChanged(args.PropertyName);

                ilPanel.Configure();
                ilPanel.Refresh();
            };

            ilPanel.Scene.Add(this);
        }
Пример #5
0
        protected override void RunInternal(object parameter)
        {
            float x1    = m_MinCornerStart.X;
            float y1    = m_MinCornerStart.Y;
            float z1    = m_MinCornerStart.Z;
            float x2    = m_MaxCornerStart.X;
            float y2    = m_MaxCornerStart.Y;
            float z2    = m_MaxCornerStart.Z;
            float aMinX = m_MinCornerEnd.X - x1;
            float aMinY = m_MinCornerEnd.Y - y1;
            float aMinZ = m_MinCornerEnd.Z - z1;
            float aMaxX = m_MaxCornerEnd.X - x2;
            float aMaxY = m_MaxCornerEnd.Y - y2;
            float aMaxZ = m_MaxCornerEnd.Z - z2;

            foreach (ILActionRampElement elem in m_ramp)
            {
                if (m_canceled)
                {
                    return;
                }
                ILPoint3Df min = new ILPoint3Df(
                    x1 + aMinX * elem.Value,
                    y1 + aMinY * elem.Value,
                    z1 + aMinZ * elem.Value);
                ILPoint3Df max = new ILPoint3Df(
                    x2 + aMaxX * elem.Value,
                    y2 + aMaxY * elem.Value,
                    z2 + aMaxZ * elem.Value);
                m_panel.Limits.Set(min, max);
                m_panel.Refresh();
                if (m_canceled)
                {
                    return;
                }
                Thread.Sleep((int)(elem.Duration * 1000));
            }
        }
        private static void DrawFunctions(ILPanel panel, NeuralNetwork ann)
        {
            int xmin = (int)ann.Instance.Samples[0].Variables[0];
            int xmax = (int)ann.Instance.Samples[ann.Instance.NumSamples - 1].Variables[0];
            int ymin = (int)ann.Instance.Samples[0].Variables[1];
            int ymax = (int)ann.Instance.Samples[ann.Instance.NumSamples - 1].Variables[0];

            var approximatedFunction = new ILSurface((x, y) => (float)Convert(ann.GetOutput, x, y)[0],
                                                     xmin, xmax, 50,
                                                     ymin, ymax, 50,
                                                     (x, y) => x * y,
                                                     colormap: Colormaps.Autumn)
            {
                UseLighting = true
            };

            panel.Invoke((Action) delegate
            {
                panel.Scene.Remove(panel.Scene.First <ILSurface>());
                panel.Scene.First <ILPlotCubeDataGroup>().Insert(0, approximatedFunction);
                panel.Refresh();
            });
        }
        public static void FillResults(ILPanel panel, Panel panelFuzzySets, NeuralNetwork ann)
        {
            SetFuzzySets(panelFuzzySets, ann);
            int xmin = (int)ann.Instance.Samples[0].Variables[0];
            int xmax = (int)ann.Instance.Samples[ann.Instance.NumSamples - 1].Variables[0];
            int ymin = (int)ann.Instance.Samples[0].Variables[1];
            int ymax = (int)ann.Instance.Samples[ann.Instance.NumSamples - 1].Variables[0];

            ErrorFunction er   = new ErrorFunction(ann.Instance.Samples, ann);
            ILPlotCube    cube = new ILPlotCube(twoDMode: false)
            {
                // rotate plot cube
                Rotation = Matrix4.Rotation(new Vector3(-1, 1, .1f), 0.4f),
                // perspective projection
                Projection = Projection.Perspective,
                Children   =
                {
                    new ILSurface((x,   y) => (float)Convert(er.ValueAt, x,               y),
                                  xmin, xmax,                            xmax - xmin + 1,
                                  ymin, ymax,                            ymax - ymin + 1,
                                  (x,   y) => x * y,
                                  colormap: Colormaps.Hsv)
                    {
                        UseLighting = true
                    }
                }
            };

            panel.Scene.Remove(panel.Scene.First <ILPlotCube>());
            panel.Scene.Add(cube);
            panel.Scene.Screen.Add(new ILLabel("Error per sample")
            {
                Position = new Vector3(1, 0, 0),
                Anchor   = new PointF(1, 0)
            });
            panel.Refresh();
        }
        private static void SetFuzzySets(Panel panel, NeuralNetwork ann)
        {
            foreach (TableLayoutPanel item in panel.Controls.OfType <TableLayoutPanel>())
            {
                panel.Controls.Remove(item);
            }

            panel.AutoScroll = true;
            panel.AutoSize   = false;

            TableLayoutPanel table = new TableLayoutPanel
            {
                Dock         = DockStyle.None,
                AutoSize     = true,
                AutoSizeMode = AutoSizeMode.GrowAndShrink,
                AutoScroll   = false
            };
            int numVariables = ann.Instance.NumVariables;
            int numRules     = ann.NumberOfRules;
            var columnCount  = numRules;
            int rowCount     = numVariables;

            IActivationFunction[] func = ann.GetFunctions <IActivationFunction>(0);
            double[] xValues           = new double[50];
            double[] yValues           = new double[50];
            for (int i = 0; i < 50; i++)
            {
                xValues[i] = -10 + (10.0 + 10.0) / 50.0 * i;
            }
            ILArray <float> xs = (double[])xValues.Clone();

            for (var i = 0; i < rowCount; i++)
            {
                table.RowCount++;
                table.RowStyles.Add(new RowStyle(SizeType.AutoSize));
                for (int j = 0; j < columnCount; j++)
                {
                    int     ruleId     = j + 1;
                    int     variableId = i + 1;
                    string  label      = "Rule " + ruleId + ", variable " + variableId;
                    ILPanel newPanel   = new ILPanel();
                    for (int k = 0; k < 50; k++)
                    {
                        yValues[k] = func[i * columnCount + j].ValueAt(xValues[k]);
                    }
                    ILArray <float> ys = (double[])yValues.Clone();
                    newPanel.Scene.Remove(newPanel.Scene.First <ILPlotCube>());
                    newPanel.Scene.Add(new ILPlotCube {
                        Children =
                        {
                            new ILLinePlot(xs, ys, lineWidth:2, lineColor:Color.Black)
                        }
                    });
                    newPanel.Scene.Screen.Add(new ILLabel(label)
                    {
                        Position = new Vector3(1, 0, 0),
                        Anchor   = new PointF(1, 0)
                    });
                    newPanel.Refresh();
                    table.ColumnCount++;
                    table.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize));
                    table.Controls.Add(newPanel, j, i);
                }
            }
            panel.Controls.Add(table);
            panel.Refresh();
        }
Пример #9
0
 void m_timer_Tick(object sender, EventArgs e)
 {
     m_offset          += (float)(Math.PI / 100);
     m_vectorField.Data = ILVectorField2D.Computation.CreateTestData(10, 15, m_offset);
     m_panel.Refresh();
 }