Exemplo n.º 1
0
        private void ShowParticleOnGraph(Populacja tmp, int size = 10)
        {
            double best = tmp.population.Min(x => x.fitnessValue);

            foreach (Particle item in tmp.population)
            {
                ILArray <float> coords = new float[3];
                coords[0] = (float)item.position[0];
                coords[1] = (float)item.position[1];
                coords[2] = (float)item.fitnessValue;// +1000;
                ILPoints bod = surface.Add(Shapes.Point);
                //surface.Colormap = Colormaps.Hot;

                if (item.fitnessValue == best)
                {
                    bod.Color = Color.Red;
                    bod.Size  = 10;
                }
                else
                {
                    bod.Color = Color.Black;
                    bod.Size  = size;
                }

                bod.Positions.Update(coords);
                surface.Add(bod);
            }
        }
Exemplo n.º 2
0
        private void RenderPopulation()
        {
            var points = new float[_population.CurrentPopulation.Count, _population.Dimensions + 1];

            for (var i = 0; i < _population.CurrentPopulation.Count; i++)
            {
                var individual = _population.CurrentPopulation[i];
                points[i, 0] = (float)individual.Position[0];
                points[i, 1] = (float)individual.Position[1];
                points[i, 2] = (float)individual.Cost + 1000; // render point higher then function
            }

            if (_points != null)
            {
                _plotCube.Remove(_points);
                _points.Dispose();
            }

            _points       = new ILPoints();
            _points.Color = Color.White;
            _points.Positions.Update(points);
            _plotCube.Add(_points);

            RenderBestIndividual();
            renderContainer.Refresh();
        }
Exemplo n.º 3
0
        private void drawOnlyPoints(Random random)
        {
            for (int i = 0; i < carDealers.Count; i++)
            {
                Color color = roundColor(random);

                try
                {
                    float[,] pointsForCar = new float[carDealers[i].carList.Count, 3];
                    for (int j = 0; j < carDealers[i].carList.Count; j++)
                    {
                        pointsForCar[j, 0] = carDealers[i].carList[j].age;
                        pointsForCar[j, 1] = carDealers[i].carList[j].beuty;
                        pointsForCar[j, 2] = 0;
                    }

                    ILPoints points = new ILPoints();
                    points.Positions = pointsForCar;
                    points.Color     = color;

                    plotCube.Add(points);
                }
                catch (NullReferenceException e)
                {
                    Debug.WriteLine("Poleciał wyjątek brak listy samchoddów.");
                }
            }
        }
Exemplo n.º 4
0
            public static void UpdateBalls(Vector3 center, ILPoints balls, ILOutArray <float> velocity, bool addBalls)
            {
                using (ILScope.Enter()) {
                    ILArray <float> position = balls.Positions.Storage;
                    ILArray <float> colors   = balls.Colors.Storage;
                    if (addBalls)
                    {
                        // increase number of balls (this is very inefficient!)
                        position[full, r(end + 1, end + 10)] = tosingle(randn(3, 10));
                        colors[full, r(end + 1, end + 10)]   = tosingle(rand(4, 10));
                        velocity[full, r(end + 1, end + 10)] = tosingle(randn(3, 10));
                    }
                    ILArray <float> d    = array <float>(center.X, center.Y, center.Z);
                    ILArray <float> off  = position * 0.1f;
                    ILArray <float> dist = sqrt(sum(position * position));
                    ILArray <int> where   = find(dist < 0.2f);
                    velocity[full, where] = velocity[full, where]
                                            + tosingle(rand(3, where.Length)) * 0.2f;
                    dist.a     = position - d;
                    off.a      = off + dist * -0.02f / sqrt(sum(dist * dist));
                    velocity.a = velocity * 0.95f - off;
                    balls.Positions.Update(position + velocity * 0.12f);
                    ILArray <float> Zs = abs(position[end, full]);

                    colors[end, full] = Zs / maxall(Zs) * 0.7f + 0.3f;
                    balls.Colors.Update(colors);
                }
            }
