Daniel@0: function a = polygon_area(x,y) Daniel@0: % AREA Area of a planar polygon. Daniel@0: % AREA(X,Y) Calculates the area of a 2-dimensional Daniel@0: % polygon formed by vertices with coordinate vectors Daniel@0: % X and Y. The result is direction-sensitive: the Daniel@0: % area is positive if the bounding contour is counter- Daniel@0: % clockwise and negative if it is clockwise. Daniel@0: % Daniel@0: % See also TRAPZ. Daniel@0: Daniel@0: % Copyright (c) 1995 by Kirill K. Pankratov, Daniel@0: % kirill@plume.mit.edu. Daniel@0: % 04/20/94, 05/20/95 Daniel@0: Daniel@0: % Make polygon closed ............. Daniel@0: x = [x(:); x(1)]; Daniel@0: y = [y(:); y(1)]; Daniel@0: Daniel@0: % Calculate contour integral Int -y*dx (same as Int x*dy). Daniel@0: lx = length(x); Daniel@0: a = -(x(2:lx)-x(1:lx-1))'*(y(1:lx-1)+y(2:lx))/2; Daniel@0: a = abs(a);