Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ILNumerics ILSurface Adjust Z values

Tags:

ilnumerics

Is there a way to manipulate the range of Z values for a Surface plot in a way that can preserve the original values so I can create a range slider with a min and max values from the GetLimits() method and then update the data array Z values so I can set new limits but move the slides back and forth to adjust the min/max Z value and see the plot adjust as I do it?

Given this code

            ILArray<float> tempArray = ILMath.tosingle(myDoubleArray);

            dataArray.a = tempArray;

            var plotCube = ilPanel1.Scene.First<ILPlotCube>();
            var surface =  plotCube.First<ILFastSurface>();

            surface.Update(Z: dataArray, colormap: new ILColormap(ILColormaps.ILNumerics));
            ilPanel1.Refresh();

The MinValue and MaxValue controls are initialized like this.

            float maxZ, minZ;
            dataArray.GetLimits(out minZ, out maxZ);
            var zRange = maxZ - minZ;

            MinValue.Maximum = (decimal)maxZ;
            MinValue.Minimum = (decimal)minZ;
            MinValue.Value = (decimal)minZ;

            MaxValue.Maximum = (decimal)maxZ;
            MaxValue.Minimum = (decimal)minZ;
            MaxValue.Value = (decimal)maxZ;

I want to be able to manipulate the Z values in the array like this

        dataArray[dataArray < (float)MinValue.Value] = (float)MinValue.Value;
        dataArray[dataArray > (float)MaxValue.Value] = (float)MaxValue.Value;

        var plotCube = ilPanel1.Scene.First<ILPlotCube>();
        var surface = plotCube.First<ILFastSurface>();

        surface.Update(Z: dataArray, colormap: new ILColormap(ILColormaps.ILNumerics));
        ilPanel1.Refresh();

The issue is that dataArray is being changed with new min/max values. How can I restore dataArray if you want to change back to a larger min/max? Do I just clone dataArray and use that to change the plot? Or is there a feature of ILArray that tracks changes and can restore the array?

like image 318
Jeff Davis Avatar asked Mar 04 '26 06:03

Jeff Davis


1 Answers

The solution to this problem is to use a temporary array and clone the original array and then normalize the temporary array and update the surface with it.

        float min = surface.GetRangeMinValue(AxisNames.CAxis) + minOffs;
        float max = surface.GetRangeMaxValue(AxisNames.CAxis) + maxOffs;

         ILArray<float> tempArray = _dataArray.C;
        tempArray[tempArray < min] = min;
        tempArray[tempArray > max] = max;

        surface.Update(Z: tempArray);

_dataArray is a static property loaded once with the original data. Any updates are done with the code above

like image 164
Jeff Davis Avatar answered Mar 08 '26 22:03

Jeff Davis



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!