/****************************************************************************************************

		Complex.h
		Copyright: (c) 2001 Eovia Corp. All rights reserved.

		Author:	Arnaud
		Date:	1/31/2006

****************************************************************************************************/

#ifndef __Complex__
#define __Complex__

#if CP_PRAGMA_ONCE
#pragma once
#endif


#include "MCBasicTypes.h"
#include "Vector2.h"

/// \addtogroup Math
/// \{

/// Defines a complex number n= x + i*y (i*i= -1)
///
struct TComplex : public TVector2
{
	inline	TComplex	() : TVector2(0.0f, 0.0f)		{}
	inline	TComplex	(const real xx, const real yy)	: TVector2(xx, yy)			{}
	inline	TComplex	(const TVector2& val)			: TVector2(val.x, val.y)	{}
	

	inline	TComplex	GetConjugate	() const		{ return TComplex(x, -y); }
	inline	void		Conjugate		() 				{ y= -y; }

	inline TComplex& operator*= (const TComplex& b)
	{ SetValues(x*b.x - y*b.y, x*b.y + y*b.x); return (*this); }

	inline static TComplex Exp			(real val)		{ return TComplex(RealCos(val), RealSin(val)); }
};

/// \}


inline TComplex  operator*  (const TComplex& a, const TComplex& b) 
{ return TComplex(a.x*b.x - a.y*b.y, a.x*b.y + a.y*b.x); }



#endif
