예제 #1
0
        public void RotationMatrixTest()
        {
            RectanglePolygon testRect      = new RectanglePolygon(new Point(100, 100), new Point(300, 100), new Point(300, 200), new Point(100, 200));
            double           expectedAngle = 0d;

            Assert.Equal(expectedAngle, testRect.Angle);

            Matrix matrix = MatrixFactory.CreateRotationMatrix(90, testRect.Center);

            Point[] rectPoints = new[] { testRect.TopLeft, testRect.TopRight, testRect.BottomRight, testRect.BottomLeft };
            matrix.Transform(rectPoints);
            testRect      = new RectanglePolygon(rectPoints[0], rectPoints[1], rectPoints[2], rectPoints[3]);
            expectedAngle = 90d;
            Assert.Equal(expectedAngle, testRect.Angle);

            matrix     = MatrixFactory.CreateRotationMatrix(-45, testRect.Center);
            rectPoints = new[] { testRect.TopLeft, testRect.TopRight, testRect.BottomRight, testRect.BottomLeft };
            matrix.Transform(rectPoints);
            testRect      = new RectanglePolygon(rectPoints[0], rectPoints[1], rectPoints[2], rectPoints[3]);
            expectedAngle = 45d;
            Assert.Equal(expectedAngle, testRect.Angle);
        }