00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00020
00021 #ifndef __VR3MATH_H__
00022 #define __VR3MATH_H__
00023
00025 #define VR3MATH_MAX2(A,B) ((A)>(B))?(A):(B)
00026
00027 #define VR3MATH_MIN2(A,B) ((A)<(B))?(A):(B)
00028
00029 #define VR3MATH_MAX3(A,B,C) ((A)>(B))?((A)>(C)?(A):(C)):((B)>(C)?(B):(C))
00030
00031 #define VR3MATH_MIN3(A,B,C) ((A)<(B))?((A)<(C)?(A):(C)):((B)<(C)?(B):(C))
00032
00034 #define VR3MATH_PI 3.14159265f
00035
00037 namespace VR3Math {
00038
00039
00040
00042
00043
00045
00053 GLvoid Cross3( GLfloat result[3], const GLfloat vector0[3],
00054 const GLfloat vector1[3] );
00055
00057
00062 GLfloat Dot3(const GLfloat vector0[3], const GLfloat vector1[3]);
00063
00065
00067 GLfloat EuclideanNorm3(const GLfloat vector[3]);
00068
00070
00072 GLfloat EuclideanNorm3(const GLfloat x, const GLfloat y, const GLfloat z);
00073
00075
00077 GLvoid Normalize3(GLfloat vector[3]);
00078
00080
00081
00082
00084
00085
00087
00089 GLfloat Determinant4x4(const GLfloat m[16]);
00090
00092
00101 GLboolean InvertMatrix4x4(GLfloat result[16], const GLfloat m[16]);
00102
00104
00112 GLvoid MultMatrix4x4(GLfloat matrix[16], const GLfloat matrix0[16], const GLfloat matrix1[16]);
00113
00115
00119 GLvoid LoadIdentity4x4(GLfloat matrix[16]);
00120
00122
00129 GLvoid Rotate4x4(GLfloat matrix[16], GLfloat angle, GLfloat x, GLfloat y, GLfloat z);
00130
00132
00141 GLvoid RotateAngles4x4(GLfloat matrix[16], GLfloat ax, GLfloat ay, GLfloat az);
00142
00144
00150 GLvoid Translate4x4(GLfloat matrix[16], GLfloat x, GLfloat y, GLfloat z);
00151
00153
00159 GLvoid Scale4x4(GLfloat matrix[16], GLfloat x, GLfloat y, GLfloat z);
00160
00162
00172 GLvoid LookAt4x4( GLfloat result[16],
00173 GLfloat eyeX, GLfloat eyeY, GLfloat eyeZ,
00174 GLfloat centerX, GLfloat centerY, GLfloat centerZ,
00175 GLfloat upX, GLfloat upY, GLfloat upZ );
00176
00178
00186 GLvoid Ortho4x4( GLfloat result[16],
00187 GLfloat left, GLfloat right,
00188 GLfloat bottom, GLfloat top,
00189 GLfloat nearVal, GLfloat farVal );
00190
00192
00200 GLvoid Perspective4x4(GLfloat result[16],
00201 GLfloat fovy, GLfloat aspect, GLfloat zNear, GLfloat zFar);
00202
00204
00211 GLvoid Frustum4x4(GLfloat result[16],
00212 GLfloat left, GLfloat right, GLfloat bottom, GLfloat top,
00213 GLfloat nearVal, GLfloat farVal);
00214
00216
00217
00218
00220
00221
00223
00235 GLvoid MultMat4x4Vector3( GLfloat result[3],
00236 const GLfloat matrix[16], const GLfloat vector[3]);
00237
00239
00246 GLvoid MultMat4x4Vector4( GLfloat result[4],
00247 const GLfloat matrix[16], const GLfloat vector[4]);
00248
00250
00251
00252
00254
00255
00257
00260 void TriangleNormal( const GLfloat* vertex1, const GLfloat* vertex2,
00261 const GLfloat* vertex3, GLfloat* normal );
00262
00264
00265 }
00266
00267 #endif