System.Drawing.GeomUtilities.PolygonArea C# (CSharp) Method

PolygonArea() static private method

static private PolygonArea ( PointF points ) : double
points PointF
return double
        internal static double PolygonArea(PointF[] points)
        {
            var first = points[0];
            var last = points[points.Length -1];
            // make sure we have a closed path
            if (last != first)
                last = first;

            double area = 0;

            for (int p = 1; p < points.Length; p++)
            {
                var next = points[p];
                area += last.X * next.Y - next.X * last.Y;
                last = next;
            }
            area += last.X * first.Y - first.X * last.Y;

            return area / 2;
        }