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>
206 lines
4.9 KiB
C++
206 lines
4.9 KiB
C++
//===========================================================================//
|
|
// File: angle.cc //
|
|
// Project: MUNGA Brick: Math Library //
|
|
// Contents: Implementation details for angle classes //
|
|
//---------------------------------------------------------------------------//
|
|
// Date Who Modification //
|
|
// -------- --- ---------------------------------------------------------- //
|
|
// 11/19/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(ANGLE_HPP)
|
|
#include <angle.hpp>
|
|
#endif
|
|
|
|
#if defined(USE_SIGNATURE)
|
|
int
|
|
Is_Signature_Bad(const volatile Radian *)
|
|
{
|
|
return False;
|
|
}
|
|
#endif
|
|
|
|
//
|
|
//#############################################################################
|
|
//#############################################################################
|
|
//
|
|
Scalar
|
|
Radian::Normalize(Scalar Value)
|
|
{
|
|
Scalar temp;
|
|
|
|
temp = fmod(Value,TWO_PI);
|
|
if (temp > PI) {
|
|
temp -= TWO_PI;
|
|
}
|
|
else if (temp < -PI) {
|
|
temp += TWO_PI;
|
|
}
|
|
return temp;
|
|
}
|
|
|
|
//
|
|
//#############################################################################
|
|
//#############################################################################
|
|
//
|
|
Radian&
|
|
Radian::Normalize()
|
|
{
|
|
Check(this);
|
|
angle = fmod(angle,TWO_PI);
|
|
if (angle > PI) {
|
|
angle -= TWO_PI;
|
|
}
|
|
else if (angle < -PI) {
|
|
angle += TWO_PI;
|
|
}
|
|
return *this;
|
|
}
|
|
|
|
//
|
|
//#############################################################################
|
|
//#############################################################################
|
|
//
|
|
Radian&
|
|
Radian::Lerp(const Radian &a,const Radian &b,Scalar t)
|
|
{
|
|
Scalar a1,a2;
|
|
|
|
Check_Pointer(this);
|
|
Check(&a);
|
|
Check(&b);
|
|
a1 = Radian::Normalize(a.angle);
|
|
a2 = Radian::Normalize(b.angle);
|
|
if (a2-a1 > PI) {
|
|
a2 -= TWO_PI;
|
|
}
|
|
else if (a2-a1 < -PI) {
|
|
a2 += TWO_PI;
|
|
}
|
|
angle = ::Lerp(a1, a2, t);
|
|
return *this;
|
|
}
|
|
|
|
//
|
|
//#############################################################################
|
|
//#############################################################################
|
|
//
|
|
ostream&
|
|
operator<<(
|
|
ostream& stream,
|
|
const Radian& radian
|
|
)
|
|
{
|
|
return stream << radian.angle << " rad";
|
|
}
|
|
|
|
//
|
|
//#############################################################################
|
|
//#############################################################################
|
|
//
|
|
Logical
|
|
Radian::TestInstance() const
|
|
{
|
|
return angle >= -100.0f && angle <= 100.0f;
|
|
}
|
|
|
|
#if defined(USE_SIGNATURE)
|
|
int
|
|
Is_Signature_Bad(const volatile Degree *)
|
|
{
|
|
return False;
|
|
}
|
|
#endif
|
|
|
|
//
|
|
//#############################################################################
|
|
//#############################################################################
|
|
//
|
|
ostream&
|
|
operator<<(
|
|
ostream& stream,
|
|
const Degree& degree
|
|
)
|
|
{
|
|
return stream << degree.angle << " deg";
|
|
}
|
|
|
|
//
|
|
//#############################################################################
|
|
//#############################################################################
|
|
//
|
|
Logical
|
|
Degree::TestInstance() const
|
|
{
|
|
return True;
|
|
}
|
|
|
|
#if defined(USE_SIGNATURE)
|
|
int
|
|
Is_Signature_Bad(const volatile SinCosPair *)
|
|
{
|
|
return False;
|
|
}
|
|
#endif
|
|
|
|
//
|
|
//#############################################################################
|
|
//#############################################################################
|
|
//
|
|
SinCosPair&
|
|
SinCosPair::operator=(const Radian &radian)
|
|
{
|
|
Check_Pointer(this);
|
|
Check(&radian);
|
|
|
|
cosine = cos(radian);
|
|
sine = sin(radian);
|
|
#if defined(__BCPLUSPLUS__)
|
|
cosine = cos(radian); // STUPID FUCKING BORLAND LIBRARY HACK!!!!!
|
|
#endif
|
|
Check(this);
|
|
return *this;
|
|
}
|
|
|
|
//
|
|
//#############################################################################
|
|
//#############################################################################
|
|
//
|
|
ostream&
|
|
operator<<(
|
|
ostream& stream,
|
|
const SinCosPair& pair
|
|
)
|
|
{
|
|
return stream << '{' << pair.cosine << ',' << pair.sine << '}';
|
|
}
|
|
|
|
//
|
|
//#############################################################################
|
|
//#############################################################################
|
|
//
|
|
Logical
|
|
SinCosPair::TestInstance() const
|
|
{
|
|
Scalar t = sine*sine + cosine*cosine;
|
|
if (!Close_Enough(t,1.0f,0.001f))
|
|
{
|
|
Dump(*this);
|
|
Dump(t);
|
|
return False;
|
|
}
|
|
return True;
|
|
}
|
|
|
|
#if defined(TEST_CLASS)
|
|
# include "angle.tcp"
|
|
#endif
|
|
|