Files
TeslaRel410/CODE/RP/MUNGA/LINMTRX.CPP
T
CydandClaude Fable 5 fdd9ac9d97 Initial import: Tesla Release 4.10 (Tesla:BattleTech & Tesla:Red Planet)
Archival snapshot of the Virtual World Entertainment Tesla cockpit
software, 1994-1996: MUNGA engine and L4 pod layer source (Borland
C++ 5.0), BT/RP game code, and game content (models, audio, maps,
gauges, Division renderer data). Includes third-party libraries:
Division dVS/DPL graphics, HMI SOS audio, WATTCP networking.

Files are preserved byte-for-byte (.gitattributes disables all
line-ending conversion). README.md documents the layout, target
hardware, and toolchain.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-02 13:21:58 -05:00

166 lines
4.4 KiB
C++

//===========================================================================//
// 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 <munga.hpp>
#pragma hdrstop
#if !defined(LINMTRX_HPP)
# include <linmtrx.hpp>
#endif
#if !defined(MATRIX_HPP)
# include <matrix.hpp>
#endif
#if !defined(LINMTRX_HPP)
#include <linmtrx.hpp>
#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