Example #1
0
        public Form1()
        {
            InitializeComponent();

            this.Width          = WIDTH;
            this.Height         = HEIGHT;
            this.DoubleBuffered = true;

            Vector v1 = new Vector();

            Console.WriteLine(v1);
            Vector v2 = new Vector(1, 2);

            Console.WriteLine(v2);
            Vector v3 = new Vector(2, 6);

            Console.WriteLine(v3);
            Vector v4 = v2 + v3;

            Console.WriteLine(v4); // 3, 8

            Matrix m1 = new Matrix();

            Console.WriteLine(m1); // 1, 0, 0, 1
            Matrix m2 = new Matrix(
                2, 4, 0, 0,
                -1, 3, 0, 0);

            Console.WriteLine(m2);
            Console.WriteLine(m1 + m2); // 3, 4, -1, 4
            Console.WriteLine(m1 - m2); // -1, -4, 1, -2
            Console.WriteLine(m2 * m2); // 0, 20, -5, 5

            Console.WriteLine(m2 * v3); // 28, 16

            // Define axes
            x_axis = new AxisX(200);
            y_axis = new AxisY(200);

            // Create object
            square1 = new Square(Color.Purple, 100);
            square2 = new Square(Color.Green, 50);
            square3 = new Square(Color.Blue, 100);

            Matrix scale = Matrix.ScaleMatrix(3.0f);

            for (int i = 0; i < square2.vb.Count; i++)
            {
                square2.vb[i] = scale * square2.vb[i];
            }

            Matrix rotated = Matrix.RotateMatrix(20);

            for (int i = 0; i < square3.vb.Count; i++)
            {
                square3.vb[i] = rotated * square3.vb[i];
            }


            var transv     = new Vector(50, 150);
            var translator = Matrix.TranslationMatrix(transv);

            for (int i = 0; i < square1.vb.Count; i++)
            {
                square1.vb[i] = translator * square1.vb[i];
            }

            Console.WriteLine(square1);
        }