private void Redraw()
        {
            Bitmap bitmap = ImageConverters.BitmapImage2Bitmap(Scene);

            using (Graphics graph = Graphics.FromImage(bitmap))
            {
                Rectangle ImageSize = new Rectangle(0, 0, sceneWidth, sceneHeight);
                graph.FillRectangle(Brushes.Black, ImageSize);
            }

            Matrix <double> rotationX = DenseMatrix.OfArray(new double[, ]
            {
                { 1, 0, 0, 0 },
                { 0, Math.Cos(xRotation), Math.Sin(xRotation), 0 },
                { 0, -Math.Sin(xRotation), Math.Cos(xRotation), 0 },
                { 0, 0, 0, 1 }
            });

            Matrix <double> rotationY = DenseMatrix.OfArray(new double[, ]
            {
                { Math.Cos(yRotation), 0, -Math.Sin(yRotation), 0 },
                { 0, 1, 0, 0, },
                { Math.Sin(yRotation), 0, Math.Cos(yRotation), 0 },
                { 0, 0, 0, 1 }
            });

            Matrix <double> rotationZ = DenseMatrix.OfArray(new double[, ]
            {
                { Math.Cos(zRotation), -Math.Sin(zRotation), 0, 0 },
                { Math.Sin(zRotation), Math.Cos(zRotation), 0, 0 },
                { 0, 0, 1, 0 },
                { 0, 0, 0, 1 }
            });

            Matrix <double> finalMatrix = DenseMatrix.CreateIdentity(4) * Translate * rotationY * rotationX * rotationZ * Zoom;

            bitmap = TransformCube(cube1, finalMatrix, bitmap);
            bitmap = TransformCube(cube2, finalMatrix, bitmap);

            Scene = ImageConverters.Bitmap2BitmapImage(bitmap);

            Image imageControl = (Image)this.FindName("SceneImage");

            imageControl.Source = Scene;
        }
        private void PrepareScene()
        {
            Image imageControl = (Image)this.FindName("SceneImage");

            imageControl.Width  = sceneWidth;
            imageControl.Height = sceneHeight;

            Bitmap bitmap = new Bitmap(sceneWidth, sceneHeight);

            using (Graphics graph = Graphics.FromImage(bitmap))
            {
                Rectangle ImageSize = new Rectangle(0, 0, sceneWidth, sceneHeight);
                graph.FillRectangle(Brushes.Black, ImageSize);
            }

            cube1 = new CustomCube(700, 300, 50, 100);
            cube2 = new CustomCube(550, 300, 10, 50);

            bitmap = cube1.Draw(bitmap);
            bitmap = cube2.Draw(bitmap);

            Scene = ImageConverters.Bitmap2BitmapImage(bitmap);

            imageControl.Source = Scene;

            double tanValue = 1 / Math.Tan(theta / 2);

            //T[3, 1] = cube1.GetCenterY();

            //Zoom[3, 1] = cube1.GetCenterY();
            Zoom[3, 2]   = 5;
            ZoomProperty = 30;

            M = DenseMatrix.OfArray(new double[, ] {
                { tanValue, 0, 0, 0 },
                { 0, tanValue, 0, 0 },
                { 0, 0, -far / (far - near), -1 },
                { 0, 0, (-far * near) / (far - near), 0 }
            });
        }