glMath.h
资源名称:gloop.zip [点击查看]
上传用户:shxiangxiu
上传日期:2007-01-03
资源大小:1101k
文件大小:4k
源码类别:
OpenGL
开发平台:
Visual C++
- /////////////////////////////////////////////////////////////////////////////
- // glMath.h : Header file; Defines the class definitions
- //
- // glOOP (OpenGL Object Oriented Programming library)
- // Copyright (c) Craig Fahrnbach 1997, 1998
- //
- // OpenGL is a registered trademark of Silicon Graphics
- //
- //
- // This program is provided for educational and personal use only and
- // is provided without guarantee or warrantee expressed or implied.
- //
- // Commercial use is strickly prohibited without written permission
- // from ImageWare Development.
- //
- // This program is -not- in the public domain.
- //
- /////////////////////////////////////////////////////////////////////////////
- #ifndef __GLMATH__
- #define __GLMATH__
- #ifdef __cplusplus
- extern "C" {
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // glMath Definitions:
- //
- #define Pi 3.14159265
- #define PiOver180 1.74532925199433E-002
- #define PiUnder180 5.72957795130823E+001
- #define SMALL_NUMBER 0.00001
- #define LARGE_NUMBER 1E20
- #define X 0 // Used for array index
- #define Y 1
- #define Z 2
- #define W 3
- /////////////////////////////////////////////////////////////////////////////
- // Type Definitions:
- //
- typedef GLfloat VECTORF[4];
- typedef GLdouble Matx4x4[4][4];
- /////////////////////////////////////////////////////////////////////////////
- // External function prototypes:
- //
- // Misc Math Functions
- extern GLfloat Radiansf(GLfloat Angle);
- extern GLfloat Degreesf(GLfloat Angle);
- extern GLfloat Cosf(GLfloat Angle);
- extern GLfloat Sinf(GLfloat Angle);
- extern GLfloat Powerf(GLfloat Base, int Exponent);
- extern GLfloat Sqrf(GLfloat x);
- extern int Roundf(GLfloat x);
- extern GLdouble Radiansd(GLdouble Angle);
- extern GLdouble Degreesd(GLdouble Angle);
- extern GLdouble Cosd(GLdouble Angle);
- extern GLdouble Sind(GLdouble Angle);
- // Vector Functions
- extern void VecClear3f(VECTORF A);
- extern void VecClear4f(VECTORF A);
- extern void Vec3f(GLfloat r, GLfloat s, GLfloat t, VECTORF A);
- extern void UnVec3f(VECTORF A, GLfloat *r, GLfloat *s, GLfloat *t);
- extern void Vec4f(GLfloat r, GLfloat s, GLfloat t, GLfloat u, VECTORF A);
- extern void UnVec4f(VECTORF A, GLfloat *r, GLfloat *s, GLfloat *t, GLfloat *u);
- extern void VecCopy3f(VECTORF A, VECTORF B);
- extern void VecCopy4f(VECTORF A, VECTORF B);
- extern void VecSubf(VECTORF A, VECTORF B, VECTORF C);
- extern void VecAddf(VECTORF A, VECTORF B, VECTORF C);
- extern void VecAdd3f(VECTORF A, VECTORF B, VECTORF C, VECTORF D);
- extern GLfloat VecDiFFf(VECTORF A, VECTORF B);
- extern GLfloat VecDotf(VECTORF A, VECTORF B);
- extern void VecCrossf(VECTORF A, VECTORF B, VECTORF C);
- extern GLfloat VecLenf(VECTORF A);
- extern void VecNormalizef(VECTORF A);
- extern void CalNormalf(VECTORF A, VECTORF B, VECTORF C, VECTORF N);
- // Affine Matrix Transformation Funcitons
- extern void ZeroMatrix(Matx4x4 A);
- extern void Translate3D(float tx, float ty, float tz, Matx4x4 A);
- extern void Scale3D(float sx, float sy, float sz, Matx4x4 A);
- extern void Rotate3D(int m, float Theta, Matx4x4 A);
- extern void MultiplyMatricies(Matx4x4 A, Matx4x4 B, Matx4x4 C);
- extern void MatrixCopy(Matx4x4 A, Matx4x4 B);
- extern void TransposeMatrix(Matx4x4 A);
- extern void PrepareMatrix(float Px, float Py, float Pz,
- float Sx, float Sy, float Sz,
- float Rx, float Ry, float Rz,
- float Tx, float Ty, float Tz,
- Matx4x4 XForm);
- extern void PrepareInvMatrix(float Px, float Py, float Pz,
- float Sx, float Sy, float Sz,
- float Rx, float Ry, float Rz,
- float Tx, float Ty, float Tz,
- Matx4x4 XForm);
- extern void VecTransformf(VECTORF sx, VECTORF dx, Matx4x4 M);
- // Misc OpenGL Related Functions
- extern void glMatrixTo4x4(GLdouble M[16], Matx4x4 A);
- extern void Matx4x4ToglMatrix(Matx4x4 A, GLdouble M[16]);
- extern void Transformf(VECTORF sx, VECTORF dx, GLdouble M[16]);
- #ifdef __cplusplus
- }
- #endif
- #endif // Include/Define