Jump to content
  • Advertisement
Sign in to follow this  
RogerThat123

Math Library C++ ?

This topic is 3086 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I need a good math library.
#ifndef __cMATH_H__
#define __cMATH_H__

static const float PI = 3.14159265358979323846f;
static const float PIdiv = 0.01745329251994329576f;
static const float divPI = 57.29577951308232087684f;
static const float M_LN2_f = 0.69314718055994530941723212145818f;
static const float TWO_PI_f = 6.283185307179586476925286766559f;
static const float PI_f = 3.1415926535897932384626433832795f;
static const float HALF_PI_f = 1.5707963267948966192313216916398f;
static const float THIRD_PI_f = 1.0471975511965977461542144610932f;
static const float QUARTER_PI_f = 0.78539816339744830961566084581988f;
static const float QUARTER_QUARTER_PI_f = 0.19634954084936207740391521145497f;
static const float INV_TWO_PI_f = 0.15915494309189533576888376337251f;
static const float INV_PI_f = 0.31830988618379067153776752674503f;
static const float INV_HALF_PI_f = 0.63661977236758134307553505349006f;
static const float INV_THIRD_PI_f= 0.95492965855137201461330258023509f;
static const float INV_QUARTER_PI_f = 1.2732395447351626861510701069801f;
static const float DEG_TO_RAD_f = 0.017453292519943295769236907684886f;
static const float RAD_TO_DEG_f = 57.295779513082320876798154814105f;

class cMaths
{
	public:
		float __fastcall ConvertHalfPiSin(const float fAngle, bool& bNeg);
		float __fastcall ConvertHalfPiCos(const float fAngle, bool& bNeg);
		void __fastcall CalcAngle( Vector &src, Vector &dst, QAngle &angles );
		void Normalize(Vector &vIn, Vector &vOut);
		float __fastcall CheckFOVRatio( QAngle angle, Vector src, Vector dst );
		float __fastcall fastInvSqrt(float fX);
		float __fastcall fastSqrt(float fX);
		float __fastcall fastSin(float fAngle);
		float __fastcall fastCos(float fAngle);
		float __fastcall fastTan(float fAngle);
		float __fastcall fastAsin(float fValue);
		float __fastcall fastAcos(float fValue);
		float __fastcall fastAtan(float fValue);
		float  __fastcall flGetDistance( int index );
		float  __fastcall lGetDistance( Vector vPlayer );
		void MakeVector( QAngle angle, QAngle& vector ) ;
		float GetFov( QAngle angle, Vector src, Vector dst ) ;
		FLOAT GetTime_S(void)	;
		DWORD GetTime_MS(void);
		void MatrixCopy( const matrix3x4_t& in, matrix3x4_t& out );
		void MatrixCopy( const VMatrix& src, VMatrix& dst );
		void VectorCopy(const vec_t *a, vec_t *b);
		void VectorCopy( RadianEuler const& src, RadianEuler &dst );
		void VectorCopy( const QAngle& src, QAngle& dst );
		void VectorAngles( const Vector& forward, QAngle &angles );
		void AngleVectors (const QAngle &angles, Vector *forward);
		void AngleVectors (const QAngle &angles, Vector *forward, Vector *right, Vector *up);
		void VectorTransform (const float *in1, const matrix3x4_t& in2, float *out1);
		void VectorTransform(const Vector& in1, const matrix3x4_t &in2, Vector &out);
		void VectorMA( const Vector& start, float s, const Vector& dir, Vector& result );
		void MatrixGetColumn( const matrix3x4_t& in, int column, Vector &out );
		void MatrixSetColumn( const Vector &in, int column, matrix3x4_t& out );
		void PositionMatrix( const Vector &position, matrix3x4_t &mat );
		void MatrixPosition( const matrix3x4_t &matrix, Vector &position );
		void MatrixAngles( const matrix3x4_t &matrix, QAngle &angles );
		void MatrixAngles( const matrix3x4_t &matrix, QAngle &angles, Vector &position );
		void MatrixAngles( const matrix3x4_t &matrix, RadianEuler &angles );
		void MatrixAngles( const matrix3x4_t& matrix, RadianEuler &angles, Vector &position );
		void MatrixAngles( const matrix3x4_t &matrix, Quaternion &q, Vector &pos );
		void MatrixAngles( const matrix3x4_t& matrix, float *angles );
		void AngleMatrix( RadianEuler const &angles, const Vector &position, matrix3x4_t& matrix );
		void AngleMatrix( const RadianEuler& angles, matrix3x4_t& matrix );
		void AngleMatrix( const QAngle &angles, const Vector &position, matrix3x4_t& matrix );
		void AngleMatrix( const QAngle &angles, matrix3x4_t& matrix );
		void  AngleIMatrix( const RadianEuler& angles, matrix3x4_t& matrix );
		void  AngleIMatrix (const QAngle& angles, matrix3x4_t& matrix );
		void  AngleIMatrix (const QAngle &angles, const Vector &position, matrix3x4_t &mat );
		void  VectorRotate( const float *in1, const matrix3x4_t& in2, float *out1 );
		void  VectorRotate( const Vector &in1, const matrix3x4_t& in2, Vector &out );
		void VectorCopy( const Vector& src, Vector& dst );
		void  AngleQuaternion( const QAngle &angles, Quaternion &outQuat );
		void  AxisAngleQuaternion( const Vector &axis, float angle, Quaternion &q );
		void  AngleQuaternion( RadianEuler const &angles, Quaternion &outQuat );
		void  _SinCos( float radians, float *sine, float *cosine );
		float  _sin(float x);
		float  _cos(float x);
		float  _acos(float x);
		double  _atan(double x);
		double  _atan2(double x,double xx);
		float  _fmodf(float x,float xx);
		int  _itoa(int i, char *s);
		float  _sqrtf(float x);
		float VectorNormalize(Vector& vec);
		void  VectorNormalize_Spinbot( Vector &vIn, Vector &vOut);
		void  VectorAdd( const Vector& a, const Vector& b, Vector& c );
		void  VectorSubtract( const Vector& a, const Vector& b, Vector& c );
		void  CrossProduct(const Vector& a, const Vector& b, Vector& result );
		float  DotProduct(const float v1[3], const float v2[3]);
		float  DotProduct(const Vector& a, const Vector& b) ;
	//	void VectorNormalize_Spinbot( Vector &vIn, Vector &vOut);
};

extern cMaths m_pMaths;


#endif

I need it to contain the classes in here, vectors, matrix, qangle and more. I tried many but they dont work. I need to include it in this header file above. Please help

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!