필터 지우기
필터 지우기

Create closed curve from intersection between multiple curves

조회 수: 7 (최근 30일)
Mattia Deriu
Mattia Deriu 2021년 11월 23일
댓글: John D'Errico 2021년 11월 23일
Hi, i wonder if it is possible inside Matlab to create a unique closed curve from the inner intersection between multiple curves. Actually i am creating the intersection manually on CAD by elaborating the vector images output.
What i get from Matlab:
What i'm doing manually (and i would love to implement inside matlab)
Thanks for the support!
Regards,
Mattia

채택된 답변

Dave B
Dave B 2021년 11월 23일
polyshape is pretty good for this, but you need to give it polygons not curves (i.e. define what's inside and what's outside). Nice bonus is that you get a shape, so you can both plot it and get stats like area:
t=linspace(0,2*pi,100)';
t=t(1:end-1);
x=3*cos(t)-2;
y=3*sin(t)-2;
p1 = polyshape([x y]);
p2 = nsidedpoly(100,'Radius',4,'Center',[1 1]); % shortcut for regular polygons
p3 = nsidedpoly(4);
hold on
p1.plot('FaceColor',[.6 .4 .4]) % plot as polyshapeobject.plot...
p2.plot('FaceColor',[.4 .6 .4])
p3.plot('FaceColor',[.4 .4 .6])
intersected_p = p1.intersect(p2).intersect(p3);
plot(intersected_p,'FaceColor','r','LineWidth',2) % ...or plot(polyshape)
intersected_p.area
ans = 1.2280
  댓글 수: 1
John D'Errico
John D'Errico 2021년 11월 23일
Polyshapes are a great tool in MATLAB. Here, I would say they are literally the perfect solution. As good as your initial polygons can finely approximate the original shapes as polygons.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by