필터 지우기
필터 지우기

area of intersection between a circle and polygon

조회 수: 17 (최근 30일)
Ananya Malik
Ananya Malik 2018년 9월 3일
댓글: Adam Fleetwood 2020년 12월 6일
x = 0;y = 0; r = 0.5;
th = 0:pi/50:2*pi;
xunit = r * cos(th) + x;
yunit = r * sin(th) + y;
h = plot(xunit, yunit);
poly1 = polyshape([0 0 1 1],[1 0 0 1]);
plot(poly1)
I want to find the area of intersection (in units) between a circle and polygon as given above. Any help would be greatly appreciated. TIA.

채택된 답변

Akira Agata
Akira Agata 2018년 9월 3일
One possible way is generating intersection by intersect function, and calculate it's area by area function. The following is an example.
x = 0; y = 0; r = 0.5;
th = 0:pi/50:2*pi;
xunit = r * cos(th) + x;
yunit = r * sin(th) + y;
poly0 = polyshape(xunit(1:end-1),yunit(1:end-1));
poly1 = polyshape([0 0 1 1],[1 0 0 1]);
poly2 = intersect(poly0,poly1);
area(poly2)
The result is:
>> area(poly2)
ans =
0.1962
  댓글 수: 4
Ananya Malik
Ananya Malik 2018년 9월 3일
Thank you sir.
Adam Fleetwood
Adam Fleetwood 2020년 12월 6일
I have tried using something similar for a project, but am getting an error that states, "unable to use a value of type polyshape as an index'. I tried using this exact code shown above, and still got that error. Any idea why?

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

추가 답변 (0개)

카테고리

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