Esempio n. 1
0
        /// <summary>
        /// Saves verticies in the specified path.
        /// </summary>
        /// <param name="path">Path to the file</param>
        /// /// <param name="polygon">Polygon to save</param>
        public static void saveVertices(string path, RegularPolygon polygon)
        {
            var verticies = polygon.VerticesCoordinates();

            string[] lines = new string[polygon.VertexNumber];
            for(int i = 0; i < polygon.VertexNumber; i++)
            {
                lines[i] = verticies[i].ToString();
            }
            System.IO.File.WriteAllLines(path, lines);
        }
Esempio n. 2
0
        /// <summary>
        /// Returns regular polygon with calculated (by RegularPolygonCalculator) values.
        /// </summary>
        /// <param name="vertexNumber"></param>
        /// <param name="sideLength"></param>
        /// <returns></returns>
        public static RegularPolygon createRegularPolygon(int vertexNumber, double sideLength)
        {
            if (vertexNumber < 3)
            {
                throw new ArgumentException("There should be at least 3 verticies");
            }

            RegularPolygon polygon = new RegularPolygon
                                     (
                RegularPolygonCalculator.calculateArea(vertexNumber, sideLength),
                vertexNumber,
                RegularPolygonCalculator.calculateVerticesCoordinates(sideLength, vertexNumber)
                                     );

            return(polygon);
        }