/****************************************************************************
*
* MATHS.H
*
* PROGRAMMER : Chris
*    VERSION : 00.02
*    CREATED : 19/11/97
*   MODIFIED : 19/11/97
*       TABS : 5
*
* DESCRIPTION
*	Header file for MATHS.C
*
*****************************************************************************/

#ifndef _MATHS_H
#define _MATHS_H

/*---------------------------------------------------------------------------
 *	Import Headers
\*--------------------------------------------------------------------------*/

#include "types.h"

/*---------------------------------------------------------------------------
 *	Constants
\*--------------------------------------------------------------------------*/

#define MAX_NESTED_MATRICES	32

/*---------------------------------------------------------------------------
 *	Type Definitions
\*--------------------------------------------------------------------------*/

typedef struct {
	LONG x, y, z;
}VECTOR3D;

typedef struct {
	WORD x, y, z;
	WORD pad;
}SVECTOR3D;

typedef struct {
	WORD m00, m01, m02;
	WORD m10, m11, m12;
	WORD m20, m21, m22;
	WORD pad;
	LONG tx, ty, tz;
}MATRIX3D;

/*---------------------------------------------------------------------------
 *	Prototypes
\*--------------------------------------------------------------------------*/

extern void mPushMatrix();
extern void mPopMatrix();

extern void mPushUnitMatrix();
extern void mTransposeMatrix();
extern void mTransposeMatrixGTE();

extern void mRotX(LONG ang);
extern void mRotY(LONG ang);
extern void mRotZ(LONG ang);

extern void mTranslate(VECTOR3D *pos);
extern void mTranslateXYZ(long x, long y, long z);
extern void mTranslateAbsXYZ(long x, long y, long z);

extern void mLoadMatrix(MATRIX3D *);

extern LONG mGetAngle(LONG x1, LONG y1, LONG x2, LONG y2);

extern LONG mSqrt(LONG n);

extern void mInitW2VMatrix(VECTOR3D *pos, VECTOR3D *target);

extern MATRIX3D *Matrix;
extern MATRIX3D iMatrixStack[];
extern SVECTOR3D CamRot;

extern LONG atanOctantTab[];
extern WORD atanTab[];

extern void mRotYXZ(LONG x, LONG y, LONG z);
extern void mRotPackedYXZ(LONG xyz);
extern void mRotSuperPackedYXZ(WORD **pp, LONG skip);

extern void mSetTrans(LONG, LONG, LONG);
extern void mCopyMatrix(MATRIX3D *);

extern LONG mClipBoundingBox(UWORD *);

/* -------- interpolation functions */

extern void InitInterpolation(LONG, LONG, MATRIX3D *);
extern void InterpolateMatrix();
extern void InterpolateArmMatrix(MATRIX3D *);

extern void iPushMatrix();
extern void iPopMatrix();
extern void iRotX(LONG ang);
extern void iRotY(LONG ang);
extern void iRotZ(LONG ang);
extern void iTranslateXYZ(LONG x, LONG y, LONG z);
extern void iTranslateXYZ2(LONG x, LONG y, LONG z, LONG x2, LONG y2, LONG z2);
extern void iRotYXZ(LONG y, LONG x, LONG z);
extern void iRotPackedYXZ(LONG ang);
extern void iRotSuperPackedYXZ(WORD **pp, LONG skip);

extern void iLoadMatrix(MATRIX3D *);
extern MATRIX3D *iMatrix;

/* -------- these shouldn't be global !! */

extern UWORD MatrixSP;
extern MATRIX3D MatrixStack[MAX_NESTED_MATRICES];

/* -------- End */
#endif


