Exemple #1
0
        // find the cofactor matrix and return the same
        public Matrix2D CoFactor()
        {
            int i1, j1;
            double det;
            Matrix2D m = new Matrix2D();
            Matrix2D CMat = new Matrix2D();

            for (var j = 0; j < 2; j++)
            {
                for (var i = 0; i < 2; i++)
                {
                    i1 = 0;
                    for (var ii = 0; ii < 2; ii++)
                    {
                        if (ii != i)
                        {
                            j1 = 0;
                            for (var jj = 0; jj < 2; jj++)
                            {
                                if (jj != j)
                                {
                                    m.matrix.SetValue(matrix[ii, jj], i1, j1);
                                    j1 = +j1 + 1;
                                }
                            }
                            i1 = i1 + 1;
                        }
                    }
                    det = m.Determinant();
                    CMat.matrix.SetValue(System.Math.Pow(-1.0, i + j + 2.0) * det, i, j);
                }
                m = null;
            }
            return CMat;
        }
Exemple #2
0
 // copy constructor
 public Matrix2D(Matrix2D Mat)
 {
     this.matrix = new double[3, 3];
     for (var i = matrix.GetLowerBound(0); i < matrix.GetUpperBound(0); i++)
     {
         for (var j = matrix.GetLowerBound(1); j < matrix.GetUpperBound(1); j++)
         {
             matrix.SetValue(Mat.matrix[i, j], i, j);
         }
     }
 }
Exemple #3
0
 // multiply the currnet matrix with the parameter
 public void PreMultiplyBy(Matrix2D Mat)
 {
     Matrix2D ThisMat = new Matrix2D();
     Matrix2D CMat = new Matrix2D();
     ThisMat.matrix = matrix;
     CMat = Multiply(Mat, ThisMat);
     matrix = CMat.matrix;
     ThisMat = null;
     CMat = null;
 }
Exemple #4
0
 // multiply the currnet matrix with the parameter
 public void PostMultiplyBY(Matrix2D Mat)
 {
     Matrix2D Thismat = new Matrix2D();
     Matrix2D CMat = new Matrix2D();
     Thismat.matrix = matrix;
     CMat = Multiply(Thismat, Mat);
     matrix = CMat.matrix;
     Thismat = null;
     CMat = null;
 }
Exemple #5
0
 // multiply matrix 1 and 2 and return the resultant matrix
 public Matrix2D Multiply(Matrix2D Mat1, Matrix2D Mat2)
 {
     Matrix2D Mat = new Matrix2D();
     Double sum = 0;
     for (var ii = 0; ii < 2; ii++)
     {
         for (var jj = 0; jj < 2; jj++)
         {
             sum = 0;
             for (var kk = 0; kk < 2; kk++)
             {
                 sum = sum + (Mat1.matrix[ii, kk] * Mat2.matrix[kk, jj]);
             }
             Mat.matrix.SetValue(sum, ii, jj);
         }
     }
     return Mat;
 }
Exemple #6
0
        // transform this point by the parameter matrix
        public void TransformBy(Matrix2D Mat)
        {
            double xx = 0; double yy = 0;
            xx = (X * Mat.matrix[0, 0]) + (Y * Mat.matrix[1, 0]) + (Mat.matrix[0, 2]);

            yy = (X * Mat.matrix[0, 1]) + (Y * Mat.matrix[1, 1]) + (Mat.matrix[1, 2]);

            X = xx;
            Y = yy;
        }