Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
multiple intersections area

Subject: multiple intersections area

From: Edwin

Date: 4 Aug, 2010 10:49:03

Message: 1 of 3

Hello everyone,
I have an irregular shaped polygon (p2) and a circle.
So I was trying to find the intersection area by using polybol to find the intersections and then polyarea, but that is working when there is just one intersection between the polygon and the circle, so my question:
Anyone could suggest how to find the area when there are multiple intersections? (please see the example below).

p2=[274.920000000000 10.6000000000000;
271.750000000000 10.6000000000000;
271.750000000000 12.8500000000000;
272.350000000000 12.5000000000000;
272.850000000000 12.1300000000000;
273.380000000000 11.6000000000000;
273.720000000000 11.2000000000000;
274.440000000000 11;
274.570000000000 10.8800000000000;
274.920000000000 10.6000000000000]

the circle center is
center=[275.9500 15.3001];

and the radius=4.6208.


Regards

Subject: multiple intersections area

From: bcomisky

Date: 4 Aug, 2010 14:57:01

Message: 2 of 3

On Aug 4, 6:49 am, "Edwin " <ones...@gmail.com> wrote:
> Hello everyone,
> I have an irregular shaped polygon (p2) and a circle.
> So I was trying to find the intersection area by using polybol to find the intersections and then polyarea, but that is working when there is just one intersection between the polygon and the circle, so my question:
> Anyone could suggest how to find the area when there are multiple intersections? (please see the example below).

It looks like polyarea() doesn't work with NaN delimited polygon
vertex vectors or cell arrays.
You can use polysplit() to turn your NaN delimited polygon x/y vectors
into cell arrays, then iterate over the polygons, calling polyarea for
each one, like:

[x, y] = polybool('intersection', p2(:,1), p2(:,2), circle(:,1),
circle(:,2));
[xs, ys] = polysplit(x,y);
areasum = 0;
for n = 1:numel(xs)
    areasum = areasum+polyarea(xs{n}, ys{n});
end

Bill

Subject: multiple intersections area

From: Edwin

Date: 5 Aug, 2010 09:35:08

Message: 3 of 3

Thanks a lot Bill,

that solved the problem.

Regards

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us