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