comparison 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
comparison
equal deleted inserted replaced
-1:000000000000 0:cc4b1211e677
1 function a = polygon_area(x,y)
2 % AREA Area of a planar polygon.
3 % AREA(X,Y) Calculates the area of a 2-dimensional
4 % polygon formed by vertices with coordinate vectors
5 % X and Y. The result is direction-sensitive: the
6 % area is positive if the bounding contour is counter-
7 % clockwise and negative if it is clockwise.
8 %
9 % See also TRAPZ.
10
11 % Copyright (c) 1995 by Kirill K. Pankratov,
12 % kirill@plume.mit.edu.
13 % 04/20/94, 05/20/95
14
15 % Make polygon closed .............
16 x = [x(:); x(1)];
17 y = [y(:); y(1)];
18
19 % Calculate contour integral Int -y*dx (same as Int x*dy).
20 lx = length(x);
21 a = -(x(2:lx)-x(1:lx-1))'*(y(1:lx-1)+y(2:lx))/2;
22 a = abs(a);