Example #1
0
        private void FormTopology_Load(object sender, EventArgs e)
        {
            var geometry = RectanglePolygon.Generate(4);

            mesh = new Mesh();
            mesh.Triangulate(geometry);

            renderControl.Initialize(mesh);

            topoControlView.PrimitiveCommandInvoked += PrimitiveCommandHandler;

            current = new OrientedTriangle();
        }
Example #2
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);
        }
Example #3
0
        public void Axis_Aligned_Has_Zero_Angle_Test()
        {
            RectanglePolygon testRect = new RectanglePolygon(axisAlignedRect: new Rect(0, 0, 640, 480), rotationAngle: 0);

            Assert.Equal(0d, testRect.Angle);
        }