//===========================================================================// // File: linmtrx.cc // // Project: MUNGA Brick: Math Library // // Contents: Implementation details for the linear matrices // //---------------------------------------------------------------------------// // Date Who Modification // // -------- --- ---------------------------------------------------------- // // 11/20/94 JMA Initial coding. // //---------------------------------------------------------------------------// // Copyright (C) 1994-1995, Virtual World Entertainment, Inc. // // All Rights reserved worldwide // // This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL // //===========================================================================// #include #pragma hdrstop #if !defined(LINMTRX_HPP) # include #endif #if !defined(MATRIX_HPP) # include #endif #if !defined(LINMTRX_HPP) #include #endif 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