Beispiel #1
0
        /// <summary>
        /// Generiert eine Zellstruktur mit der angegebenen Länge und Breite. Die Ränder werden automatisch dazu addiert.
        /// </summary>
        /// <param name="s_width">Breite der gewünschten Struktur.</param>
        /// <param name="s_height">Länge der gewünschten Struktur</param>
        /// <returns>Einen GenStructHelper mit den Strukturinformationen.</returns>
        public GenStructHelper GenerateStructure(int s_width, int s_height)
        {
            List <DominoDefinition> DominoList = new List <DominoDefinition>();
            GenStructHelper         g          = new GenStructHelper() // Initialize GenStructHelper with final size.
            {
                width  = cells[0, 0].width + cells[1, 1].width * s_width + cells[2, 2].width,
                height = cells[0, 0].height + cells[1, 1].height * s_height + cells[2, 2].height
            };

            for (int x = -1; x < s_width + 1; x++)
            {
                for (int y = -1; y < s_height + 1; y++)
                {
                    DominoList.AddRange(
                        (cells[(x == -1) ? 0 : ((x == s_width) ? 2 : 1), (y == -1) ? 0 : ((y == s_height) ? 2 : 1)]
                         .TransformDefinition(
                             (x == -1) ? 0 : (cells[1, 1].width * x + cells[0, 0].width),
                             (y == -1) ? 0 : (cells[1, 1].height * y + cells[0, 0].height),
                             x, y, s_width, s_height))
                        .Dominoes);
                }
            }
            g.dominoes = DominoList.ToArray();
            g.HasProtocolDefinition = HasProtocolDefinition;
            return(g);
        }
Beispiel #2
0
        public GenStructHelper GenerateCircle()
        {
            List <DominoDefinition> dominos = new List <DominoDefinition>();
            int circlecount = 0;
            int diameter    = d_min;

            while (circlecount < circles)
            {
                diameter += 2 * domino_height + 2 * normal_distance;
                // get number of dominoes in this spiral
                double domino_angle         = Math.Asin((double)domino_width / diameter) * 2;
                double distance_angle       = Math.Asin((double)tangential_distance / diameter) * 2;
                int    current_domino_count = (int)Math.Floor(2 * Math.PI / ((double)domino_angle + distance_angle));
                // equally space the distance between all dominoes
                distance_angle = (2 * Math.PI - (domino_angle * current_domino_count)) / current_domino_count;
                // calculate dominoes
                double angle = 0;
                for (int i = 0; i < current_domino_count; i++)
                {
                    DominoDefinition d = GenerateDomino(diameter, angle, domino_angle);
                    angle += domino_angle + distance_angle;
                    dominos.Add(d);
                }
                circlecount++;
            }
            DominoDefinition[] Domino = dominos.ToArray();
            float x_min = int.MaxValue;
            float y_min = int.MaxValue;
            float x_max = int.MinValue;
            float y_max = int.MinValue;

            foreach (DominoDefinition d in Domino)
            {
                RectangleF container = d.GetContainer();
                if (container.X < x_min)
                {
                    x_min = container.X;
                }
                if (container.Y < y_min)
                {
                    y_min = container.Y;
                }
                if (container.X + container.Width > x_max)
                {
                    x_max = container.X + container.Width;
                }
                if (container.Y + container.Height > y_max)
                {
                    y_max = container.Y + container.Height;
                }
            }
            for (int i = 0; i < Domino.Length; i++)
            {
                Domino[i] = Domino[i].TransformDefinition(-x_min, -y_min, 0, 0, 0, 0);
            }
            GenStructHelper g = new GenStructHelper();

            g.HasProtocolDefinition = false;
            g.dominoes = Domino;
            g.width    = x_max - x_min;
            g.height   = y_max - y_min;
            return(g);

            GenStructHelper circle = new GenStructHelper();

            // do some magic
            return(circle);
        }
Beispiel #3
0
        public GenStructHelper GenerateSpiral()
        {
            List <DominoDefinition> dominolist = new List <DominoDefinition>();
            double theta    = theta_min;
            int    ycounter = 0;

            while (theta < theta_max)
            {
                DominoDefinition d = CreateDomino(theta);
                d.ProtocolDefinition = new DominoProtocolDefinition();
                d.ProtocolDefinition.yParams.yConstant = (int)Math.Floor((theta - theta_min) / (2d * Math.PI));
                d.ProtocolDefinition.xParams.xConstant = ycounter;
                dominolist.Add(d);
                double start_value = theta + 0.01d;
                double theta_new   = newton_archimedean(theta, start_value, (double)tangential_distance + (double)domino_width);
                while (theta_new < theta)
                {
                    start_value += 0.01d;
                    theta_new    = newton_archimedean(theta, start_value, (double)tangential_distance + (double)domino_width);
                }
                ycounter++;
                if ((int)Math.Floor((theta - theta_min) / (2d * Math.PI)) != (int)Math.Floor((theta_new - theta_min) / (2d * Math.PI)))
                {
                    ycounter = 0;
                }
                theta = theta_new;
            }
            DominoDefinition[] Domino = dominolist.ToArray();
            float x_min = int.MaxValue;
            float y_min = int.MaxValue;
            float x_max = int.MinValue;
            float y_max = int.MinValue;

            foreach (DominoDefinition d in Domino)
            {
                RectangleF container = d.GetContainer();
                if (container.X < x_min)
                {
                    x_min = container.X;
                }
                if (container.Y < y_min)
                {
                    y_min = container.Y;
                }
                if (container.X + container.Width > x_max)
                {
                    x_max = container.X + container.Width;
                }
                if (container.Y + container.Height > y_max)
                {
                    y_max = container.Y + container.Height;
                }
            }
            for (int i = 0; i < Domino.Length; i++)
            {
                Domino[i] = Domino[i].TransformDefinition(-x_min, -y_min, 0, 0, 0, 0);
            }
            GenStructHelper g = new GenStructHelper();

            g.HasProtocolDefinition = true;
            g.dominoes = Domino;
            g.width    = x_max - x_min;
            g.height   = y_max - y_min;
            return(g);
        }