public List<IntPoint> OptimizeShape(List<IntPoint> shape)
{
if (vertices > shape.Count)
throw new ArgumentException("Number of points left must be higher than number of the shape.");
var complex = new List<Complex>();
for (int i = 0; i < shape.Count; i++)
complex.Add(new Complex(shape[i].X, shape[i].Y));
for (int i = 0; i < shape.Count - vertices; i++)
{
double[] winkelmaass = winkel(complex);
int index = 0;
Matrix.Min(winkelmaass, out index);
complex.RemoveAt(index);
}
var newShape = new List<IntPoint>(complex.Count);
for (int i = 0; i < complex.Count; i++)
newShape.Add(new IntPoint((int)complex[i].Real, (int)complex[i].Imaginary));
return newShape;
}