How do I add shadings when overlapping polygons?
조회 수: 2 (최근 30일)
이전 댓글 표시
figure();
x = [0 1 1 0];
y = [0 0 1 1];
xy = polyshape(x,y); hold on;
xx = [0 0.5 0.5 0];
yy = [0 0 0.5 0.5];
xxyy = polyshape(xx,yy);
xxx = [0.25 0.75 0.75 0.25];
yyy = [0.25 0.25 0.75 0.75];
xxxyyy = polyshape(xxx,yyy);
L = linspace(0,2.*pi,100);
kx = 0.2*cos(L)'+0.7;
ky = 0.2*sin(L)'+0.7;
kreis = polyshape(kx(1:end-1),ky(1:end-1));
plot(xy)
plot(xxyy)
plot(xxxyyy)
plot(kreis)
axis equal;
I have a variety of polygons. Now I need to know how to either shade the overlapping areas according to a grayscale (the the more polygons overlapping the darker the intersecting area) or to otherwise gain information about the overlapping areas. Thanks
댓글 수: 0
채택된 답변
Matt J
2019년 1월 4일
편집: Matt J
2019년 1월 4일
Why not just create a grayscale image?
t= linspace(0,1,300);
[X,Y]=meshgrid(t);
sz=size(X);
X=X(:);Y=Y(:);
I=xy.isinterior(X,Y)+xxyy.isinterior(X,Y)+xxxyyy.isinterior(X,Y)+...
kreis.isinterior(X,Y);
imagesc((reshape(I,sz)),'XData',t,'YData',t);
colormap(gray)
axis image
set(gca,'YDir','normal');
추가 답변 (1개)
Steven Lord
2019년 1월 4일
To determine if two polyshape objects overlap, use the overlaps function (introduced in release R2018a) or the intersect function (release R2017b, when polyshape was introduced.)
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Elementary Polygons에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!