Files
Cyd 2b8ca921cb Initial full mirror of c:\VWE (source + assets + toolchain + outputs) via Git LFS
Complete disaster-recovery snapshot: engine/game source, game data assets,
VC6 toolchain + DX SDKs, build outputs, deployed game, and _UNUSED archive.
Large binaries in Git LFS; text preserved byte-for-byte (core.autocrlf=false,
no eol attributes). See RECOVERY.md for the one-clone rebuild procedure.
2026-06-24 21:28:16 -05:00

157 lines
3.8 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 "StuffHeaders.hpp"
//
//#############################################################################
//#############################################################################
//
Scalar
Radian::Normalize(Scalar Value)
{
Scalar temp = static_cast<Scalar>(fmod(Value,Two_Pi));
if (temp > Pi)
{
temp -= Two_Pi;
}
else if (temp <= -Pi)
{
temp += Two_Pi;
}
return temp;
}
//
//#############################################################################
//#############################################################################
//
Radian&
Radian::Normalize()
{
Check_Object(this);
angle = static_cast<Scalar>(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_Object(&a);
Check_Object(&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 = Stuff::Lerp(a1, a2, t);
return *this;
}
#if 0
SinCosPair&
SinCosPair::operator=(const Radian &radian)
{
Check_Pointer(this);
Check_Object(&radian);
#if USE_ASSEMBLER_CODE
Scalar *f = &sine;
_asm {
push ebx
push edx
mov ebx, f
mov edx, radian.angle
fld dword ptr [edx]
fsincos
fstp dword ptr [ebx + 4]
fstp dword ptr [ebx]
pop edx
pop ebx
}
#else
cosine = cos(radian);
sine = sin(radian);
#endif
Check_Object(this);
return *this;
}
#endif
//
//#############################################################################
//#############################################################################
//
#if !defined(Spew)
void
Spew(
const char* group,
const Radian& angle
)
{
Check_Object(&angle);
SPEW((group, "%f rad+", angle.angle));
}
//
//#############################################################################
//#############################################################################
//
void
Spew(
const char* group,
const Degree& angle
)
{
Check_Object(&angle);
SPEW((group, "%f deg+", angle.angle));
}
//
//#############################################################################
//#############################################################################
//
void
Spew(
const char* group,
const SinCosPair& angle
)
{
Check_Object(&angle);
SPEW((group, "{%f,%f}+", angle.cosine, angle.sine));
}
#endif