Constant object size when turning 3-D Matlab graphics

I am trying to create a set of representations of a three-dimensional object in Matlab, so that the angle changes, but the size of the object remains constant. As Matlab tries to fit the entire axis, the subject will decrease or increase depending on whether the plot is viewed at an angle or at an angle. As an example:

[x,y,z] = sphere(50); % coordinates of a sphere surf(x,y,z); % plot the sphere axis image off view(0,0) % at this angle the sphere fills the axes view(-37.5,30) % at this angle the sphere is much smaller 

How can I make it so that the sphere looks the same size no matter what angle it looks?

+4
source share
1 answer

The axis function is your friend here. Try to add

 axis vis3d 

From the help, "the VIS3D axis depends on the properties of the proportions to allow the rotation of three-dimensional objects and redefines the stretch to fill." If you are interested, the same can be done with

 ax = gca; props = {'CameraViewAngle','DataAspectRatio','PlotBoxAspectRatio'}; set(ax,props,get(ax,props)); 
+4
source

Source: https://habr.com/ru/post/1496324/


All Articles