MATLAB: Area of intersection between a circle and polygon

area of intersectionMATLAB and Simulink Student Suitepolygon and circle

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.

Best Answer

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
Related Question