function getCentroid(ps: number[][]): number[] { let totalX = 0; let totalY = 0; const len = ps.length; for (let i=0; i