SharpMath.float4x4.Invert C# (CSharp) 메소드

Invert() 공개 메소드

public Invert ( ) : float4x4
리턴 float4x4
        public float4x4 Invert()
        {
            float	fDet = Determinant();
            if ( (float) System.Math.Abs(fDet) < float.Epsilon )
                throw new MatrixException( "Matrix is not invertible!" );		// The matrix is not invertible! Singular case!

            float	fIDet = 1.0f / fDet;

            float4x4	Temp = new float4x4();
            Temp.m[0, 0] = CoFactor( 0, 0 ) * fIDet;
            Temp.m[1, 0] = CoFactor( 0, 1 ) * fIDet;
            Temp.m[2, 0] = CoFactor( 0, 2 ) * fIDet;
            Temp.m[3, 0] = CoFactor( 0, 3 ) * fIDet;
            Temp.m[0, 1] = CoFactor( 1, 0 ) * fIDet;
            Temp.m[1, 1] = CoFactor( 1, 1 ) * fIDet;
            Temp.m[2, 1] = CoFactor( 1, 2 ) * fIDet;
            Temp.m[3, 1] = CoFactor( 1, 3 ) * fIDet;
            Temp.m[0, 2] = CoFactor( 2, 0 ) * fIDet;
            Temp.m[1, 2] = CoFactor( 2, 1 ) * fIDet;
            Temp.m[2, 2] = CoFactor( 2, 2 ) * fIDet;
            Temp.m[3, 2] = CoFactor( 2, 3 ) * fIDet;
            Temp.m[0, 3] = CoFactor( 3, 0 ) * fIDet;
            Temp.m[1, 3] = CoFactor( 3, 1 ) * fIDet;
            Temp.m[2, 3] = CoFactor( 3, 2 ) * fIDet;
            Temp.m[3, 3] = CoFactor( 3, 3 ) * fIDet;

            Set( Temp );

            return	this;
        }