//===========================================================================//
// File:	origin.hh                                                           //
// Project: MUNGA           Brick: Math Library                              //
// Contents: Implementation details for the position class                   //
//---------------------------------------------------------------------------//
//   Date    Who  Modification                                               //
// --------  ---  ---------------------------------------------------------- //
// 11/19/94  JMA  Initial coding.                                            //
// 11/29/94  JMA  Added origin concatenation                                 //
//---------------------------------------------------------------------------//
// Copyright (C) 1994-1995, Virtual World Entertainment, Inc.                //
// All Rights reserved worldwide                                             //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL               //
//===========================================================================//

#if !defined(ORIGIN_HPP)
#	define ORIGIN_HPP

#	if !defined(POINT3D_HPP)
#		include <point3d.hpp>
#	endif

#	if !defined(ROTATION_HPP)
#		include <rotation.hpp>
#	endif

	class Motion;

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Origin ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

	class Origin
	{
		#if defined(USE_SIGNATURE)
			friend int
				Is_Signature_Bad(const volatile Origin *);
		#endif

	 public:
		Point3D
			linearPosition;
		Quaternion
			angularPosition;

		static const Origin
			Identity;

		//
		// Constructors
		//
		Origin()
			{}
		Origin(
			const Point3D &t,
			const EulerAngles& q
		)
			{Check(&t); Check(&q); linearPosition = t; angularPosition = q;}
		Origin(
			const Point3D &t,
			const Quaternion& q
		)
			{Check(&t); Check(&q); linearPosition = t; angularPosition = q;}
		Origin(const LinearMatrix &matrix);

		//
		// Assignment operators
		//
		Origin&
			operator=(const Origin& p);
		Origin&
			operator=(const Point3D& p)
				{Check_Pointer(this); Check(&p); linearPosition = p; return *this;}
		Origin&
			operator=(const EulerAngles& q)
				{Check_Pointer(this); Check(&q); angularPosition = q; return *this;}
		Origin&
			operator=(const YawPitchRoll& q)
				{Check_Pointer(this); Check(&q); angularPosition = q; return *this;}
		Origin&
			operator=(const Quaternion& q)
				{Check_Pointer(this); Check(&q); angularPosition = q; return *this;}
		Origin&
			operator=(const LinearMatrix &m);

		//
		// Equality operator
		//
		Logical
			operator==(const Origin&) const;

		//
		// Origin motion
		//
		Origin&
			AddScaled(
				const Origin& source,
				const Motion& delta,
				Scalar t
			);
		Origin&
			Lerp(
				const Origin& start,
				const Origin& end,
				Scalar t
			);

		//
		// Support functions
		//
		friend ostream&
			operator<<(
				ostream& stream,
				const Origin& p
			);
		Logical
			TestInstance() const;
		static Logical
			TestClass();
	};

	inline Point3D&
		Point3D::operator=(const Origin& p)
			{return operator=(p.linearPosition);}

	inline EulerAngles&
		EulerAngles::operator=(const Origin& p)
			{return operator=(p.angularPosition);}

	inline Quaternion&
		Quaternion::operator=(const Origin& p)
			{return operator=(p.angularPosition);}

#endif

