예제 #1
0
        public void transform(CMatrix3x3 m)
        {
            double temp = _v[0];

            _v[0] = m[0][0] * temp + m[0][1] * _v[1] + m[0][2];
            _v[1] = m[1][0] * temp + m[1][1] * _v[1] + m[1][2];
        }
예제 #2
0
        public static void transform(CMatrix3x3 m, ref double v1, ref double v2)
        {
            double temp = v1;

            v1 = m[0][0] * temp + m[0][1] * v2 + m[0][2];
            v2 = m[1][0] * temp + m[1][1] * v2 + m[1][2];
        }
예제 #3
0
        public void transform(CMatrix3x3 m)
        {
            int n = _size;

            while ((n--) != 0)
            {
                this[n].transform(m);
            }
        }
예제 #4
0
        public static CMatrix3x3 realign(CXYVector target, CXYVector anchor, double [] weight)
        {
            double X1, Y1, X2, Y2, W, Z, C1, C2;

            int k = anchor.size;

            X1 = Y1 = X2 = Y2 = W = Z = C1 = C2 = 0;

            while ((k--) != 0)
            {
                double x1 = anchor[k][0];
                double y1 = anchor[k][1];
                double x2 = target[k][0];
                double y2 = target[k][1];

                double w = weight[k];

                W += w;
                Z += w * (x2 * x2 + y2 * y2);

                X1 += w * x1; Y1 += w * y1;
                X2 += w * x2; Y2 += w * y2;
                C1 += w * (x1 * x2 + y1 * y2);
                C2 += w * (y1 * x2 - x1 * y2);
            }

            CVector4 solution =
                new CMatrix4x4(
                    new CVector4(X2, -Y2, W, 0),
                    new CVector4(Y2, X2, 0, W),
                    new CVector4(Z, 0, X2, Y2),
                    new CVector4(0, Z, -Y2, X2)
                    ).inverse().multiplyCopy(new CVector4(X1, Y1, C1, C2));

            CMatrix3x3 trx = new CMatrix3x3(
                new CVector3(solution[0], -solution[1], solution[2]),
                new CVector3(solution[1], solution[0], solution[3]),
                new CVector3(0, 0, 1));

            target.transform(trx);
            return(trx);
        }
예제 #5
0
        public CMatrix3x3 inverse()
        {
            CMatrix3x3 a = new CMatrix3x3(this);
            CMatrix3x3 b = new CMatrix3x3();
            int        i, j, i1;

            for (j = 0; j < 3; j++)
            {
                i1 = j;
                for (i = j + 1; i < 3; i++)
                {
                    if (Math.Abs(a[i][j]) > Math.Abs(a[i1][j]))
                    {
                        i1 = i;
                    }
                }

                a.swapRow(i1, j);
                b.swapRow(i1, j);

                if (a[j][j] == 0)
                {
                    return(null);
                }
                b[j].divide(a[j][j]);
                a[j].divide(a[j][j]);

                for (i = 0; i < 3; i++)
                {
                    if (i != j)
                    {
                        b[i].substract(b[j].multiplyCopy(a[i][j]));
                        a[i].substract(a[j].multiplyCopy(a[i][j]));
                    }
                }
            }
            return(b);
        }
예제 #6
0
 public void substract(CMatrix3x3 m)
 {
     _m[0].substract(m[0]);
     _m[1].substract(m[1]);
     _m[2].substract(m[2]);
 }
예제 #7
0
 public void add(CMatrix3x3 m)
 {
     _m[0].add(m[0]);
     _m[1].add(m[1]);
     _m[2].add(m[2]);
 }
예제 #8
0
 public CMatrix3x3(CMatrix3x3 m)
 {
     _m[0] = new CVector3(m._m[0]);
     _m[1] = new CVector3(m._m[1]);
     _m[2] = new CVector3(m._m[2]);
 }