//===========================================================================// // File: angle.tst // // Project: MUNGA Brick: Math Library // // Contents: Tests 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" // //############################################################################# //############################################################################# // bool Radian::TestClass() { SPEW((GROUP_STUFF_TEST, "Starting Radian Test...")); const Radian a(1.25f); Radian b,c; Verify(a); c = 0.0f; Verify(!c); Verify(Normalize(3.1f) == 3.1f); Verify(Normalize(-3.1f) == -3.1f); Scalar f = Normalize(Pi+Pi_Over_2); Verify(Close_Enough(f,Pi_Over_2 - Pi)); f = Normalize(-Pi-Pi_Over_2); Verify(Close_Enough(f,Pi - Pi_Over_2)); c = a; #if 0 Verify(c == a); Verify(c.angle == a); Verify(c == a.angle); #endif b.Negate(c); #if 0 Verify(b == -c.angle); #endif #if 0 b = -c; d.Add(b,c); Verify(d == b.angle + c.angle); Verify(a+b == a.angle + b.angle); Verify(a+c == a.angle + c.angle); Verify(a+1.25f == a.angle+1.25f); Verify(1.25f+c == 1.25f+c.angle); c = 1.5f; d.Subtract(c,a); Verify(d == c.angle - a.angle); Verify(c-a == c.angle - a.angle); Verify(c-1.25f == c.angle - 1.25f); Verify(1.5f-a == 1.5f - a.angle); Verify(c-b == c.angle - b.angle); c = 2.5f; d.Multiply(a,c); Verify(d == a.angle * c.angle); Verify(a*c == a.angle * c.angle); Verify(1.25f*c == 1.25f * c.angle); Verify(a*2.5f == a.angle * 2.5f); Verify(a*b == a.angle * b.angle); c = 2.0f; d.Divide(a,c); Verify(d == a.angle / c.angle); Verify(a/c == a.angle / c.angle); Verify(1.25f/c == 1.25f / c.angle); Verify(a/2.0f == a.angle / 2.0f); Verify(a/b == a.angle / b.angle); b = a; b += c; b.Normalize(); Verify(b == 3.25f - TWO_PI); b += 2.0f; b.Normalize(); Verify(b == 5.25f - TWO_PI); b -= c; b.Normalize(); Verify(b == 3.25f - TWO_PI); b -= 2.0f; b.Normalize(); Verify(b == 1.25f); b *= c; b.Normalize(); Verify(b == 1.25f*2.0f); b *= 2.0f; b.Normalize(); Verify(b == 1.25f*2.0f*2.0f - TWO_PI); b = a*c; b.Normalize(); Verify(b == 1.25f*2.0f); b /= 2.0f; b.Normalize(); Verify(b == 1.25f); b = -3.0f*PI_OVER_4; c = 3.0f*PI_OVER_4; Verify(Lerp(b,c,0.25f) < b); Verify(Normalize(Lerp(b,c,0.75f)) > c); #endif return true; } // //############################################################################# //############################################################################# // bool Degree::TestClass() { SPEW((GROUP_STUFF_TEST, "Starting Degree test...")); const Degree a(Degrees_Per_Radian); Degree b,c; Radian r(1.0f),s; s = a; Verify(r == s); b = r; s = b; #if 0 Verify(r == s); #endif c = Degrees_Per_Radian; s = c; #if 0 Verify(r == s); #endif b = c; s = b; #if 0 Verify(r == s); #endif return true; } // //############################################################################# //############################################################################# // bool SinCosPair::TestClass() { SPEW((GROUP_STUFF_TEST, "Starting SinCos test...")); Radian s,r(Pi_Over_2); SinCosPair a; a = r; Verify(Close_Enough(a.sine,1.0f)); Verify(Small_Enough(a.cosine)); s = a; Verify(s == r); return true; }