Nez.Portable/Physics/Shapes/Polygon.cs
/// <summary>
/// finds the center of the Polygon. Note that this will be accurate for regular polygons. Irregular polygons have no center.
/// </summary>
/// <returns>The polygon center.</returns>
/// <param name="points">Points.</param>
finds the center of the Polygon. Note that this will be accurate for regular polygons. Irregular polygons have no center.
finds the center of the Polygon . Note that this will be accurate for regular polygons . Irregular polygons have no center .
public static Vector2 findPolygonCenter(Vector2[] points)
        {
            float x = 0, y = 0;
            for (var i = 0; i < points.Length; i++)
            {
                x += points[i].X;
                y += points[i].Y;
            }
            return new Vector2(x / points.Length, y / points.Length);
        }
public static Vector2 findPolygonCenter ( Vector2 [ ] points ) { float x = 0 , y = 0 ; for ( var i = 0 ; i < points . Length ; i ++ ) { x += points [ i ] . X ; y += points [ i ] . Y ; } return new Vector2 ( x / points . Length , y / points . Length ) ; }
finds the center of the Polygon.
finds the center of the Polygon .
The polygon center.
The polygon center .
points
Vector2[]
None