Exemplo n.º 5
0
        private void drawPointsAndLines(Random random)
        {
            for (int i = 0; i < boundaryPoints.Count; i++)
            {
                Color color = roundColor(random);
                for (int j = 0; j < boundaryPoints[i].Count; j++)
                {
                    Debug.WriteLine("Rysuję punkt: " + boundaryPoints[i][j].toString());

                    Models.Point thirdPoint = findThirdPoint(new Models.Point(0, 0), new Models.Point(boundaryPoints[i][j].x1, boundaryPoints[i][j].x2), maxPointValue);
                    float[,] array2D = new float[, ] {
                        { 0, 0 }, { boundaryPoints[i][j].x1, boundaryPoints[i][j].x2 }, { thirdPoint.x1, thirdPoint.x2 }
                    };
                    ILArray <float> Pos = array2D;
                    plotCube.Add(new ILLinePlot(Pos, tag: "mylineplot")
                    {
                        Line =
                        {
                            Width        =     2,
                            Color        = color,
                            Antialiasing = true,
                            DashStyle    = DashStyle.Solid
                        }
                    });
                }

                try
                {
                    float[,] pointsForCar = new float[carDealers[i].carList.Count, 3];
                    for (int j = 0; j < carDealers[i].carList.Count; j++)
                    {
                        pointsForCar[j, 0] = carDealers[i].carList[j].age;
                        pointsForCar[j, 1] = carDealers[i].carList[j].beuty;
                        pointsForCar[j, 2] = 0;
                    }

                    ILPoints points = new ILPoints();
                    points.Positions = pointsForCar;
                    points.Color     = color;

                    plotCube.Add(points);
                }
                catch (NullReferenceException e)
                {
                    Debug.WriteLine("Poleciał wyjątek brak listy samchoddów.");
                }
            }
        }
Exemplo n.º 6
0
        private void RenderBestIndividual()
        {
            var best      = _population.BestIndividual;
            var bestPoint = new[] { (float)best.Position[0], (float)best.Position[1], (float)best.Cost + 1500 }; // render point higher then function and other points

            if (_bestPoint != null)
            {
                _plotCube.Remove(_bestPoint);
                _bestPoint.Dispose();
            }

            _bestPoint = new ILPoints {
                Color = Color.BlueViolet
            };
            _bestPoint.Positions.Update(bestPoint);

            _plotCube.Add(_bestPoint);
        }
