예제 #1
0
 float Matrix4::Determinant() const
 {
    return 
       m[0][0] * MinorDeterminant(1, 2, 3, 1, 2, 3) -
       m[0][1] * MinorDeterminant(1, 2, 3, 0, 2, 3) +
       m[0][2] * MinorDeterminant(1, 2, 3, 0, 1, 3) -
       m[0][3] * MinorDeterminant(1, 2, 3, 0, 1, 2);
 }
예제 #2
0
	static Matrix4x4 MatAdjoint(const Matrix4x4* pkMat)
	{
		// COMMENT : http://www.codeproject.com/csharp/Matrix.asp
		Matrix4x4 kMatRet;
		for(UINT32 r = 0; r < 4; ++r)
		{
			for(UINT32 c = 0; c < 4; ++c)
			{
				kMatRet.m[c][r] = powf(-1.0f, (FLOAT32)(r + c)) * MinorDeterminant(*pkMat, r, c);
			}
		}
		return kMatRet;
	}
예제 #3
0
   Matrix4 Matrix4::Inverse() const
   {
      float minorDeterminant123123 = MinorDeterminant(1, 2, 3, 1, 2, 3);
      float minorDeterminant123023 = MinorDeterminant(1, 2, 3, 0, 2, 3);
      float minorDeterminant123013 = MinorDeterminant(1, 2, 3, 0, 1, 3);
      float minorDeterminant123012 = MinorDeterminant(1, 2, 3, 0, 1, 2);

      float determinant = 
         m[0][0] * minorDeterminant123123 -
         m[0][1] * minorDeterminant123023 +
         m[0][2] * minorDeterminant123013 -
         m[0][3] * minorDeterminant123012;

      Matrix4 adjoint( 
         minorDeterminant123123,
         -MinorDeterminant(0, 2, 3, 1, 2, 3),
         MinorDeterminant(0, 1, 3, 1, 2, 3),
         -MinorDeterminant(0, 1, 2, 1, 2, 3),

         -minorDeterminant123023,
         MinorDeterminant(0, 2, 3, 0, 2, 3),
         -MinorDeterminant(0, 1, 3, 0, 2, 3),
         MinorDeterminant(0, 1, 2, 0, 2, 3),

         minorDeterminant123013,
         -MinorDeterminant(0, 2, 3, 0, 1, 3),
         MinorDeterminant(0, 1, 3, 0, 1, 3),
         -MinorDeterminant(0, 1, 2, 0, 1, 3),

         -minorDeterminant123012,
         MinorDeterminant(0, 2, 3, 0, 1, 2),
         -MinorDeterminant(0, 1, 3, 0, 1, 2),
         MinorDeterminant(0, 1, 2, 0, 1, 2));

      return adjoint * (1.0f / determinant);
   }
예제 #4
0
   Matrix4 Matrix4::Adjoint() const
   {
      return Matrix4( 
         MinorDeterminant(1, 2, 3, 1, 2, 3),
         -MinorDeterminant(0, 2, 3, 1, 2, 3),
         MinorDeterminant(0, 1, 3, 1, 2, 3),
         -MinorDeterminant(0, 1, 2, 1, 2, 3),

         -MinorDeterminant(1, 2, 3, 0, 2, 3),
         MinorDeterminant(0, 2, 3, 0, 2, 3),
         -MinorDeterminant(0, 1, 3, 0, 2, 3),
         MinorDeterminant(0, 1, 2, 0, 2, 3),

         MinorDeterminant(1, 2, 3, 0, 1, 3),
         -MinorDeterminant(0, 2, 3, 0, 1, 3),
         MinorDeterminant(0, 1, 3, 0, 1, 3),
         -MinorDeterminant(0, 1, 2, 0, 1, 3),

         -MinorDeterminant(1, 2, 3, 0, 1, 2),
         MinorDeterminant(0, 2, 3, 0, 1, 2),
         -MinorDeterminant(0, 1, 3, 0, 1, 2),
         MinorDeterminant(0, 1, 2, 0, 1, 2));
   }