Exemple #1
0
        public static Figure GetRotatedFigure(Figure rectangle, double angleOfRotation)
        {
            double rotatedWidthSize = (Math.Abs(Math.Cos(angleOfRotation)) * rectangle.Width) +
                (Math.Abs(Math.Sin(angleOfRotation)) * rectangle.Height);
            double rotatedHeightSize = (Math.Abs(Math.Sin(angleOfRotation)) * rectangle.Width) +
                (Math.Abs(Math.Cos(angleOfRotation)) * rectangle.Height);
            Figure rotatedFigure = new Figure(rotatedWidthSize, rotatedHeightSize);

            return rotatedFigure;
        }
        public static void Main()
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

            Figure initial = new Figure(4, 9);
            Console.WriteLine("Initial figure is:");
            Console.WriteLine(initial.ToString());

            Console.WriteLine();

            double angleOfRotation = 60;
            Figure rotated = Figure.GetRotatedFigure(initial, angleOfRotation);
            Console.WriteLine("Figure after rotation at {0} degrees is", angleOfRotation);
            Console.WriteLine(rotated.ToString());
        }