Exemplo n.º 7
0
        // Initial plot setup, modify this as needed
        private void ilPanel1_Load(object sender, EventArgs e)
        {
            ILPlotCube plotCube = new ILPlotCube();

            ILPoints points = new ILPoints();

            points.Positions = list0;
            points.Color     = Color.Red;

            ILPoints points2 = new ILPoints();

            points2.Positions = list1;
            points2.Color     = Color.Blue;

            plotCube.Add(points);
            plotCube.Add(points2);

            ilPanel1.Scene.Add(plotCube);
        }
        public override void Draw(ILRenderProperties props, ILShape shape)
        {
            GL.Enable(EnableCap.Blend);
            GL.BlendFunc(BlendingFactorSrc.SrcAlpha,
                         BlendingFactorDest.OneMinusSrcAlpha);
            GL.Enable(EnableCap.DepthTest);
            ILPoints points = (shape as ILPoints);

            fixed(C4bV3f *pVertices = points.Vertices)
            {
                GL.InterleavedArrays(InterleavedArrayFormat.C4ubV3f, 0, (IntPtr)pVertices);
                if (points.Shading == ShadingStyles.Flat)
                {
                    GL.DisableClientState(EnableCap.ColorArray);
                    GL.Color4(points.FillColor);
                }
                GL.Enable(EnableCap.PointSmooth);
                GL.PointSize(points.Width);
                GL.DrawArrays(BeginMode.Points, 0, points.VertexCount);
            }
        }
        public void reDraw(float[,] givenLocs)
        {
            ILArray<float> ourPositions = givenLocs;

            var scene = new ILScene();
            var plotCube = scene.Add(new ILPlotCube(null,false));

            var ourPosBuffer = new ILPoints();
            ourPosBuffer.Positions = ourPositions;
            ourPosBuffer.Size = 5;
            ourPosBuffer.Color = Color.White;

            plotCube.Add(ourPosBuffer);
            plotCube.FieldOfView = 60;
            plotCube.LookAt = new Vector3(0, 0, 0);

            plotCube.ScaleModes.XAxisScale = AxisScale.Linear;
            plotCube.ScaleModes.YAxisScale = AxisScale.Linear;
            plotCube.ScaleModes.ZAxisScale = AxisScale.Linear;

            //set label colors. This is all over the place.
            var xLabel = plotCube.Axes.XAxis.Ticks.DefaultLabel;
            xLabel.Color = Color.White;

            var yLabel = plotCube.Axes.YAxis.Ticks.DefaultLabel;
            yLabel.Color = Color.White;

            var zLabel = plotCube.Axes.ZAxis.Ticks.DefaultLabel;
            zLabel.Color = Color.White;

            plotCube.Axes.XAxis.Label.Color = Color.White;
            plotCube.Axes.YAxis.Label.Color = Color.White;
            plotCube.Axes.ZAxis.Label.Color = Color.White;

            //designed to create a starfield look.
            iLStarChart.Scene = scene;
            iLStarChart.BackColor = Color.Black;
            iLStarChart.ForeColor = Color.White;
            iLStarChart.Scene.Configure();
        }
Exemplo n.º 10
0
Arquivo: Form1.cs Projeto: daywee/BIA
        private void RenderAdditionalPoints()
        {
            var points = new float[_population.AdditionalIndividualsToRender.Count, _population.Dimensions + 1];

            for (var i = 0; i < _population.AdditionalIndividualsToRender.Count; i++)
            {
                var individual = _population.AdditionalIndividualsToRender[i];
                points[i, 0] = (float)individual[0];
                points[i, 1] = (float)individual[1];
                points[i, 2] = (float)individual.Cost + 1000; // render point higher then function
            }

            if (_additionalPoints != null)
            {
                _plotCube.Remove(_additionalPoints);
                _additionalPoints.Dispose();
            }

            _additionalPoints       = new ILPoints();
            _additionalPoints.Color = Color.Yellow;
            _additionalPoints.Positions.Update(points);
            _plotCube.Add(_additionalPoints);
        }
