How to change ILNumerics plot marker type?

282 views Asked by At

I have set of random generated points in 3D Scene, and in runtime I want to change the type of point markers to, for example, triangles, as in the picture:

enter image description here

Is it possible? How can I achieve this? Also I need change color for some points.

Scene initialization code below:

ILArray<float> points = ILMath.tosingle(ILMath.randn(3, 1000));
var scene = new ILScene 
{
    new ILPlotCube(twoDMode: false) 
    {
        new ILPoints 
        {
            Positions = points,
            Color = null,
            Size = 2
        }
    }
};
1

There are 1 answers

0
user492238 On BEST ANSWER

Markers (ILMarker) and 'points' (ILPoints) are very different beasts. Markers are much more flexible configurable, mostly look nicer and are much more expensive to render. They commonly consist out of a border (line shape) and a filled area (triangles shape) and come with a number of predefined looks.

ILPoints on the other hand are designed to be fast and easy. one can easily create millions of points without decreasing the plotting performance. Don't try this with markers! But such points are what they are: filled circles. It's it. No borders, no different shapes.

However, if you want to give it a try - even for the 1000 points in your questions - you can do so. Just use an ILLinePlot instead and configure a marker for it. You may set the line color to Color.Empty to have the markers showing up alone.

new ILLinePlot(points, lineColor: Color.Empty, markerStyle: MarkerStyle.TriangleDown)

In order to get individual colors for individual point markers you would split your markers (points) up into individual set of points. Create an ILLinePlot for each set of points using the scheme described above.

The part of your question dealing with 'dynamic' is also easy: You can change the type of markers as well as any other property at runtime. Here is one simple example which toogles the markers between red triangle markers and white rectangle markers by clicking anywhere on the scene:

ilPanel1.Scene.MouseClick += (_s, _a) => {
    if (_a.DirectionUp) return; 
    var lp = ilPanel1.Scene.First<ILLinePlot>();
    if (lp != null) {
        if (lp.Marker.Style == MarkerStyle.TriangleDown) {
            lp.Marker.Style = MarkerStyle.Rectangle;
            lp.Marker.Fill.Color = Color.White;
        } else {
            lp.Marker.Style = MarkerStyle.TriangleDown;
            lp.Marker.Fill.Color = Color.Red; 
        }
        lp.Configure();
        ilPanel1.Refresh(); 
    }
};