コード例 #1
0
ファイル: Matrix4x4.cs プロジェクト: glocklueng/agg-sharp
 public Matrix4X4(Matrix4X4 CopyFrom)
 {
     for(int i=0; i<16; i++)
     {
         matrix[i] = CopyFrom.matrix[i];
     }
 }
コード例 #2
0
        public void PrepareMatrix(double Tx, double Ty, double Tz,
                                  double Rx, double Ry, double Rz,
                                  double Sx, double Sy, double Sz)
        {
            bool Initialized = false;

            if (Sx != 1.0f || Sy != 1.0f || Sz != 1.0f)
            {
                if (Initialized)
                {
                    Matrix4X4 Temp = new Matrix4X4();
                    Temp.Scale(Sx, Sy, Sz);
                    Multiply(Temp);
                }
                else
                {
                    Scale(Sx, Sy, Sz);
                    Initialized = true;
                }
            }
            if (Rx != .0f)
            {
                if (Initialized)
                {
                    Matrix4X4 Temp = new Matrix4X4();
                    Temp.Rotate(0, Rx);
                    Multiply(Temp);
                }
                else
                {
                    Rotate(0, Rx);
                    Initialized = true;
                }
            }
            if (Ry != .0f)
            {
                if (Initialized)
                {
                    Matrix4X4 Temp = new Matrix4X4();
                    Temp.Rotate(1, Ry);
                    Multiply(Temp);
                }
                else
                {
                    Rotate(1, Ry);
                    Initialized = true;
                }
            }
            if (Rz != .0f)
            {
                if (Initialized)
                {
                    Matrix4X4 Temp = new Matrix4X4();
                    Temp.Rotate(2, Rz);
                    Multiply(Temp);
                }
                else
                {
                    Rotate(2, Rz);
                    Initialized = true;
                }
            }
            if (Tx != 0.0f || Ty != 0.0f || Tz != 0.0f)
            {
                if (Initialized)
                {
                    Matrix4X4 Temp = new Matrix4X4();
                    Temp.Translate(Tx, Ty, Tz);
                    Multiply(Temp);
                }
                else
                {
                    Translate(Tx, Ty, Tz);
                    Initialized = true;
                }

                if (!Initialized)
                {
                    Identity();
                }
            }
        }
コード例 #3
0
        public bool Invert()
        {
            Matrix4X4 Temp = new Matrix4X4(this);

            return(SetToInverse(Temp));
        }
コード例 #4
0
 public bool SetToInverse(Matrix4X4 OriginalMatrix)
 {
     IntelInvertC(OriginalMatrix.matrix, matrix);
     return(true);
 }
コード例 #5
0
ファイル: Matrix4x4.cs プロジェクト: glocklueng/agg-sharp
 public void SetElements(Matrix4X4 CopyFrom)
 {
     SetElements(CopyFrom.GetElements());
 }
コード例 #6
0
ファイル: Matrix4x4.cs プロジェクト: glocklueng/agg-sharp
        public void Multiply(Matrix4X4 One, Matrix4X4 Two)
        {
            if (this == One || this == Two)
            {
                throw new System.FormatException("Neither of the input parameters can be the same Matrix as this.");
            }

	        for(int i = 0; i < 4; i++)
	        {
		        for(int j = 0; j < 4; j++)
		        {
                    SetElement(i, j, 0);
			        for(int k = 0; k < 4; k++)
			        {
				        AddElement(i, j, One.GetElement(i, k) * Two.GetElement(k, j));
			        }
		        }
	        }
        }
コード例 #7
0
ファイル: Matrix4x4.cs プロジェクト: glocklueng/agg-sharp
        public void Multiply(Matrix4X4 Two)
        {
	        Matrix4X4 Hold = new Matrix4X4(this);
	        Multiply(Hold, Two);
        }
コード例 #8
0
ファイル: Matrix4x4.cs プロジェクト: glocklueng/agg-sharp
        public bool SetToInverse(Matrix4X4 OriginalMatrix)
        {
	        IntelInvertC(OriginalMatrix.matrix, matrix);
	        return true;
        }
コード例 #9
0
ファイル: Matrix4x4.cs プロジェクト: glocklueng/agg-sharp
        public void PrepareInvMatrix(double Tx, double Ty, double Tz,
                                          double Rx, double Ry, double Rz,
                                          double Sx, double Sy, double Sz)
        {
	        Matrix4X4 M0 = new Matrix4X4();
            Matrix4X4 M1 = new Matrix4X4();
            Matrix4X4 M2 = new Matrix4X4();
            Matrix4X4 M3 = new Matrix4X4();
            Matrix4X4 M4 = new Matrix4X4();
            Matrix4X4 M5 = new Matrix4X4();
            Matrix4X4 M6 = new Matrix4X4();
            Matrix4X4 M7 = new Matrix4X4();

	        M0.Scale(Sx, Sy, Sz);
	        M1.Rotate(0, Rx);
	        M2.Rotate(1, Ry);
	        M3.Rotate(2, Rz);
	        M4.Translate(Tx, Ty, Tz);
	        // 4 * 3 * 2 * 1 * 0
	        M5.Multiply(M4, M3);
	        M6.Multiply(M5, M2);
	        M7.Multiply(M6, M1);
	        Multiply(M7, M0);
        }
