00001 #ifndef MATH_H 00002 #define MATH_H 00003 00004 #include "shared.h" 00005 #include "vector.h" 00006 #include "vertex.h" 00007 #include "quat.h" 00008 00009 #define dot(u,v) ((u).x * (v).x + (u).y * (v).y + (u).z * (v).z) 00010 #define norm(v) sqrt(dot(v,v)) // norm = length of vector 00011 #define d(u,v) norm(u-v) // distance = norm of difference 00012 00013 void LoadIdentity(float m[]); 00014 void CopyMatrix(float m[], float n[]); 00015 void MultMatrix(float m[], float n[]); 00016 void MatrixInverse(float m[]); 00017 QUAT AxisAngleToMatrix(VECTOR axis, float theta, float m[16]); 00018 float DotProduct(VECTOR vec1, VECTOR vec2); 00019 VECTOR CrossVector(VECTOR vec1, VECTOR vec2); 00020 void EulerToQuat(float roll, float pitch, float yaw, QUAT * quat); 00021 float MagnitudeQuat(QUAT q1); 00022 QUAT NormaliseQuat(QUAT q1); 00023 void QuatToMatrix(QUAT quat, float m[16]); 00024 QUAT MultQuat(QUAT q1, QUAT q2); 00025 VERTEX GetNorm(float x1, float y1, float z1, float x2, float y2, float z2, float x3, float y3, float z3); 00026 float MagnitudeVector(VECTOR vec1); 00027 VECTOR GetUnitVector(VECTOR vector); 00028 VECTOR GetEdgeVector(VECTOR point1, VECTOR point2); 00029 00030 #endif