I am trying to generate a set of views of a 3-D object in Matlab such that the angle changes but the object size stays constant. Because Matlab tries to fit the entire axis into view, an object will shrink or grow depending on whether the plot is viewed head-on 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 appears the same size no matter what angle it's viewed at?
The axis
function is your friend here. Try adding
axis vis3d
From the help, "axis VIS3D freezes aspect ratio properties to enable rotation of 3-D objects and overrides stretch-to-fill." If you're interested The same this can be accomplished via
ax = gca;
props = {'CameraViewAngle','DataAspectRatio','PlotBoxAspectRatio'};
set(ax,props,get(ax,props));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With