23 lines
517 B
C#
23 lines
517 B
C#
using System.Collections.Generic;
|
|
|
|
namespace Assets.Common
|
|
{
|
|
public static class PointUtils
|
|
{
|
|
public static Point Mean(IEnumerable<Point> points)
|
|
{
|
|
var result = new Point(0, 0);
|
|
var i = 0;
|
|
|
|
foreach (var point in points)
|
|
{
|
|
result.x = (result.x * i + point.x) / (i + 1);
|
|
result.y = (result.y * i + point.y) / (i + 1);
|
|
|
|
i++;
|
|
}
|
|
|
|
return result;
|
|
}
|
|
}
|
|
} |