/**
* Quaternion
* @version: 01-30-2005
* @original author: Jim 'Entropy' Hunter
* @revised by: Joseph 'Pcjoe' Florencio
*/

#ifndef QUATERNION_H
#define QUATERNION_H
#include "../cl_dll/util_vector.h"

void QuaternionRotate(const float * anglesIn, const float * deltaAngles, float * anglesOut);

class CQuaternion
{
public:
	CQuaternion( );
	CQuaternion( const float *angles );
	CQuaternion( double dw,double dx ,double dy,double dz );
	void Normalize( void );
	void Multiply( const CQuaternion q1 );
	void Conjugate( void );
	void VectorToQuaternion( const float *vector );
	void EulerToQuaternion( const float *angles );
	vec3_t QuaternionToEuler( void );
	void FromAxisAndAngle( const float *axis, const float angle );
	vec3_t PointRotate( const float *point );
	void QuaternionToMatrix( float (*matrix)[4] );
	void MatrixToQuaternion( float matrix[3][4] );
	void QuaternionSlerp( CQuaternion p, CQuaternion q, double t );

	operator double *()								{ return &x; } // Quaternions will now automatically convert to double * when needed
	operator const double *() const					{ return &x; } // Quaternions will now automatically convert to double * when needed

	// Accessors
	void setQuaternion( double dw,double dx ,double dy,double dz );
	void setQuaternion( CQuaternion q );

public:
	double x;
	double y;
	double z;
	double w;
};
#endif