CPolygon:CalcCenter


The CalcCenter method calculates the center of mass of the CPolygon.

Syntax

x, y = CPolygon:CalcCenter()

where

    x, y are the coordinates of the center of mass.

Example

The following script creates a CPolygon from 2 arrays and calculates its center of mass coordinates:

A = NewPolygon( {4,5,6,7}, {1,2,-3,5} )

-- create CPolygon A

Printf("Center = %lg,%lg", A:CalcCenter() )

-- result: CalcCenter = 5.5,1.25

Related Topics

CalcRect

CPolygon class