У меня есть эти наборы очков:
{X = 3.142888 Y = 101.633827}
{X = 3.142325 Y = 101.633827}
{X = 3.142023 Y = 101.633759}
{X = 3.141899 Y = 101.633652}
{X = 3.141045 Y = 101.633659}
{X = 3.141433 Y = 101.634193}
{X = 3.141291 Y = 101.6343}
{X = 3.141381 Y = 101.634415}
{X = 3.141194 Y = 101.634895}
{X = 3.141618 Y = 101.6349}
{X = 3.142697 Y = 101.634239}
Я пытался использовать метод http://csharphelper.com/blog/2014/07/find-the-centroid-of-a-polygon-in-c/
public PointF FindCentroid()
{
// Add the first point at the end of the array.
int num_points = Points.Length;
PointF[] pts = new PointF[num_points + 1];
Points.CopyTo(pts, 0);
pts[num_points] = Points[0];
// Find the centroid.
float X = 0;
float Y = 0;
float second_factor;
for (int i = 0; i < num_points; i++)
{
second_factor =
pts[i].X * pts[i + 1].Y -
pts[i + 1].X * pts[i].Y;
X += (pts[i].X + pts[i + 1].X) * second_factor;
Y += (pts[i].Y + pts[i + 1].Y) * second_factor;
}
// Divide by 6 times the polygon's area.
float polygon_area = PolygonArea();
X /= (6 * polygon_area);
Y /= (6 * polygon_area);
// If the values are negative, the polygon is
// oriented counterclockwise so reverse the signs.
if (X < 0)
{
X = -X;
Y = -Y;
}
return new PointF(X, Y);
}
Но результат далек:
{X = 3.11197066 Y = 100.614342}
Есть что-то, что я здесь пропустил?
Спасибо