00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef MMATH_H
00018 #define MMATH_H
00019
00020 #ifdef __cplusplus
00021 extern "C" {
00022 #endif
00023
00024 #define SQR(x) ((x)*(x))
00025
00026 #ifndef M_PI
00027 #define M_PI 3.141592765
00028 #endif
00029
00030 #define EPS 1e-5f
00031
00032 typedef struct {
00033 float x, y, z;
00034 } Vector3;
00035
00036 typedef struct {
00037 float x, y, z, w;
00038 } Quaternion;
00039
00040 Vector3 Vector3_new(float x, float y, float z);
00041
00042 Vector3 Vector3_add(Vector3 u, Vector3 v);
00043
00044 Vector3 Vector3_sub(Vector3 u, Vector3 v);
00045
00046 Vector3 Vector3_cross(Vector3 u, Vector3 v);
00047
00048 float Vector3_dot(Vector3 u, Vector3 v);
00049
00050 Vector3 Vector3_mult(Vector3 u, Vector3 v);
00051
00052 Vector3 Vector3_smult(float s, Vector3 v);
00053
00054 float Vector3_normalize(Vector3 *v);
00055
00056 void Vector3_stderr(char *s, Vector3 v);
00057
00058 Quaternion Quaternion_new(float w, float x, float y, float z);
00059
00060 Quaternion Quaternion_fromAngleAxis(float angle, Vector3 axis);
00061
00062 Quaternion Quaternion_mult(Quaternion p, Quaternion q);
00063
00064 void Quaternion_getAngleAxis(const Quaternion q, float *angle, Vector3 *axis);
00065
00066 void Quaternion_normalize(Quaternion *q);
00067
00068 Quaternion Quaternion_inverse(Quaternion q);
00069
00070 Vector3 Quaternion_multVector3(Quaternion q, Vector3 v);
00071
00072 void Quaternion_stderr(char *s, Quaternion q);
00073
00074 #ifdef __cplusplus
00075 }
00076 #endif
00077
00078
00079 #endif