Пример #1
0
        public IConvexHull FindConvexHull(IList <PlanePoint> points)
        {
            int dim = points[0].Dim;

            if (dim == 2)
            {
                return(new ConvexHull2d(points));
            }
            ConvexHull convexHull = new ConvexHull(dim);

            PlanePoint[] planePoints = new PlanePoint[points.Count - 1];
            for (int i = 0; i < points.Count; i++)
            {
                int k = 0;
                for (int j = 0; j < points.Count; j++)
                {
                    if (j == i)
                    {
                        continue;
                    }
                    planePoints[k++] = points[j];
                }
                Hyperplane        hyperplane    = Hyperplane.Create(planePoints);
                List <PlanePoint> convertPoints =
                    planePoints.Select((point => hyperplane.ConvertPoint(point))).ToList();
                Face newFace = new Face(hyperplane);
                newFace.ConvexHull = FindConvexHull(convertPoints);
                foreach (ICell f in newFace.ConvexHull.Cells)
                {
                    newFace.AdjacentCells.Add((IFace)f);
                    ((IFace)f).AdjacentCells.Add(newFace);
                }

                convexHull.AddInnerCell(newFace);
            }

            return(convexHull);
        }
Пример #2
0
        public PlanePoint ConvertPoint_ReturnPlanePoint(Hyperplane h, Point p)
        {
            PlanePoint planePoint = h.ConvertPoint(p.ToPlanePoint());

            return(planePoint);
        }