示例#1
0
 static void Main(string[] args)
 {
     Size size = new Size(5, 4);
     Size newSize = GetRotatedSize(size, Math.PI/4);
     Console.WriteLine("New width: {0:F2}", newSize.width);
     Console.WriteLine("New height: {0:F2}", newSize.height);
 }
示例#2
0
        public static Size GetRotatedSize(Size size, double angleOfRotation)
        {
            double newWidth = Math.Abs(Math.Cos(angleOfRotation)) * size.width +
                    Math.Abs(Math.Sin(angleOfRotation)) * size.height;

            double newHeight = Math.Abs(Math.Sin(angleOfRotation)) * size.width +
                    Math.Abs(Math.Cos(angleOfRotation)) * size.height;

            return new Size(newWidth, newHeight);
        }