Exemplo n.º 1
0
        //create a rotation matrix from a fwd and side 2D vector

        //create a rotation matrix from a 2D vector
        public void Rotate(Vector2D fwd, Vector2D side)
        {
            C2DMatrix.Matrix mat = new C2DMatrix.Matrix();

            mat._11 = fwd.X;
            mat._12 = fwd.Y;
            mat._13 = 0;

            mat._21 = side.X;
            mat._22 = side.Y;
            mat._23 = 0;

            mat._31 = 0;
            mat._32 = 0;
            mat._33 = 1;

            //and multiply
            MatrixMultiply(mat);
        }
Exemplo n.º 2
0
        //create a scale matrix

        //create a scale matrix
        public void Scale(double xScale, double yScale)
        {
            C2DMatrix.Matrix mat = new C2DMatrix.Matrix();

            mat._11 = xScale;
            mat._12 = 0;
            mat._13 = 0;

            mat._21 = 0;
            mat._22 = yScale;
            mat._23 = 0;

            mat._31 = 0;
            mat._32 = 0;
            mat._33 = 1;

            //and multiply
            MatrixMultiply(mat);
        }
Exemplo n.º 3
0
        //multiplies m_Matrix with mIn

        //multiply two matrices together
        private void MatrixMultiply(Matrix mIn)
        {
            C2DMatrix.Matrix mat_temp = new C2DMatrix.Matrix();

            //first row
            mat_temp._11 = (m_Matrix._11 * mIn._11) + (m_Matrix._12 * mIn._21) + (m_Matrix._13 * mIn._31);
            mat_temp._12 = (m_Matrix._11 * mIn._12) + (m_Matrix._12 * mIn._22) + (m_Matrix._13 * mIn._32);
            mat_temp._13 = (m_Matrix._11 * mIn._13) + (m_Matrix._12 * mIn._23) + (m_Matrix._13 * mIn._33);

            //second
            mat_temp._21 = (m_Matrix._21 * mIn._11) + (m_Matrix._22 * mIn._21) + (m_Matrix._23 * mIn._31);
            mat_temp._22 = (m_Matrix._21 * mIn._12) + (m_Matrix._22 * mIn._22) + (m_Matrix._23 * mIn._32);
            mat_temp._23 = (m_Matrix._21 * mIn._13) + (m_Matrix._22 * mIn._23) + (m_Matrix._23 * mIn._33);

            //third
            mat_temp._31 = (m_Matrix._31 * mIn._11) + (m_Matrix._32 * mIn._21) + (m_Matrix._33 * mIn._31);
            mat_temp._32 = (m_Matrix._31 * mIn._12) + (m_Matrix._32 * mIn._22) + (m_Matrix._33 * mIn._32);
            mat_temp._33 = (m_Matrix._31 * mIn._13) + (m_Matrix._32 * mIn._23) + (m_Matrix._33 * mIn._33);


            m_Matrix = mat_temp;
        }
Exemplo n.º 4
0
        //create a rotation matrix

        //create a rotation matrix
        public void Rotate(double rot)
        {
            C2DMatrix.Matrix mat = new C2DMatrix.Matrix();

            double Sin = Math.Sin(rot);
            double Cos = Math.Cos(rot);

            mat._11 = Cos;
            mat._12 = Sin;
            mat._13 = 0;

            mat._21 = -Sin;
            mat._22 = Cos;
            mat._23 = 0;

            mat._31 = 0;
            mat._32 = 0;
            mat._33 = 1;

            //and multiply
            MatrixMultiply(mat);
        }