From: Edwin on 1 Jul 2010 05:07 hello everyone, I'm having troubles with polyarea, example: if I have two polygons with the exact same coordinates but ordered them in different manner them I get two different answers. The area should be the same no matter what is the order of the polygons vertices. is there a way to solve this?. ---------------------------------------------------------------------------------------------------- p1 = [1 1;1 2;3 2;3 1;1 1]; p2 = [1 1;1 2;3 1;1 1;3 2]; A1 = polyarea(p1(:,1),p1(:,2)) A2 = polyarea(p2(:,1),p2(:,2)) ------------------------------------------------------------------------------------------------------- A1 = 2 A2 = 1 Thanks in advance
From: John D'Errico on 1 Jul 2010 05:45 "Edwin " <onest30(a)gmail.com> wrote in message <i0hlro$gv3$1(a)fred.mathworks.com>... > hello everyone, > I'm having troubles with polyarea, > example: > if I have two polygons with the exact same coordinates but ordered them in different manner them I get two different answers. The area should be the same no matter what is the order of the polygons vertices. > No, that is simply not true. A polygon as matlab defines it is a function of the order of the points. Order is indeed important. In fact, many orderings of the points may even have a polygon that crosses itself. Even if this does not happen, I will claim that if I just give you an arbitrary (non-convex) set of points, then you cannot determine unambiguously without the ordering known what the true polygon is. This is trivially true. And if you cannot unambiguously determine the polygon merely from a list of unordered points, then you cannot determine the area of the polygon that you do not know. Case closed. John
|
Pages: 1 Prev: How to surface-plot a series of points? Next: Replacing a NaN by it nanmean |