shader04_向量矩阵

向量点积

shader04_向量矩阵shader04_向量矩阵

向量叉积

shader04_向量矩阵

shader04_向量矩阵

 

矩阵

矩阵转置

shader04_向量矩阵

矩阵乘法

shader04_向量矩阵

shader04_向量矩阵

 class Triangle
    {
        PointF A, B, C;

        public Triangle(PointF A, PointF B, PointF C)
        {
            this.A = A;
            this.B = B;
            this.C = C;
        }

        public void Draw(Graphics g)
        {
            Pen pen = new Pen(Color.Red, 2);
            g.DrawLine(pen, A, B);
            g.DrawLine(pen, B, C);
            g.DrawLine(pen, C, A);
        }

        public void Rotate(int degrees)
        {
            float angle = (float)(degrees / 360.0f * Math.PI);//转化为弧度

            A.X = (float)(A.X * Math.Cos(angle) - A.Y * Math.Sin(angle));
            A.Y = (float)(A.X * Math.Sin(angle) + A.Y * Math.Cos(angle));

            B.X = (float)(B.X * Math.Cos(angle) - B.Y * Math.Sin(angle));
            B.Y = (float)(B.X * Math.Sin(angle) + B.Y * Math.Cos(angle));

            C.X = (float)(C.X * Math.Cos(angle) - C.Y * Math.Sin(angle));
            C.Y = (float)(C.X * Math.Sin(angle) + C.Y * Math.Cos(angle));
        }
    }

分别是沿XYZ轴旋转

shader04_向量矩阵

 

shader04_向量矩阵

shader04_向量矩阵

shader04_向量矩阵

 

shader04_向量矩阵

平移矩阵

shader04_向量矩阵

shader04_向量矩阵