TriangleNet.NewLocation.FindPolyCentroid C# (CSharp) Method

FindPolyCentroid() private method

Returns the centroid of a given polygon
private FindPolyCentroid ( int numpoints, double points, double &centroid ) : void
numpoints int
points double
centroid double Centroid of a given polygon
return void
        private void FindPolyCentroid(int numpoints, double[] points, ref double[] centroid)
        {
            int i;
            //double area = 0.0;//, temp
            centroid[0] = 0.0; centroid[1] = 0.0;

            for (i = 0; i < 2 * numpoints; i = i + 2)
            {

                centroid[0] = centroid[0] + points[i];
                centroid[1] = centroid[1] + points[i + 1];

            }
            centroid[0] = centroid[0] / numpoints;
            centroid[1] = centroid[1] / numpoints;
        }