Exemplo n.º 11
0
        private void SetExampleScene(IILPanelForm panel)
        {
            if (m_cleanUpExample != null) {
                m_cleanUpExample();
                m_cleanUpExample = null;
            }
            ILScene scene = new ILScene();
            try {
                ILLabel.DefaultFont = new System.Drawing.Font("Helvetica", 8);
                //ilPanel1.Driver = RendererTypes.GDI;

                #region upper left plot
                // prepare some data
                ILArray<float> P = 1,
                    x = ILMath.linspace<float>(-2, 2, 40),
                    y = ILMath.linspace<float>(2, -2, 40);

                ILArray<float> F = ILMath.meshgrid(x, y, P);
                // a simple RBF
                ILArray<float> Z = ILMath.exp(-(1.2f * F * F + P * P));
                // surface expects a single matrix
                Z[":;:;2"] = F; Z[":;:;1"] = P;

                // add a plot cube
                var pc = scene.Add(new ILPlotCube {
                    // shrink viewport to upper left quadrant
                    ScreenRect = new RectangleF(0.05f, 0, 0.4f, 0.5f),
                    // 3D rotation
                    TwoDMode = false,
                    Children = {
                        // add surface
                        new ILSurface(Z) {
                            // disable mouse hover marking
                            Fill = { Markable = false },
                            Wireframe = { Markable = false },
                            // make it shiny
                            UseLighting = true,
                            Children = { new ILColorbar() }
                        },
                        //ILLinePlot.CreateXPlots(Z["1:10;:;0"], markers: new List<MarkerStyle>() {
                        //    MarkerStyle.None,MarkerStyle.None,MarkerStyle.None,MarkerStyle.None,MarkerStyle.Circle, MarkerStyle.Cross, MarkerStyle.Plus, MarkerStyle.TriangleDown }),
                        //new ILLegend("hi","n","ku","zs","le", "blalblalblalblalb\\color{red} hier gehts rot")
                    },
                    Rotation = Matrix4.Rotation(new Vector3(1.1f, -0.4f, -0.69f), 1.3f)
                });

                #endregion

                #region top right plot
                // create a gear shape
                var gear = new ILGear(toothCount: 30, inR: 0.5f, outR: 0.9f) {
                    Fill = { Markable = false, Color = Color.DarkGreen }
                };
                // group with right clipping plane
                var clipgroup = new ILGroup() {
                    Clipping = new ILClipParams() {
                        Plane0 = new Vector4(1, 0, 0, 0)
                    },
                    Children = {
                            // a camera holding the (right) clipped gear
                            new ILCamera() {
                                // shrink viewport to upper top quadrant
                                ScreenRect = new RectangleF(0.5f,0,0.5f,0.5f),
                                // populate interactive changes back to the global scene
                                IsGlobal = true,
                                // adds the gear to the camera
                                Children = { gear },
                                Position = new Vector3(0,0,-15)
                            }
                        }
                };
                // setup the scene
                var gearGroup = scene.Add(new ILGroup {
                    clipgroup, clipgroup // <- second time: group is cloned
                });

                gearGroup.First<ILCamera>().Parent.Clipping = new ILClipParams() {
                    Plane0 = new Vector4(-1, 0, 0, 0)
                };
                // make the left side transparent green
                gearGroup.First<ILTriangles>().Color = Color.FromArgb(100, Color.Green);

                // synchronize both cameras; source: left side
                gearGroup.First<ILCamera>().PropertyChanged += (s, arg) => {
                    gearGroup.Find<ILCamera>().ElementAt(1).CopyFrom(s as ILCamera, false);
                };
                #endregion

                #region left bottom plot
                // start value
                int nrBalls = 10; bool addBalls = true;
                var balls = new ILPoints("balls") {
                    Positions = ILMath.tosingle(ILMath.randn(3, nrBalls)),
                    Colors = ILMath.tosingle(ILMath.rand(3, nrBalls)),
                    Color = null,
                    Markable = false
                };
                var leftBottomCam = scene.Add(new ILCamera {
                    ScreenRect = new RectangleF(0, 0.5f, 0.5f, 0.5f),
                    Projection = Projection.Perspective,
                    Children = { balls }
                });
                // funny label
                string harmony = @"\color{red}H\color{blue}a\color{green}r\color{yellow}m\color{magenta}o\color{cyan}n\color{black}y\reset
            ";
                var ballsLabel = scene.Add(new ILLabel(tag: "harmony") {
                    Text = harmony,
                    Fringe = { Color = Color.FromArgb(240, 240, 240) },
                    Position = new Vector3(-0.75f, -0.25f, 0)
                });
                long oldFPS = 1;
                PointF currentMousePos = new PointF();
                // setup the swarm. Start with a few balls, increase number
                // until framerate drops below 60 fps.
                ILArray<float> velocity = ILMath.tosingle(ILMath.randn(3, nrBalls));
                EventHandler<ILRenderEventArgs> updateBallsRenderFrame = (s, arg) => {
                    // transform viewport coords into 3d scene coords
                    Vector3 mousePos = new Vector3(currentMousePos.X * 2 - 1,
                                                    currentMousePos.Y * -2 + 1, 0);
                    // framerate dropped? -> stop adding balls
                    if (panel.Panel.FPS < oldFPS && panel.Panel.FPS < 60) addBalls = false;
                    oldFPS = panel.Panel.FPS;
                    Computation.UpdateBalls(mousePos, balls, velocity, addBalls);
                    // balls buffers have been changed -> must call configure() to publish
                    balls.Configure();
                    // update balls label
                    ballsLabel.Text = harmony + "(" + balls.Positions.DataCount.ToString() + " balls)";
                };

                // saving the mouse position in MouseMove is easier for
                // transforming the coordinates into the viewport
                leftBottomCam.MouseMove += (s, arg) => {
                    // save the mouse position
                    currentMousePos = arg.LocationF;
                };
                panel.Panel.BeginRenderFrame += updateBallsRenderFrame;
                m_cleanUpExample = () => {
                    leftBottomCam.MouseMove -= (s, arg) => {
                        // save the mouse position
                        currentMousePos = arg.LocationF;
                    };
                    panel.Panel.BeginRenderFrame -= updateBallsRenderFrame;
                };
                #endregion

                panel.Panel.Scene = scene;

            } catch (Exception exc) {
                System.Diagnostics.Trace.WriteLine("ILPanel_Load Error:");
                System.Diagnostics.Trace.WriteLine("====================");
                System.Diagnostics.Trace.WriteLine(exc.ToString());
                System.Windows.Forms.MessageBox.Show(exc.ToString());
            }
        }
