From: Edwin on 4 Aug 2010 06:49 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
From: bcomisky on 4 Aug 2010 10:57 On Aug 4, 6:49 am, "Edwin " <ones...(a)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
From: Edwin on 5 Aug 2010 05:35 Thanks a lot Bill, that solved the problem. Regards
|
Pages: 1 Prev: Problem using the 'lecroy_basic_driver'! Next: SimBiology |