Info

此问题已关闭。 请重新打开它进行编辑或回答。

Artefacts in 3D plotting after view rotation

2 次查看(过去 30 天)
jmj
jmj 2017-6-1
关闭: MATLAB Answer Bot 2021-8-20
Hello!
I'm using fill3 to generate ploygons for 3D plotting of areas in layers. Afterwards, I rotat the view into the desired angle. The areas are transparent to generate the imperssion of 3D when multiple layers overlap in the view:
startX = 1;
startY = 1;
startZ = 1;
ai = 2;
bi = 3;
fig = figure(1);
hold on
layerOffset =2;
layerTextOffset = layerOffset + .5;
xMin = min(startX) - layerOffset;
xMax = max(startX +ai) + layerOffset;
yMin = min(startY) - layerOffset;
yMax = max(startY + bi) + layerOffset;
zMin = min(startZ);
zMax = max(startZ);
for z = 1:max(startZ)
fill3( [xMin xMin xMax xMax], [yMin yMax yMax yMin], [z z z z],...
[.6, .6, .6], ...
'FaceAlpha', .1, ...
'FaceLighting', 'gouraud', ...
'EdgeColor', 'none', ...
'EdgeAlpha',.5, ...
'LineStyle', ':', 'LineWidth', 2);
layerText = ['Layer ', num2str(z)];
text( xMax + layerTextOffset, mean([yMin, yMax]),...
z, layerText, ...
'HorizontalAlignment', 'left',...
'FontName', 'Palatino Linotype');
end
for i =1:length(startX)
x1 = startX(i);
x2 = startX(i)+ai(i);
x3 = startX(i)+ai(i);
x4 = startX(i);
y1 = startY(i);
y2 = startY(i);
y3 = startY(i)+bi(i);
y4 = startY(i)+bi(i);
z = startZ(i);
fill3( [x1 x2 x3 x4], [y1 y2 y3 y4], [z z z z],...
'k',...
'FaceAlpha', .7-(z*0.2), ...
'EdgeColor', 'b', ...
'FaceLighting', 'gouraud', ...
'EdgeAlpha',.5, ...
'LineStyle', ':', 'LineWidth', 2);
textOffsetX = 0.2;
textOffsetY = .3;
textContent = ['Area ', num2str(i)];
text(mean([x1, x3]), mean([y2, y3]), z, ...
textContent, ...
'HorizontalAlignment', 'center',...
'FontName', 'Palatino Linotype');
end
az = 22;
el = 54;
view(az, el);
print(fig, 'error.png', '-dpng')
Unfortunatly, the plots have errors after the rotation:
How do I avoid these artefacts?
Thanks for your kind responses, jmj

回答(0 个)

此问题已关闭。

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by