Transparent Sphere on a Polygon Plot

3 views (last 30 days)
I want to create a transparent sphere. First I plot a polygon, then I plot a transparent sphere (according to this: https://www.mathworks.com/matlabcentral/answers/59536-how-to-create-a-transparent-sphere), but the first polygon doesn't appear in the transparent sphere. Even though I plot the polygon over sphere, it still doesn't appear. How should I do that? Many thanks. My code is this:
close all;clear all;clc;
pA1=[-2.9,-0.9,0]';
pA2=[-1.2,3.0,0]';
pB1=[1.3,-2.3,0]';
pB2=[-1.2,-3.7,0]';
pC1=[2.5,4.1,0]';
pC2=[3.2,1.0,0]';
patch([pA1(1),pA2(1),pC1(1),pC2(1),pB1(1),pB2(1)],[pA1(2),pA2(2),pC1(2),pC2(2),pB1(2),pB2(2)],0)
grid on; axis equal;hold on;
text(pA1(1),pA1(2),'A1');text(pA2(1),pA2(2),'A2')
text(pB1(1),pB1(2),'B1');text(pB2(1),pB2(2),'B2')
text(pC1(1),pC1(2),'C1');text(pC2(1),pC2(2),'C2')
L1=5.0;L2=4.5;L3=5.0;L4=5.5;L5=5.5;L6=5.7;
[x y z] = sphere(128);x=L1*x;y=L1*y;z=L1*z;
h = surfl(x, y, z);
set(h, 'FaceAlpha', 0.1)
shading interp

Accepted Answer

WalterWhite
WalterWhite on 6 Jan 2021
try using flat shading (shading flat) instead of interpolating colormap shading (shading interp)

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!