Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to keep shape in ILCube

I want to plot some 3d surfaces with ILNumerics. I noticed that ILCube does not keep the shape of surface if I rotate it and it is because it tries to fit the cube in the ILPanel. If I use ILCamera, however, it will keep the shape but there is no cube around it. Here is an example,

private void ilPanel1_Load(object sender, EventArgs e)
{
    var scene = new ILScene();
    ILArray<float> A = ILSpecialData.torus(0.75f, 0.25f);
    var sf = new ILSurface(A);
    var pc = new ILPlotCube();
    pc.TwoDMode = false;
    scene.Add(pc);
    pc.Add(sf);
    sf.Colormap = Colormaps.Jet;
    var cb = new ILColorbar();
    cb.Location = new PointF(1, .1f);
    sf.Children.Add(cb);
    ilPanel1.Scene = scene;
}

and the result is

enter image description here

and for ILCamera

private void ilPanel1_Load(object sender, EventArgs e)
{
    var scene = new ILScene();
    ILArray<float> A = ILSpecialData.torus(0.75f, 0.25f);
    var sf = new ILSurface(A);
    var cam = scene.Camera;
    cam.Add(sf);
    sf.Colormap = Colormaps.Jet;
    var cb = new ILColorbar();
    cb.Location = new PointF(1, .1f);
    sf.Children.Add(cb);
    ilPanel1.Scene = scene;
}

and the result is

enter image description here

Is there any way to make the ILCube to keep the shape of the surface? Or add a cube around the surface to the ILCamera? Thanks.

like image 915
Ehsan Avatar asked Aug 30 '13 04:08

Ehsan


People also ask

What makes a shape a cube?

In Maths or in Geometry, a Cube is a solid three-dimensional figure, which has 6 square faces, 8 vertices and 12 edges. It is also said to be a regular hexahedron.


1 Answers

Plot cubes currently do not support equal axis aspect ratios. But it is fairly simple to add this yourself.

For your example, the content of the plot cube (torus) is stretched along the Z axis, because the extend of the torus along Z is smaller than in X or Y direction. Hence, the plot cube chooses to stretch the content to give better details.

In order to show the torus without distortion, make sure the axis range of the plot cube equals in all directions:

pc.Limits.Set(new Vector3(-1,-1,-1), new Vector3(1,1,1));

See an interactive example here: http://ilnumerics.net/ilcc.php?ilc=i63fb4c

ILNumerics plot cube without distortion

Drawback: you will have to adjust the Limits setting everytime the content of the plot cube is modified (ie. data is added / removed / altered).

like image 176
Haymo Kutschbach Avatar answered Oct 03 '22 17:10

Haymo Kutschbach