Dav*_*fau 5 3d matlab plot matlab-figure
我正在尝试在 Matlab 中生成一组 3D 对象的视图,以便角度发生变化但对象大小保持不变。由于 Matlab 尝试将整个轴放入视图中,因此对象会缩小或增大,具体取决于是从正面还是从某个角度查看绘图。举个例子:
[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
Run Code Online (Sandbox Code Playgroud)
如何才能使球体无论从哪个角度观看都显示相同的大小?
该axis函数是您的朋友。尝试添加
axis vis3d
Run Code Online (Sandbox Code Playgroud)
在帮助中,“轴 VIS3D 冻结纵横比属性以启用 3D 对象的旋转并覆盖拉伸填充”。如果您有兴趣,同样可以通过以下方式完成
ax = gca;
props = {'CameraViewAngle','DataAspectRatio','PlotBoxAspectRatio'};
set(ax,props,get(ax,props));
Run Code Online (Sandbox Code Playgroud)