overlapping polygons translation to non overlapping polygons

조회 수: 2 (최근 30일)
jahanzaib ahmad
jahanzaib ahmad 2018년 11월 29일
댓글: jahanzaib ahmad 2018년 12월 1일
how can i translate the overlapping polygos to new location so that there is no overlap.
A=[];
N = 20;
for i=1:N
X = randn(N,2);
R = sqrt(rand(N,1));
X = R .* X ./ sqrt(sum(X.^2,2));
X=.05.*X;
XX=X(:,1);
XY=X(:,2);
XX=XX+rand;
XY=XY+rand;
K=convhull(XX,XY);
polyin=polyshape(XX(K),XY(K));
polyarray=regions(polyin);
AB=[XX(K),XY(K)];
A=[A; AB];
plot(XX(K),XY(K));
hold on
end
Capture.PNG

채택된 답변

jahanzaib ahmad
jahanzaib ahmad 2018년 12월 1일
c(i)=polyin;
AB=[XX(K),XY(K)];
A{i} = AB;
TF = overlaps(c);
end
[R, C] = find(TF);
A(R(~(R==C))) = [];
for i = A
plot(i{:}(:,1), i{:}(:,2))
hold on;
end
  댓글 수: 1
jahanzaib ahmad
jahanzaib ahmad 2018년 12월 1일
can u guide me how to maintain minimum disatnce between them ?like 0.1Capture.PNG

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Steven Lord
Steven Lord 2018년 11월 29일
Use area and intersect (possibly with polybuffer) as shown in this post on Loren Shure's blog to identify overlapping polygons. Alternately if you're using release R2018a, use the overlaps function introduced in that release. [The blog post was written before R2018a was released and so couldn't use overlaps.]
When you've identified polygons that overlap, translate the corresponding polyshape or polyshapes to move it or them to a different location then retest for overlaps.
  댓글 수: 1
jahanzaib ahmad
jahanzaib ahmad 2018년 12월 1일
yes but i have deleted the overlapping one ..coz translating them can take very very long ..coz if the numbers of polygons are more .translation will be never ending loop .

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Elementary Polygons에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by