MATLAB隐藏线删除的限制?

MATLAB隐藏线删除的限制?,matlab,matlab-figure,Matlab,Matlab Figure,我在Mathwork的网站上问过这个问题,所以如果不允许交叉发布,请告诉我,我会删除这个 我试图在MATLAB中同时渲染小对象和大对象。我正在使用“摄影机”命令限制我的视野,以便我可以同时看到这两个区域。但是,当我这样做时,隐藏线移除在小对象上失败。我本以为,对于浮点数来说,隐藏线移除应该是在机器精度下完成的,但看起来不是这样。这是我的图形卡的功能还是我可以解决这个问题? 下面的代码是我能想到的最小示例。绘制在具有默认限制的轴上时,隐藏线移除效果良好(左侧),当轴设置为较大范围(与对象相比)时,

我在Mathwork的网站上问过这个问题,所以如果不允许交叉发布,请告诉我,我会删除这个

我试图在MATLAB中同时渲染小对象和大对象。我正在使用“摄影机”命令限制我的视野,以便我可以同时看到这两个区域。但是,当我这样做时,隐藏线移除在小对象上失败。我本以为,对于浮点数来说,隐藏线移除应该是在机器精度下完成的,但看起来不是这样。这是我的图形卡的功能还是我可以解决这个问题? 下面的代码是我能想到的最小示例。绘制在具有默认限制的轴上时,隐藏线移除效果良好(左侧),当轴设置为较大范围(与对象相比)时,线移除失败(中间)。当我使轴消失时,一切又恢复正常(对)。

对于本例,我可以只隐藏轴,输出看起来是正确的。但对于我真正想做的,那不是一个选择。有没有什么建议或者有人能给我指出一个场景中最小和最大对象之间的适当界限,以便正确渲染? 下面是生成上述球体的代码。提前谢谢

由MATLAB 2018A生成的图像

clearvars
F1 = figure(1);
clf
set(F1,'color',[1 1 1],'Renderer','opengl'); % have to enable this to clip surfaces behind the camera


for step = [2 1 3] % out of order because the axis in case 2 is trying to hide the first plot

subplot(1,3,step)
view(gca,3);
camproj(gca,'Perspective'); % have to enable this to clip surfaces behind the camera

[Xs,Ys,Zs] = sphere(20);
r = 30e-6;
surf(gca,Xs*r,Ys*r,Zs*r);
axis(gca,'equal');

 % three different behaviors, pick a number 1, 2, or 3
switch step
    case 1 % this plots the sphere correctly
    %axis([-2 2 -2 2 -2 2]);
    %axis off

    case 2 % this messes up the hidden line removal
    axis([-2 2 -2 2 -2 2]);
    %axis off   

    case 3 % removing the axis walls fixes things again
    axis([-2 2 -2 2 -2 2]);
    axis off
end

% put viewpoint on unit sphere
camera_pos = get(gca,'CameraPosition');
mag_camera_pos = sqrt(sum(camera_pos.^2));
camera_pos = camera_pos / mag_camera_pos; 
set(gca,'CameraPosition',camera_pos);

final_angle = 2.5*atand(r/1);
set(gca,'CameraViewAngle',final_angle);
end

drawnow