annotate toolboxes/FullBNT-1.0.7/KPMtools/polygon_area.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
rev   line source
wolffd@0 1 function a = polygon_area(x,y)
wolffd@0 2 % AREA Area of a planar polygon.
wolffd@0 3 % AREA(X,Y) Calculates the area of a 2-dimensional
wolffd@0 4 % polygon formed by vertices with coordinate vectors
wolffd@0 5 % X and Y. The result is direction-sensitive: the
wolffd@0 6 % area is positive if the bounding contour is counter-
wolffd@0 7 % clockwise and negative if it is clockwise.
wolffd@0 8 %
wolffd@0 9 % See also TRAPZ.
wolffd@0 10
wolffd@0 11 % Copyright (c) 1995 by Kirill K. Pankratov,
wolffd@0 12 % kirill@plume.mit.edu.
wolffd@0 13 % 04/20/94, 05/20/95
wolffd@0 14
wolffd@0 15 % Make polygon closed .............
wolffd@0 16 x = [x(:); x(1)];
wolffd@0 17 y = [y(:); y(1)];
wolffd@0 18
wolffd@0 19 % Calculate contour integral Int -y*dx (same as Int x*dy).
wolffd@0 20 lx = length(x);
wolffd@0 21 a = -(x(2:lx)-x(1:lx-1))'*(y(1:lx-1)+y(2:lx))/2;
wolffd@0 22 a = abs(a);