//===========================================================================//
// File:	unitvec.hh                                                          //
// Project: MUNGA           Brick: Math Library                              //
// Contents: Interface specification for unit vector class                   //
//---------------------------------------------------------------------------//
//   Date    Who  Modification                                               //
// --------  ---  ---------------------------------------------------------- //
// 11/19/94  JMA  Initial coding.                                            //
// 12/01/94  JMA  Made compatible with SGI CC                                //
//---------------------------------------------------------------------------//
// Copyright (C) 1994-1995, Virtual World Entertainment, Inc.                //
// All Rights reserved worldwide                                             //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL               //
//===========================================================================//

#if !defined(UNITVEC_HPP)
#	define UNITVEC_HPP

#	if !defined(VECTOR3D_HPP)
#		include <vector3d.hpp>
#	endif

	//~~~~~~~~~~~~~~~~~~~~~~~~~~ UnitVector ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

	class LinearMatrix;

	class UnitVector:
		public Vector3D
	{
	public:
		//
		// Constructors
		//
		UnitVector()
			{}
		UnitVector(
			Scalar x,
			Scalar y,
			Scalar z
		):
			Vector3D(x,y,z)
				{}

		//
		// Assignment operators
		//
		UnitVector&
			operator=(const UnitVector &vector)
				{Check(&vector); Vector3D::operator=(vector); return *this;}
		UnitVector&
			operator=(const Vector3D& v)
				{Vector3D::Normalize(v); return *this;}

		//
		// Math operations
		//
		UnitVector&
			Negate(const UnitVector &v)
				{Check(&v); Vector3D::Negate(v); return *this;}

		Scalar
			operator*(const Vector3D& v) const
				{return Vector3D::operator*(v);}

		//
		// Transforms
		//
		UnitVector& Multiply(
			const UnitVector &v,
			const LinearMatrix &m
		);
		UnitVector&
			operator*=(const LinearMatrix &m);
		UnitVector&
			MultiplyByInverse(
				const UnitVector &v,
				const LinearMatrix &m
			)
				{Vector3D::MultiplyByInverse(v,m); return *this;}

		//
		// Template support
		//
		UnitVector&
			Lerp(
				const UnitVector& v1,
				const UnitVector& v2,
				Scalar t
			);

		//
		// Support functions
		//
		Logical
			TestInstance() const;
		static Logical
			TestClass();

	private:
		static const UnitVector identity;
		UnitVector& Negate(const Vector3D &V);
		UnitVector& Add(const Vector3D& V1,const Vector3D& V2);
		UnitVector& operator+=(const Vector3D& V);
		UnitVector& Subtract(const Vector3D& V1,const Vector3D& V2);
		UnitVector& operator-=(const Vector3D& V);
		UnitVector& Cross(const Vector3D& V1,const Vector3D& V2);
		UnitVector& Multiply(const Vector3D& V,Scalar Scale);
		UnitVector& operator*=(Scalar Value);
		UnitVector& Multiply(const Vector3D& V1,const Vector3D& V2);
		UnitVector& operator*=(const Vector3D &V);
		UnitVector& Multiply(const Vector3D &Source, const AffineMatrix &M);
		UnitVector& MultiplyByInverse(const Vector3D &Source, const LinearMatrix &M);
		UnitVector& Divide(const Vector3D& V,Scalar Scale);
		UnitVector& operator/=(Scalar Value);
		UnitVector& Combine(const Vector3D& V1,Scalar t1,const Vector3D& V2,Scalar t2);
	};

#endif
