Пример #1
0
        public Quadrilateral GetQuadrilateralByPosition(Plane plane, int positionX, int positionY )
        {
            var source = plane.Vertices.ToArray();

            int topLeft = ConvexGenerator.GetVertexIndex(PartWidth, positionX, positionY);
            int topRight = ConvexGenerator.GetVertexIndex(PartWidth, positionX + 1, positionY);
            int bottomRight = ConvexGenerator.GetVertexIndex(PartWidth, positionX + 1, positionY + 1);
            int bottomLeft = ConvexGenerator.GetVertexIndex(PartWidth, positionX, positionY + 1);

            return new Quadrilateral
                {
                    TopLeft = source[topLeft],
                    TopRight = source[topRight],
                    BottomRight = source[bottomRight],
                    BottomLeft = source[bottomLeft]
                };
        }
Пример #2
0
        public static void FillPlanes(this ConvexSettings settings)
        {
            settings.Planes = new List<Plane>();
            for (int i = 0; i < settings.NumberOfPlanes; i++)
            {
                var plane = new Plane();
                List<Color> colors = ConvexGenerator.GetFaceColors(settings.PartWidth, settings.PartHeight);

                plane.Colors = colors;
                Quadrilateral quadrilateral = ConvexGenerator.GenerateRandomQuadrilateral(settings.BoundaryBox,
                                                                                          settings.MinFractureSize,
                                                                                          settings.MaxFractureSize);
                Point[] vertices = ConvexGenerator.GetGridVertices(quadrilateral, settings.PartWidth,
                                                                   settings.PartHeight);
                plane.Vertices = new List<Point>();
                plane.Vertices.AddRange(vertices);
                settings.Planes.Add(plane);
            }
        }