//===========================================================================// // File: unitvec.tst // // Project: MUNGA Brick: Math Library // // Contents: Implementation details for unit vector class // //---------------------------------------------------------------------------// // 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 // //===========================================================================// #if !defined(LINMTRX_HPP) #include #endif #if !defined(ROTATION_HPP) #include #endif // //########################################################################### //########################################################################### // Logical UnitVector::TestClass() { DEBUG_STREAM << "Starting UnitVector test...\n"; UnitVector b; const UnitVector c(0.6f,0.0f,0.8f); UnitVector d(0.8f,-0.6f,0.0f); Test(c.x == 0.6f && c.y == 0.0f && c.z == 0.8f); Test(c[2] == c.z); b = c; Test(b.x == c.x && b.y == c.y && b.z == c.z); Test(Close_Enough(b,c)); Test(b == c); b.Negate(c); Test(b == UnitVector(-c.x,-c.y,-c.z)); Scalar f = c*d; Test(Close_Enough(f,c.x*d.x + c.y*d.y + c.z*d.z)); LinearMatrix m; EulerAngles r(PI_OVER_4,0.0f,0.0f); m = r; b.Multiply(c,m); Test(b == UnitVector(c.x,c.y*m(1,1)+c.z*m(2,1),c.y*m(1,2)+c.z*m(2,2))); b = c; b *= m; Test(b == UnitVector(c.x,c.y*m(1,1)+c.z*m(2,1),c.y*m(1,2)+c.z*m(2,2))); f = c.LengthSquared(); Test(f == 1.0f); f = c.Length(); Test(f == 1.0f); Vector3D v(0.0f,1.2f,1.6f); f = v.Length(); b = v; Test(b == UnitVector(v.x/f, v.y/f, v.z/f)); return True; }