public override void RegenerateShapes()
        {
            Point             endpoint   = getPoint(ThetaMax, nGroup * (DominoLength + NormalDistance) / a);
            double            end_radius = Math.Sqrt(endpoint.X * endpoint.X + endpoint.Y * endpoint.Y);
            List <PathDomino> dominolist = new List <PathDomino>();
            double            pi2        = 1 / (2d * Math.PI); // spart ein paar Gleitkommadivisionen

            for (int i = 0; i < nGroup; i++)
            {
                double shift = i * (DominoLength + NormalDistance) / a;
                shift = shift - shiftfactor * nGroup * (DominoLength + NormalDistance) / a;
                double theta          = ThetaMin;
                int    ycounter       = 0;
                double current_radius = 0;
                while (closeEnds ? current_radius < end_radius : theta < ThetaMax)
                {
                    Point current_point = getPoint(theta, i * (DominoLength + NormalDistance) / a);
                    current_radius = Math.Sqrt(current_point.X * current_point.X + current_point.Y * current_point.Y);
                    for (int k = 0; k < nArms; k++)
                    {
                        PathDomino d = CreateDomino(theta, shift, 2.0 * Math.PI / nArms * k);
                        //d.position = new ProtocolDefinition();
                        //d.position.y = (int)Math.Floor((theta - theta_min) * pi2);
                        //d.position.x = ycounter;
                        dominolist.Add(d);
                    }
                    double start_value = theta;
                    double theta_new;
                    do
                    {
                        start_value += 0.01d;
                        theta_new    = approximate_archimedean(theta, start_value, TangentialDistance + DominoWidth, shift);
                    }while (theta_new < theta);
                    ycounter++;
                    if ((int)Math.Floor((theta - ThetaMin) * pi2) != (int)Math.Floor((theta_new - ThetaMin) * pi2))
                    {
                        ycounter = 0;
                    }
                    theta = theta_new;
                }
            }
            IDominoShape[]    dominoes   = dominolist.ToArray();
            DominoRectangle[] containers = dominoes.AsParallel().Select(x => x.GetContainer()).ToArray();

            double x_min = containers.Min(x => x.x);
            double y_min = containers.Min(x => x.y);
            double x_max = containers.Max(x => x.width + x.x);
            double y_max = containers.Max(x => x.height + x.y);

            Parallel.For(0, dominoes.Length, (i) =>
            {
                dominoes[i] = dominoes[i].TransformDomino(-x_min, -y_min, 0, 0, 0, 0);
            });
            last        = new DominoTransfer(dominoes, colors);
            shapesValid = true;
        }
        public override void RegenerateShapes()
        {
            PathDomino[][] dominos = new PathDomino[Circles][];
            Parallel.For(0, Circles, new ParallelOptions()
            {
                MaxDegreeOfParallelism = -1
            },
                         (circlecount) =>
            {
                int diameter             = StartDiameter + circlecount * (2 * DominoWidth + 2 * NormalDistance);
                double domino_angle      = Math.Asin((double)DominoLength / diameter) * 2;
                double distance_angle    = Math.Asin((double)TangentialDistance / diameter) * 2;
                int current_domino_count = (int)Math.Floor(2 * Math.PI / ((double)domino_angle + distance_angle));
                current_domino_count     = (int)Math.Floor((double)current_domino_count / _force_divisibilty) * _force_divisibilty;
                // equally space the distance between all dominoes
                distance_angle = (2 * Math.PI - (domino_angle * current_domino_count)) / current_domino_count;
                // calculate dominoes
                double angle         = (double)AngleShiftFactor * circlecount;
                dominos[circlecount] = new PathDomino[current_domino_count];
                for (int i = 0; i < current_domino_count; i++)
                {
                    PathDomino d = GenerateDomino(diameter, angle);
                    angle       += domino_angle + distance_angle;
                    d.position   = new ProtocolDefinition()
                    {
                        x = i, y = circlecount
                    };
                    dominos[circlecount][i] = d;
                }
            });
            IDominoShape[]    dominoes   = dominos.SelectMany(x => x).ToArray();
            DominoRectangle[] containers = dominoes.AsParallel().Select(x => x.GetContainer()).ToArray();

            double x_min = containers.Min(x => x.x);
            double y_min = containers.Min(x => x.y);
            double x_max = containers.Max(x => x.width + x.x);
            double y_max = containers.Max(x => x.height + x.y);

            Parallel.For(0, dominoes.Length, (i) =>
            {
                dominoes[i] = dominoes[i].TransformDomino(-x_min, -y_min, 0, 0, 0, 0);
            });
            last        = new DominoTransfer(dominoes, colors);
            shapesValid = true;
        }