コード例 #1
0
 // The default constructor must create a identity matrix.
 public NativeMatrix44Adaptor()
 {
     m_Matrix2d = new NativeMatrix2dAdaptor(4, 4);
     for (int row = 0; row < 4; row++)
         for (int column = 0; column < 4; column++)
             if (row == column)
                 m_Matrix2d[row, column] = 1;
             else
                 m_Matrix2d[row, column] = 0;
 }
コード例 #2
0
        public NativeMatrix2dAdaptor(NativeMatrix2dAdaptor src)
        {
            Debug.Assert(src != null);

            m_IriduimMatrix = Matrix.Create(src.m_IriduimMatrix);
        }
コード例 #3
0
        public NativeMatrix2dAdaptor RightUnite(NativeMatrix2dAdaptor B)
        {
            if (null == B) return null;

            if (this.RowCount != B.RowCount) return null;

            double[,] data = new double[this.RowCount
                , this.ColumnCount + B.ColumnCount];

            for (int row = 0; row < this.RowCount; row++)
                for (int col = 0; col < this.ColumnCount; col++)
                    data[row, col] = this[row, col];

            for (int row = 0; row < this.RowCount; row++)
                for (int col = 0; col < B.ColumnCount; col++)
                    data[row, this.ColumnCount + col] = B[row, col];

            NativeMatrix2dAdaptor C = new NativeMatrix2dAdaptor(data);

            return C;
        }
コード例 #4
0
        public void RightMutiply(NativeMatrix2dAdaptor rhs)
        {
            if (null == rhs) return;

            NativeMatrix2dAdaptor newMatrix = this * rhs;

            m_IriduimMatrix = new Matrix(newMatrix.m_IriduimMatrix);
        }
コード例 #5
0
 public NativeMatrix2dAdaptor Clone()
 {
     NativeMatrix2dAdaptor NewMatrix = new NativeMatrix2dAdaptor(m_IriduimMatrix.Clone());
     return NewMatrix;
 }
コード例 #6
0
 private NativeMatrix44Adaptor(NativeMatrix2dAdaptor src)
 {
     Debug.Assert(src.RowCount == 4 && src.ColumnCount == 4);
     if (src.RowCount == 4 && src.ColumnCount == 4)
         m_Matrix2d = src;
 }
コード例 #7
0
        protected override PointAdaptor OperatorMultiply(Matrix44Adaptor trans, PointAdaptor point)
        {
            Debug.Assert(point != null && trans != null);
            if (null == point || null == trans) return null;

            double[,] data = new double[4, 1];
            data[0, 0] = point.X;
            data[1, 0] = point.Y;
            data[2, 0] = point.Z;
            data[3, 0] = 1;
            NativeMatrix44Adaptor nativeTrans = trans as NativeMatrix44Adaptor;
            NativeMatrix2dAdaptor pointMatrix = new NativeMatrix2dAdaptor(data);

            NativeMatrix2dAdaptor resulr = nativeTrans.GetNativeMatrix2dProxy() * pointMatrix;
            resulr = resulr / resulr[3, 0];

            return new NativePointAdaptor(resulr[0, 0], resulr[1, 0], resulr[2, 0]);
        }
コード例 #8
0
        // Scale
        public override Matrix44Adaptor SetScaling(double allScale, PointAdaptor basePoint)
        {
            Debug.Assert(allScale > 0 && basePoint != null);
            if (!(allScale > 0 && basePoint != null)) return this;

            PointAdaptor origin = new NativePointAdaptor(0,0,0);
            if (basePoint.IsEqualTo(origin))
            {
                SetScaling(allScale);
            }
            else
            {
                // Transform the origin to the base point.
                NativeMatrix44Adaptor T = NativeMatrix44Adaptor.Identity;
                T.SetTranslation(origin - basePoint);

                // zoom
                NativeMatrix44Adaptor S = NativeMatrix44Adaptor.Identity;
                S.SetScaling(allScale);

                // Recover the coordinate of the base point
                NativeMatrix44Adaptor T_1 = T.Inverse as NativeMatrix44Adaptor;

                NativeMatrix44Adaptor R = (T_1 * S * T) as NativeMatrix44Adaptor;
                m_Matrix2d = new NativeMatrix2dAdaptor(R.m_Matrix2d);
            }

            return this;
        }