Exemplo n.º 12
0
        private void SetExampleScene(ILPanel panel)
        {
            ILScene scene = new ILScene();

            try {
                ILLabel.DefaultFont = new System.Drawing.Font("Helvetica", 8);
                //ilPanel1.Driver = RendererTypes.GDI;

                #region upper left plot
                // prepare some data
                ILArray <float> P = 1,
                                x = ILMath.linspace <float>(-2, 2, 40),
                                y = ILMath.linspace <float>(2, -2, 40);

                ILArray <float> F = ILMath.meshgrid(x, y, P);
                // a simple RBF
                ILArray <float> Z = ILMath.exp(-(1.2f * F * F + P * P));
                // surface expects a single matrix
                Z[":;:;2"] = F; Z[":;:;1"] = P;

                // add a plot cube
                var pc = scene.Add(new ILPlotCube {
                    // shrink viewport to upper left quadrant
                    ScreenRect = new RectangleF(0.05f, 0, 0.4f, 0.5f),
                    // 3D rotation
                    TwoDMode = false,
                    Children =
                    {
                        // add surface
                        new ILSurface(Z)
                        {
                            // disable mouse hover marking
                            Fill      = { Markable = false },
                            Wireframe ={ Markable                 = false },
                            // make it shiny
                            UseLighting = true,
                            Children    = { new ILColorbar() }
                        },
                        //ILLinePlot.CreateXPlots(Z["1:10;:;0"], markers: new List<MarkerStyle>() {
                        //    MarkerStyle.None,MarkerStyle.None,MarkerStyle.None,MarkerStyle.None,MarkerStyle.Circle, MarkerStyle.Cross, MarkerStyle.Plus, MarkerStyle.TriangleDown }),
                        //new ILLegend("hi","n","ku","zs","le", "blalblalblalblalb\\color{red} hier gehts rot")
                    },
                    Rotation = Matrix4.Rotation(new Vector3(1.1f, -0.4f, -0.69f), 1.3f)
                });

                #endregion

                #region top right plot
                // create a gear shape
                var gear = new ILGear(toothCount: 30, inR: 0.5f, outR: 0.9f)
                {
                    Fill = { Markable = false, Color = Color.DarkGreen }
                };
                // group with right clipping plane
                var clipgroup = new ILGroup()
                {
                    Clipping = new ILClipParams()
                    {
                        Plane0 = new Vector4(1, 0, 0, 0)
                    },
                    Children =
                    {
                        // a camera holding the (right) clipped gear
                        new ILCamera()
                        {
                            // shrink viewport to upper top quadrant
                            ScreenRect = new RectangleF(0.5f, 0, 0.5f, 0.5f),
                            // populate interactive changes back to the global scene
                            IsGlobal = true,
                            // adds the gear to the camera
                            Children ={ gear                },
                            Position = new Vector3(0, 0, -15)
                        }
                    }
                };
                // setup the scene
                var gearGroup = scene.Add(new ILGroup {
                    clipgroup, clipgroup // <- second time: group is cloned
                });

                gearGroup.First <ILCamera>().Parent.Clipping = new ILClipParams()
                {
                    Plane0 = new Vector4(-1, 0, 0, 0)
                };
                // make the left side transparent green
                gearGroup.First <ILTriangles>().Color = Color.FromArgb(100, Color.Green);

                // synchronize both cameras; source: left side
                gearGroup.First <ILCamera>().PropertyChanged += (s, arg) => {
                    gearGroup.Find <ILCamera>().ElementAt(1).CopyFrom(s as ILCamera, false);
                };
                #endregion

                #region left bottom plot
                // start value
                int nrBalls = 10; bool addBalls = true;
                var balls = new ILPoints("balls")
                {
                    Positions = ILMath.tosingle(ILMath.randn(3, nrBalls)),
                    Colors    = ILMath.tosingle(ILMath.rand(3, nrBalls)),
                    Color     = null,
                    Markable  = false
                };
                var leftBottomCam = scene.Add(new ILCamera {
                    ScreenRect = new RectangleF(0, 0.5f, 0.5f, 0.5f),
                    Projection = Projection.Perspective,
                    Children   = { balls }
                });
                // funny label
                string harmony    = @"\color{red}H\color{blue}a\color{green}r\color{yellow}m\color{magenta}o\color{cyan}n\color{black}y\reset
";
                var    ballsLabel = scene.Add(new ILLabel(tag: "harmony")
                {
                    Text     = harmony,
                    Fringe   = { Color = Color.FromArgb(240, 240, 240) },
                    Position = new Vector3(-0.75f, -0.25f, 0)
                });
                long   oldFPS          = 1;
                PointF currentMousePos = new PointF();
                // setup the swarm. Start with a few balls, increase number
                // until framerate drops below 60 fps.
                ILArray <float> velocity = ILMath.tosingle(ILMath.randn(3, nrBalls));
                EventHandler <ILRenderEventArgs> updateBallsRenderFrame = (s, arg) => {
                    // transform viewport coords into 3d scene coords
                    Vector3 mousePos = new Vector3(currentMousePos.X * 2 - 1,
                                                   currentMousePos.Y * -2 + 1, 0);
                    // framerate dropped? -> stop adding balls
                    if (panel.FPS < oldFPS && panel.FPS < 60)
                    {
                        addBalls = false;
                    }
                    oldFPS = panel.FPS;
                    Computation.UpdateBalls(mousePos, balls, velocity, addBalls);
                    // balls buffers have been changed -> must call configure() to publish
                    balls.Configure();
                    // update balls label
                    ballsLabel.Text = harmony + "(" + balls.Positions.DataCount.ToString() + " balls)";
                };

                // saving the mouse position in MouseMove is easier for
                // transforming the coordinates into the viewport
                leftBottomCam.MouseMove += (s, arg) => {
                    // save the mouse position
                    currentMousePos = arg.LocationF;
                };
                panel.BeginRenderFrame += updateBallsRenderFrame;
                m_cleanUpExample        = () => {
                    leftBottomCam.MouseMove -= (s, arg) => {
                        // save the mouse position
                        currentMousePos = arg.LocationF;
                    };
                    panel.BeginRenderFrame -= updateBallsRenderFrame;
                };
                #endregion

                panel.Scene = scene;
            } catch (Exception exc) {
                System.Diagnostics.Trace.WriteLine("ILPanel_Load Error:");
                System.Diagnostics.Trace.WriteLine("====================");
                System.Diagnostics.Trace.WriteLine(exc.ToString());
                MessageBox.Show(exc.ToString());
            }
        }
