Combining different mesh granularities

1 次查看(过去 30 天)
This code
figure;
[x, y, z] = sphere(20);
surf(x, y, z, 'edgecolor', 'None'); hold on;
surf(x, y, z, 'facecolor', 'None');
produces the plot
Instead, if I use a different granularity for the faces and the edges:
figure;
[x, y, z] = sphere(100);
[x1, y1, z1] = sphere;
s1 = surf(x, y, z, 'edgecolor', 'None'); hold on;
s2 = surf(x1, y1, z1, 'facecolor', 'None');
the edges are not complete:
Does s1 interfere with s2 and how to fix the problem?

回答(1 个)

John D'Errico
John D'Errico 2017-10-24
This is more a question of understanding graphics. Of understanding what you are doing.
You need to consider that your monitor has limited resolution. It can only display so much information.
You created a pair of polyhedra. NO spheres were created. Only approximations to a sphere. Had they both been true spheres of the same radius, you could not see the difference at all.
Since one of the objects is a coarser approximation, but both with planar faces, it will be almost entirely inside the finer one. Since both are opaque, you will essentially NEVER see the coarser one at all, except where a vertex of the coarse polyhedron happens to stick out. When that happens, there will be some confusion.
t1 = linspace(0,2*pi,5);
t2 = linspace(0,2*pi,12);
r = 1;
plot(r*cos(t1),r*sin(t1),'b-',r*cos(t2),r*sin(t2),'r-')
axis equal
axis square
Where the blue circular approximation sticks out through the red one, there will clearly be confusion. But otherwise, you would never see the coarse one at all.
One solution is to use transparency. Hint, try setting 'facealpha',0.75.

类别

Help CenterFile Exchange 中查找有关 Surface and Mesh Plots 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by