Beispiel #1
0
        /// <summary>
        /// The method calculates the new size after of rotation by N degrees
        /// </summary>
        /// <param name="angleOfRotation">The degrees of rotation</param>
        /// <returns>new object of type Size</returns>
        public Size GetRotatedSize(double angleOfRotation)
        {
            double width = GetSinAndCosOfDimensions(angleOfRotation, this.Width, this.Height);
            double height = GetSinAndCosOfDimensions(angleOfRotation, this.Height, this.Width);
            Size sizeAfterRotation = new Size(width, height);

            return sizeAfterRotation;
        }
        public static void Main()
        {
            var initialSize = new Size(10.0, 15.0);
            var sizeAfterRotation = initialSize.GetRotatedSize(35.5);

            Console.WriteLine(initialSize);
            Console.WriteLine(sizeAfterRotation);
        }
        public static void Main()
        {
            var figure = new Size(23.0, 7.0);
            var sizeAfterRotation = figure.GetRotatedSize(figure, 13.5);

            Console.WriteLine(figure);
            Console.WriteLine(sizeAfterRotation);
        }
        public static void Main()
        {
            var size = new Size(14.3, 7.2);
            var rotatedSize = size.GetRotatedSize(13.2);

            Console.WriteLine(size);
            Console.WriteLine(rotatedSize);
        }
        public Size GetRotatedSize(Size size, double figureAngle)
        {
            double figureAngleCos = Math.Abs(Math.Cos(figureAngle));
            double figureAngleSin = Math.Abs(Math.Sin(figureAngle));

            double width = (figureAngleCos * size.Width) + (figureAngleSin * size.Height);
            double height = (figureAngleSin * size.Width) + (figureAngleCos * size.Height);

            return new Size(width, height);
        }
        public static Size GetRotatedSize(
            Size figureToRotate, double angleOfRotate)
        {
            var cosOfAngleOfRotate = Math.Abs(Math.Cos(angleOfRotate));
            var sinOfAngleOfRotate = Math.Abs(Math.Sin(angleOfRotate));

            var newWidth = (cosOfAngleOfRotate * figureToRotate.Width) + (sinOfAngleOfRotate * figureToRotate.Height);
            var newHeight = (sinOfAngleOfRotate * figureToRotate.Width) + (cosOfAngleOfRotate * figureToRotate.Height);
            
            var rotatedFigure = new Size(newWidth, newHeight);

            return rotatedFigure;
        }