area_poly2.c

Go to the documentation of this file.
00001 #include "gis.h"
00002 
00013 double G_planimetric_polygon_area(double *x,double *y,int n)
00014 {
00015     double x1,y1,x2,y2;
00016     double area;
00017 
00018     x2 = x[n-1];
00019     y2 = y[n-1];
00020 
00021     area = 0;
00022     while (--n >= 0)
00023     {
00024         x1 = x2;
00025         y1 = y2;
00026 
00027         x2 = *x++;
00028         y2 = *y++;
00029 
00030         area += (y2+y1)*(x2-x1);
00031     }
00032 
00033     if((area /= 2.0) < 0.0)
00034         area = -area;
00035     
00036     return area;
00037 }

Generated on Sat Jul 22 22:06:14 2006 for GRASS by  doxygen 1.4.7