public static Size GetRotatedSize(Size size, double rotatedAngle) { double rotatedWidth = Math.Abs(Math.Cos(rotatedAngle)) * size.width + Math.Abs(Math.Sin(rotatedAngle)) * size.heigth; double rotatedHeigth = Math.Abs(Math.Sin(rotatedAngle)) * size.width + Math.Abs(Math.Cos(rotatedAngle)) * size.heigth; Size newRotatedSize = new Size(rotatedWidth, rotatedHeigth); return newRotatedSize; }
public static Size GetRotatedSize(Size size, double angle) { double cos = Math.Abs(Math.Cos(angle)); double sin = Math.Abs(Math.Sin(angle)); double width = (cos * size.Width) + (sin * size.Height); double height = (sin * size.Width) + (cos * size.Height); Size sizeOfFigure = new Size(width, height); return sizeOfFigure; }
public static Size GetRotatedFigure(Size s, double angleOfTheFigure) { var rotatedWidth = (Math.Abs(Math.Cos(angleOfTheFigure)) * s.width) + (Math.Abs(Math.Sin(angleOfTheFigure)) * s.heigth); var rotatedHeigth = (Math.Abs(Math.Sin(angleOfTheFigure)) * s.width) + (Math.Abs(Math.Cos(angleOfTheFigure)) * s.heigth); return new Size(rotatedWidth, rotatedHeigth); }
static void Main() { double width = 10.5; double height = 5.5; double angle = 35; Size triangle = new Size(width, height); Console.WriteLine("This figure has width {0} and height {1}", triangle.Width, triangle.Height); triangle = Size.GetRotatedSize(triangle, angle); Console.WriteLine("After rotated figure has width {0} and height {1}", triangle.Width, triangle.Height); }