internal static Figure GetRotatedFigure(Figure figure, double angleOfTheFigureThatWillBeRotaed) { double cosinusOfAngle; double absoluteCosinus; double sinusOfAngle; double absoluteSinus; cosinusOfAngle = Math.Cos(angleOfTheFigureThatWillBeRotaed); absoluteCosinus = Math.Abs(cosinusOfAngle); absoluteCosinus *= figure.Width; sinusOfAngle = Math.Sin(angleOfTheFigureThatWillBeRotaed); absoluteSinus = Math.Abs(sinusOfAngle); absoluteSinus *= figure.Height; double widthOfTheNewFigure = absoluteCosinus + absoluteSinus; cosinusOfAngle = Math.Cos(angleOfTheFigureThatWillBeRotaed); absoluteCosinus = Math.Abs(cosinusOfAngle); absoluteCosinus *= figure.Height; sinusOfAngle = Math.Sin(angleOfTheFigureThatWillBeRotaed); absoluteSinus = Math.Abs(sinusOfAngle); absoluteSinus *= figure.Width; double heightOfTheNewFigure = absoluteCosinus + absoluteSinus; Figure newFigure = new Figure(widthOfTheNewFigure, heightOfTheNewFigure); return newFigure; }
public static Figure GetRotatedFigure(Figure firgure, double angleOfTheFigureToBeRotated) { double sinusTimesHeight = Math.Abs(Math.Sin(angleOfTheFigureToBeRotated)) * firgure.Height; double cosinusTimesWidth = Math.Abs(Math.Cos(angleOfTheFigureToBeRotated)) * firgure.Width; double sinusTimesWidth = Math.Abs(Math.Sin(angleOfTheFigureToBeRotated)) * firgure.Width; double cosinusTimesHeight = Math.Abs(Math.Cos(angleOfTheFigureToBeRotated)) * firgure.Height; double rotatedFigureWidth = cosinusTimesWidth + sinusTimesHeight; double rotatedFigureHeight = sinusTimesWidth + cosinusTimesHeight; Figure rotatedFigure = new Figure(rotatedFigureWidth, rotatedFigureHeight); return rotatedFigure; }
public static Figure GetRotatedFigure(Figure figure, double angleOfRotation) { double sinOfAngle = Math.Sin(angleOfRotation); double cosOfAngle = Math.Cos(angleOfRotation); double modulOfSinus = Math.Abs(sinOfAngle); double modulOfCosinus = Math.Abs(cosOfAngle); double rotatedFigureWidth = (modulOfCosinus * figure.width) + (modulOfSinus * figure.height); double rotatedFigureHeight = (modulOfSinus * figure.width) + (modulOfCosinus * figure.height); Figure rotatedFigure = new Figure(rotatedFigureWidth, rotatedFigureHeight); return rotatedFigure; }
// this class is not included in homework. I just put it for test purposes. static void Main() { Figure square = new Figure(3.5, 3.5); Figure Idkwhatisthis = Figure.GetRotatedFigure(square, 90); Console.WriteLine(Idkwhatisthis.Width + " " + Idkwhatisthis.Height); }