Exemplo n.º 13
0
        public void SetSurface()
        {
            points = new ILPoints();
            points.Size = 10;
            points.Color = null;

            scene = new ILScene();
            plotCube = new ILPlotCube(twoDMode: false);

            surface = new ILSurface(
                            (x, y) =>
                            {
                                return Calculate(new double[] { x, y });
                            },
                            xmin: Min, xmax: Max, xlen: 100,
                            ymin: YMin, ymax: YMax, ylen: 100,
                            colormap: Colormaps.ILNumerics
                        );

            plotCube.Add(surface);
        }
Exemplo n.º 14
0
 public ILPointsWrapper(ILPoints source, ILPanelEditor editor, string path, string name = null, string label = null)
     : base(source, editor, path, BuildName(name, editor.Panel, source, "Points"), label)
 {
     this.source = source;
 }
Exemplo n.º 15
0
        private void PlotByNodesPoints(
            DenseMatrix dmListOfData,
            Dictionary <string, object> properties,
            string description = "")
        {
            strDataDescription = description;
            ThreadSafeOperations.SetText(lblDescription, strDataDescription, false);

            defaultProperties  = properties;
            strOutputDirectory = (string)defaultProperties["DefaultDataFilesLocation"];
            if (!ServiceTools.CheckIfDirectoryExists(strOutputDirectory))
            {
                strOutputDirectory = "";
            }

            dmDataList = dmListOfData.Copy();
            double dataMaxVal = dmDataList.Column(3).Max();
            double dataMinVal = dmDataList.Column(3).Min();

            ILScene scene = new ILScene();

            currSurfPlotCube          = new ILPlotCube();
            currSurfPlotCube.TwoDMode = false;

            ILArray <float> A =
                ILMath.tosingle((ILArray <double>)(dmDataList.SubMatrix(0, dmDataList.RowCount, 0, 3).ToArray()));

            ILArray <float> colors = ILMath.zeros <float>(4, dmDataList.RowCount);

            ColorScheme newCS = new ColorScheme("");


            double[] dvRvalues = DenseVector.Create(dmDataList.RowCount, (r) =>
            {
                Bgr currColor = newCS.GetColorByValueAndRange(dmDataList[r, 3], dataMinVal, dataMaxVal);
                return(currColor.Red / 255.0d);
            }).ToArray();
            double[] dvGvalues = DenseVector.Create(dmDataList.RowCount, (r) =>
            {
                Bgr currColor = newCS.GetColorByValueAndRange(dmDataList[r, 3], dataMinVal, dataMaxVal);
                return(currColor.Green / 255.0d);
            }).ToArray();
            double[] dvBvalues = DenseVector.Create(dmDataList.RowCount, (r) =>
            {
                Bgr currColor = newCS.GetColorByValueAndRange(dmDataList[r, 3], dataMinVal, dataMaxVal);
                return(currColor.Blue / 255.0d);
            }).ToArray();
            colors["0;:"] = ILMath.tosingle((ILArray <double>)dvRvalues);
            colors["1;:"] = ILMath.tosingle((ILArray <double>)dvGvalues);
            colors["2;:"] = ILMath.tosingle((ILArray <double>)dvBvalues);
            colors["3;:"] = 0.5f;

            ILPoints pts = new ILPoints
            {
                Positions = A,
                Colors    = colors,
            };

            pts.Color = null;
            currSurfPlotCube.Add(pts);

            currSurfPlotCube.Projection = Projection.Orthographic;
            currSurfPlotCube.Rotation   = Matrix4.Rotation(new Vector3(1, 1, 1), 0.5f);
            currSurfPlotCube.Plots.Reset();
            scene.Add(currSurfPlotCube);

            ilPanel1.Scene = scene;
        }
