Пример #1
0
        private static Point[] ResizeConvexPolygon(Point[] polygon, double newArea)
        {
            Point center = Math2D.GetCenter(polygon);

            // Create a delagate that returns the area of the polygon based on the percent size
            Func <double, double> getOutput = new Func <double, double>(o =>
            {
                Point[] polyPoints = GetPolygon(center, polygon, o);
                return(Math2D.GetAreaPolygon(polyPoints));
            });

            // Find a percent that returns the desired area
            double percent = Math1D.GetInputForDesiredOutput_PosInput_PosCorrelation(newArea, newArea * .01, getOutput);

            // Return the sized polygon
            return(GetPolygon(center, polygon, percent));
        }