Go to the documentation of this file.00001
00017 #include <grass/gis.h>
00018
00019
00029 double G_planimetric_polygon_area(const double *x, const double *y, int n)
00030 {
00031 double x1, y1, x2, y2;
00032 double area;
00033
00034 x2 = x[n - 1];
00035 y2 = y[n - 1];
00036
00037 area = 0;
00038 while (--n >= 0) {
00039 x1 = x2;
00040 y1 = y2;
00041
00042 x2 = *x++;
00043 y2 = *y++;
00044
00045 area += (y2 + y1) * (x2 - x1);
00046 }
00047
00048 if ((area /= 2.0) < 0.0)
00049 area = -area;
00050
00051 return area;
00052 }