Exemplo n.º 16
0
            public static void UpdateBalls(Vector3 center, ILPoints balls, ILOutArray<float> velocity, bool addBalls)
            {
                if (!balls.IsDisposed) { // <- this obviously is not threadsafe!! TODO
                    using (ILScope.Enter()) {
                        ILArray<float> position = balls.Positions.Storage;
                        ILArray<float> colors = balls.Colors.Storage;
                        if (addBalls) {
                            // increase number of balls (this is very inefficient!)
                            position[full, r(end + 1, end + 10)] = tosingle(randn(3, 10));
                            colors[full, r(end + 1, end + 10)] = tosingle(rand(4, 10));
                            velocity[full, r(end + 1, end + 10)] = tosingle(randn(3, 10));
                        }
                        ILArray<float> d = array<float>(center.X, center.Y, center.Z);
                        ILArray<float> off = position * 0.1f;
                        ILArray<float> dist = sqrt(sum(position * position));
                        ILArray<int> where = find(dist < 0.2f);
                        velocity[full, where] = velocity[full, where]
                                                    + tosingle(rand(3, where.Length)) * 0.2f;
                        dist.a = position - d;
                        off.a = off + dist * -0.02f / sqrt(sum(dist * dist));
                        velocity.a = velocity * 0.95f - off;
                        balls.Positions.Update(position + velocity * 0.12f);
                        ILArray<float> Zs = abs(position[end, full]);

                        colors[end, full] = Zs / maxall(Zs) * 0.7f + 0.3f;
                        balls.Colors.Update(colors);
                    }
                }
            }
