//===========================================================================// // 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 // //===========================================================================// // //############################################################################# //############################################################################# // Logical Radian::TestClass() { DEBUG_STREAM << "Starting Radian Test...\n"; const Radian a(1.25f); Radian b,c; Test(a); c = 0.0f; Test(!c); Test(Normalize(3.1f) == 3.1f); Test(Normalize(-3.1f) == -3.1f); Scalar f = Normalize(PI+PI_OVER_2); Test(Close_Enough(f,PI_OVER_2 - PI)); f = Normalize(-PI-PI_OVER_2); Test(Close_Enough(f,PI - PI_OVER_2)); c = a; Test(c == a); Test(c.angle == a); Test(c == a.angle); b.Negate(c); Test(b == -c.angle); #if 0 b = -c; d.Add(b,c); Test(d == b.angle + c.angle); Test(a+b == a.angle + b.angle); Test(a+c == a.angle + c.angle); Test(a+1.25f == a.angle+1.25f); Test(1.25f+c == 1.25f+c.angle); c = 1.5f; d.Subtract(c,a); Test(d == c.angle - a.angle); Test(c-a == c.angle - a.angle); Test(c-1.25f == c.angle - 1.25f); Test(1.5f-a == 1.5f - a.angle); Test(c-b == c.angle - b.angle); c = 2.5f; d.Multiply(a,c); Test(d == a.angle * c.angle); Test(a*c == a.angle * c.angle); Test(1.25f*c == 1.25f * c.angle); Test(a*2.5f == a.angle * 2.5f); Test(a*b == a.angle * b.angle); c = 2.0f; d.Divide(a,c); Test(d == a.angle / c.angle); Test(a/c == a.angle / c.angle); Test(1.25f/c == 1.25f / c.angle); Test(a/2.0f == a.angle / 2.0f); Test(a/b == a.angle / b.angle); b = a; b += c; b.Normalize(); Test(b == 3.25f - TWO_PI); b += 2.0f; b.Normalize(); Test(b == 5.25f - TWO_PI); b -= c; b.Normalize(); Test(b == 3.25f - TWO_PI); b -= 2.0f; b.Normalize(); Test(b == 1.25f); b *= c; b.Normalize(); Test(b == 1.25f*2.0f); b *= 2.0f; b.Normalize(); Test(b == 1.25f*2.0f*2.0f - TWO_PI); b = a*c; b.Normalize(); Test(b == 1.25f*2.0f); b /= 2.0f; b.Normalize(); Test(b == 1.25f); b = -3.0f*PI_OVER_4; c = 3.0f*PI_OVER_4; Test(Lerp(b,c,0.25f) < b); Test(Normalize(Lerp(b,c,0.75f)) > c); #endif return True; } // //############################################################################# //############################################################################# // Logical Degree::TestClass() { DEBUG_STREAM << "Starting Degree test...\n"; const Degree a(DEG_PER_RAD); Degree b,c; Radian r(1.0f),s; s = a; Test(r == s); b = r; s = b; Test(r == s); c = DEG_PER_RAD; s = c; Test(r == s); b = c; s = b; Test(r == s); return True; } // //############################################################################# //############################################################################# // Logical SinCosPair::TestClass() { DEBUG_STREAM << "Starting SinCos test...\n"; Radian s,r(PI_OVER_2); SinCosPair a; a = r; Test(Close_Enough(a.sine,1.0f)); Test(Small_Enough(a.cosine)); s = a; Test(s == r); return True; }