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

initial commit to HG from Changeset: 646 (e263d8a21543) added further path and more save "camirversion.m"
author Daniel Wolff
date Fri, 19 Aug 2016 13:07:06 +0200
parents
children
rev   line source
Daniel@0 1 function a = polygon_area(x,y)
Daniel@0 2 % AREA Area of a planar polygon.
Daniel@0 3 % AREA(X,Y) Calculates the area of a 2-dimensional
Daniel@0 4 % polygon formed by vertices with coordinate vectors
Daniel@0 5 % X and Y. The result is direction-sensitive: the
Daniel@0 6 % area is positive if the bounding contour is counter-
Daniel@0 7 % clockwise and negative if it is clockwise.
Daniel@0 8 %
Daniel@0 9 % See also TRAPZ.
Daniel@0 10
Daniel@0 11 % Copyright (c) 1995 by Kirill K. Pankratov,
Daniel@0 12 % kirill@plume.mit.edu.
Daniel@0 13 % 04/20/94, 05/20/95
Daniel@0 14
Daniel@0 15 % Make polygon closed .............
Daniel@0 16 x = [x(:); x(1)];
Daniel@0 17 y = [y(:); y(1)];
Daniel@0 18
Daniel@0 19 % Calculate contour integral Int -y*dx (same as Int x*dy).
Daniel@0 20 lx = length(x);
Daniel@0 21 a = -(x(2:lx)-x(1:lx-1))'*(y(1:lx-1)+y(2:lx))/2;
Daniel@0 22 a = abs(a);