#ifndef DAEDALUS_MATH_H #define DAEDALUS_MATH_H /****************************************************************************** * 4x4 matrix ******************************************************************************/ typedef struct _D3DMATRIX { union { struct { float _11, _12, _13, _14; float _21, _22, _23, _24; float _31, _32, _33, _34; float _41, _42, _43, _44; }; float m[4][4]; }; } D3DMATRIX; typedef struct D3DXMATRIX : public D3DMATRIX { public: D3DXMATRIX(); D3DXMATRIX( const float * ); D3DXMATRIX( const D3DMATRIX & ); D3DXMATRIX( float _11, float _12, float _13, float _14, float _21, float _22, float _23, float _24, float _31, float _32, float _33, float _34, float _41, float _42, float _43, float _44 ); float& operator () ( uint Row, uint Col ); float operator () ( uint Row, uint Col ) const; operator float* (); operator const float* () const; // assignment operators D3DXMATRIX& operator *= ( const D3DXMATRIX & ); D3DXMATRIX& operator += ( const D3DXMATRIX & ); D3DXMATRIX& operator -= ( const D3DXMATRIX & ); D3DXMATRIX& operator *= ( float ); D3DXMATRIX& operator /= ( float ); // unary operators D3DXMATRIX operator + () const; D3DXMATRIX operator - () const; // binary operators D3DXMATRIX operator * ( const D3DXMATRIX & ) const; D3DXMATRIX operator + ( const D3DXMATRIX & ) const; D3DXMATRIX operator - ( const D3DXMATRIX & ) const; D3DXMATRIX operator * ( float ) const; D3DXMATRIX operator / ( float ) const; friend D3DXMATRIX operator * ( float, const D3DXMATRIX & ); bool operator == ( const D3DXMATRIX & ) const; bool operator != ( const D3DXMATRIX & ) const; } D3DXMATRIX, *LPD3DXMATRIX; /****************************************************************************** * 3d vector ******************************************************************************/ typedef struct _D3DVECTOR { float x; float y; float z; } D3DVECTOR, D3DVECTOR3; class D3DXVECTOR3 : public D3DVECTOR3 { public: D3DXVECTOR3(); D3DXVECTOR3( const float *f ); D3DXVECTOR3( const D3DVECTOR3 &v ); D3DXVECTOR3( float _x, float _y, float _z ); // casting inline operator float* (); inline operator const float* () const; // assignment operators inline D3DXVECTOR3& operator += ( const D3DXVECTOR3 &op ); inline D3DXVECTOR3& operator -= ( const D3DXVECTOR3 &op ); inline D3DXVECTOR3& operator *= ( float op ); inline D3DXVECTOR3& operator /= ( float op ); // unary operators inline D3DXVECTOR3 operator + () const; inline D3DXVECTOR3 operator - () const; // binary operators inline D3DXVECTOR3 operator + ( const D3DXVECTOR3 &op ) const; inline D3DXVECTOR3 operator - ( const D3DXVECTOR3 &op ) const; inline D3DXVECTOR3 operator * ( float op ) const; inline D3DXVECTOR3 operator / ( float op ) const; friend D3DXVECTOR3 operator * ( float, const D3DXVECTOR3& ); inline bool operator == ( const D3DXVECTOR3 &op ) const; inline bool operator != ( const D3DXVECTOR3 &op ) const; }; /****************************************************************************** * 4d vector ******************************************************************************/ typedef struct _D3DVECTOR4 { float x; float y; float z; float w; } D3DVECTOR4; class D3DXVECTOR4 : public D3DVECTOR4 { public: D3DXVECTOR4(); D3DXVECTOR4( const float *f ); D3DXVECTOR4( const D3DVECTOR4 &v ); D3DXVECTOR4( float _x, float _y, float _z, float _w ); // casting inline operator float* (); inline operator const float* () const; // assignment operators inline D3DXVECTOR4& operator += ( const D3DXVECTOR4 &op ); inline D3DXVECTOR4& operator -= ( const D3DXVECTOR4 &op ); inline D3DXVECTOR4& operator *= ( float op ); inline D3DXVECTOR4& operator /= ( float op ); // unary operators inline D3DXVECTOR4 operator + () const; inline D3DXVECTOR4 operator - () const; // binary operators inline D3DXVECTOR4 operator + ( const D3DXVECTOR4 &op ) const; inline D3DXVECTOR4 operator - ( const D3DXVECTOR4 &op ) const; inline D3DXVECTOR4 operator * ( float op ) const; inline D3DXVECTOR4 operator / ( float op ) const; friend D3DXVECTOR4 operator * ( float, const D3DXVECTOR4& ); inline bool operator == ( const D3DXVECTOR4 &op ) const; inline bool operator != ( const D3DXVECTOR4 &op ) const; }; D3DXVECTOR4 WINAPI D3DXVec3Transform( D3DXVECTOR4 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DXMATRIX *pM ); D3DXMATRIX* D3DXMatrixTranspose( D3DXMATRIX* pOut, CONST D3DXMATRIX* pM ); #endif