Exemplo n.º 17
0
        public static void DrawPoints(this ILPanel panel, List<Element> population, float min, float max, float step)
        {
            ILScene scene = null;

            // setup the scene + plot cube + surface

            ILArray<float> ilar = population.Array3D();

            ILPoints ilpoints = new ILPoints { Positions = ilar, Color = Color.Black };

            scene = panel.Scene;
            scene.First<ILPlotCube>().Add(ilpoints);

            //scene.First<ILPlotCube>().Rotation = Matrix4.Rotation(new Vector3(2, 0.55, 0.64), Math.PI / 2);

            panel.Scene = scene;
            panel.Refresh();
        }
Exemplo n.º 18
0
        /// <summary>
        /// Creates an ILPoints-object at the specified coordinates and with a handler to set the
        ///  specified label for the coordinates invisible.
        /// </summary>
        /// <param name="x">First coordinate of the point. Must be a one-dimensional array with one element and must not be null!</param>
        /// <param name="y">Second coordinate of the point. Must be a one-dimensional array with one element and must not be null!</param>
        /// <param name="z">Third coordinate of the point. Must be a one-dimensional array with one element and must not be null!</param>
        /// <param name="l">Label that will show the coordinates of the point. Must not be null.</param>
        /// <returns>An interactive point that displays its coordinates.</returns>
        private ILPoints createPoint(ILRetArray<float> x, ILRetArray<float> y, ILRetArray<float> z, Label l)
        {
            if (x == null)
                throw new ArgumentNullException("Parameter x must not be null!");
            if (y == null)
                throw new ArgumentNullException("Parameter y must not be null!");
            if (z == null)
                throw new ArgumentNullException("Parameter z must not be null!");
            if (l == null)
                throw new ArgumentNullException("Parameter l must not be null!");
            if (x.Size.NumberOfElements != 1)
                throw new Exception("Parameter x does not contain exactly one element!");
            if (y.Size.NumberOfElements != 1)
                throw new Exception("Parameter y does not contain exactly one element!");
            if (z.Size.NumberOfElements != 1)
                throw new Exception("Parameter z does not contain exactly one element!");

            ILArray<float> coors = ILMath.zeros<float>(0);

            coors[0, 0] = x;
            coors[1, 0] = y;
            coors[2, 0] = z;

            ILPoints point = new ILPoints
            {
                Positions = coors,
                Color = Color.Black
            };

            point.MouseLeave += (s, a) =>
            {
                l.Visible = false;
            };

            return point;
        }