コード例 #10
0
ファイル: Matrix4x4.cs プロジェクト: glocklueng/agg-sharp
        public void PrepareMatrix(double Tx, double Ty, double Tz,
                                       double Rx, double Ry, double Rz,
                                       double Sx, double Sy, double Sz)
        {
            bool Initialized = false;

            if (Sx != 1.0f || Sy != 1.0f || Sz != 1.0f)
            {
                if (Initialized)
                {
                    Matrix4X4 Temp = new Matrix4X4();
                    Temp.Scale(Sx, Sy, Sz);
                    Multiply(Temp);
                }
                else
                {
                    Scale(Sx, Sy, Sz);
                    Initialized = true;
                }
            }
            if (Rx != .0f)
            {
                if (Initialized)
                {
                    Matrix4X4 Temp = new Matrix4X4();
                    Temp.Rotate(0, Rx);
                    Multiply(Temp);
                }
                else
                {
                    Rotate(0, Rx);
                    Initialized = true;
                }
            }
            if (Ry != .0f)
            {
                if (Initialized)
                {
                    Matrix4X4 Temp = new Matrix4X4();
                    Temp.Rotate(1, Ry);
                    Multiply(Temp);
                }
                else
                {
                    Rotate(1, Ry);
                    Initialized = true;
                }
            }
            if (Rz != .0f)
            {
                if (Initialized)
                {
                    Matrix4X4 Temp = new Matrix4X4();
                    Temp.Rotate(2, Rz);
                    Multiply(Temp);
                }
                else
                {
                    Rotate(2, Rz);
                    Initialized = true;
                }
            }
            if (Tx != 0.0f || Ty != 0.0f || Tz != 0.0f)
            {
                if (Initialized)
                {
                    Matrix4X4 Temp = new Matrix4X4();
                    Temp.Translate(Tx, Ty, Tz);
                    Multiply(Temp);
                }
                else
                {
                    Translate(Tx, Ty, Tz);
                    Initialized = true;
                }

                if (!Initialized)
                {
                    Identity();
                }
            }
        }
コード例 #11
0
ファイル: Matrix4x4.cs プロジェクト: glocklueng/agg-sharp
        public bool Equals(Matrix4X4 OtherMatrix, double ErrorRange)
        {
	        for(int i=0; i<4; i++)
	        {
		        for(int j=0; j<4; j++)
		        {
			        if(		GetElement(i, j) < OtherMatrix.GetElement(i, j) - ErrorRange
				        ||	GetElement(i, j) > OtherMatrix.GetElement(i, j) + ErrorRange)
			        {
				        return false;
			        }
		        }
	        }

	        return true;
        }
コード例 #12
0
ファイル: Matrix4x4.cs プロジェクト: glocklueng/agg-sharp
        public void AddRotate(uint Axis, double Theta)
        {
            Matrix4X4 Temp = new Matrix4X4();
            Temp.Rotate(Axis, Theta);

            Multiply(Temp);
        }
コード例 #13
0
ファイル: Matrix4x4.cs プロジェクト: glocklueng/agg-sharp
        public void AddTranslate(Vector3 Vect)
        {
            Matrix4X4 Temp = new Matrix4X4();
            Temp.Translate(Vect.x, Vect.y, Vect.z);

            Multiply(Temp);
        }
コード例 #14
0
ファイル: Matrix4x4.cs プロジェクト: glocklueng/agg-sharp
        public bool Invert()
        {
	        Matrix4X4 Temp = new Matrix4X4(this);
	        return SetToInverse(Temp);
        }
コード例 #15
0
        public void Multiply(Matrix4X4 Two)
        {
            Matrix4X4 Hold = new Matrix4X4(this);

            Multiply(Hold, Two);
        }
コード例 #16
0
 public void SetElements(Matrix4X4 CopyFrom)
 {
     SetElements(CopyFrom.GetElements());
 }
コード例 #17
0
ファイル: Matrix4x4.cs プロジェクト: glocklueng/agg-sharp
 public static Matrix4X4 operator *(Matrix4X4 A, Matrix4X4 B)
 {
     Matrix4X4 Temp = new Matrix4X4(A);
     Temp.Multiply(B);
     return Temp;
 }