#include "munga.h" #pragma hdrstop #include "linmtrx.h" #include "matrix.h" #include "linmtrx.h" const LinearMatrix LinearMatrix::Identity(true); LinearMatrix& LinearMatrix::operator=(const AffineMatrix &m) { // // Make sure to test linearness on m // AffineMatrix::operator=(m); return *this; } // //########################################################################### //########################################################################### // LinearMatrix& LinearMatrix::operator=(const Matrix4x4 &m) { // // Make sure to test linearness on m // AffineMatrix::operator=(m); return *this; } // //########################################################################### //########################################################################### // LinearMatrix& LinearMatrix::operator=(const TransposedMatrix &m) { // // Make sure to test linearness on m // AffineMatrix::operator=(m); return *this; } // //########################################################################### //########################################################################### // LinearMatrix& LinearMatrix::Invert(const LinearMatrix& Source) { // //----------------------------------------- // First, transpose the 3x3 rotation matrix //----------------------------------------- // (*this)(0,0) = Source(0,0); (*this)(0,1) = Source(1,0); (*this)(0,2) = Source(2,0); (*this)(1,0) = Source(0,1); (*this)(1,1) = Source(1,1); (*this)(1,2) = Source(2,1); (*this)(2,0) = Source(0,2); (*this)(2,1) = Source(1,2); (*this)(2,2) = Source(2,2); // //---------------------------- // Now run the offsets through //---------------------------- // (*this)(3,0) = -Source(3,0)*Source(0,0) -Source(3,1)*Source(0,1) -Source(3,2)*Source(0,2); (*this)(3,1) = -Source(3,0)*Source(1,0) -Source(3,1)*Source(1,1) -Source(3,2)*Source(1,2); (*this)(3,2) = -Source(3,0)*Source(2,0) -Source(3,1)*Source(2,1) -Source(3,2)*Source(2,2); return *this; } // //########################################################################### //########################################################################### // LinearMatrix& LinearMatrix::Normalize() { (*this)(0,2) = (*this)(1,0)*(*this)(2,1) - (*this)(1,1)*(*this)(2,0); (*this)(1,2) = (*this)(2,0)*(*this)(0,1) - (*this)(2,1)*(*this)(0,0); (*this)(2,2) = (*this)(0,0)*(*this)(1,1) - (*this)(0,1)*(*this)(1,0); return *this; } // //########################################################################### //########################################################################### // Logical LinearMatrix::TestInstance() const { UnitVector v1; GetFromAxis(X_Axis,&v1); if (!v1.TestInstance()) { Dump(*this); Dump(v1); return False; } UnitVector v2; GetFromAxis(Y_Axis,&v2); if (!v2.TestInstance()) { Dump(*this); Dump(v1); return False; } UnitVector v3; v3.Vector3D::Cross(v1,v2); GetFromAxis(Z_Axis,&v1); return Close_Enough(v1,v3); } #if defined(TEST_CLASS) #include "linmtrx.tcp" #endif