Mercurial > hg > camir-aes2014
comparison 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 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:e9a9cd732c1e |
---|---|
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); |