public IPoint get_TrueCentroid(IPolyline pLine)
{
IPoint pTrueCentroid = new PointClass();
double pTC_X = 0;
double pTC_Y = 0;
ISegmentCollection pSegs = (ISegmentCollection)pLine;
for (int k = 0; k <= (pSegs.SegmentCount - 1); k++)
{
ISegment seg = pSegs.get_Segment(k);
double length = seg.Length / 2;
IPoint pFP = seg.FromPoint;
IPoint pTP = seg.ToPoint;
pTC_X = ((pFP.X + pTP.X) * length) + pTC_X;
pTC_Y = ((pFP.Y + pTP.Y) * length) + pTC_Y;
}
pTrueCentroid.X = pTC_X / pLine.Length;
pTrueCentroid.Y = pTC_Y / pLine.Length;
return pTrueCentroid;