```csharp
int numVertices = polyline.NumberOfVertices;
double area = 0;
double cx = 0;
double cy = 0;
for (int i = 0; i < numVertices; i++)
{
Point2d p1 = polyline.GetPoint2dAt(i);
Point2d p2 = polyline.GetPoint2dAt((i + 1) % numVertices);
double temp = p1.X * p2.Y - p2.X * p1.Y;
area += temp;
cx += (p1.X + p2.X) * temp;
cy += (p1.Y + p2.Y) * temp;
}
area *= 0.5;
cx /= (6 * area);
cy /= (6 * area);
return new Point3d(cx, cy, 0);
`