| 1 | #ifndef MATH3D_H |
|---|
| 2 | #define MATH3D_H |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | |
|---|
| 19 | |
|---|
| 20 | |
|---|
| 21 | |
|---|
| 22 | |
|---|
| 23 | #ifdef __cplusplus |
|---|
| 24 | extern "C" { |
|---|
| 25 | #endif |
|---|
| 26 | |
|---|
| 27 | |
|---|
| 28 | #define UR_PI 3.14159265358979323846 |
|---|
| 29 | #define degToRad(deg) ((UR_PI/180.0)*(double)(deg)) |
|---|
| 30 | #define radToDeg(rad) ((180.0/UR_PI)*(double)(rad)) |
|---|
| 31 | |
|---|
| 32 | |
|---|
| 33 | |
|---|
| 34 | |
|---|
| 35 | void ur_loadIdentity( float* ); |
|---|
| 36 | void ur_loadRotation( float* mat, const float* axis, float radians ); |
|---|
| 37 | void ur_matrixMult( const float* a, const float* b, float* result ); |
|---|
| 38 | void ur_transLocal( float* mat, float x, float y, float z ); |
|---|
| 39 | void ur_matrixTranspose( float* mat, const float* a ); |
|---|
| 40 | void ur_matrixInverse( float* mat, const float* a ); |
|---|
| 41 | |
|---|
| 42 | |
|---|
| 43 | |
|---|
| 44 | |
|---|
| 45 | float ur_distance( const float* vecA, const float* vecB ); |
|---|
| 46 | void ur_transform( float* pnt, const float* mat ); |
|---|
| 47 | void ur_transform3x3( float* pnt, const float* mat ); |
|---|
| 48 | void ur_reflect( const float* a, const float* b, float* result ); |
|---|
| 49 | void ur_lineToPoint( const float* a, const float* b, const float* pnt, |
|---|
| 50 | float* vec ); |
|---|
| 51 | void ur_normalize( float* vec ); |
|---|
| 52 | |
|---|
| 53 | #define ur_dot(a,b) ((a[0] * b[0]) + (a[1] * b[1]) + (a[2] * b[2])) |
|---|
| 54 | |
|---|
| 55 | #define ur_cross(a,b,res) \ |
|---|
| 56 | res[0] = (a[1] * b[2]) - (a[2] * b[1]); \ |
|---|
| 57 | res[1] = (a[2] * b[0]) - (a[0] * b[2]); \ |
|---|
| 58 | res[2] = (a[0] * b[1]) - (a[1] * b[0]) |
|---|
| 59 | |
|---|
| 60 | #define ur_lengthSq(a) ((a[0] * a[0]) + (a[1] * a[1]) + (a[2] * a[2])) |
|---|
| 61 | |
|---|
| 62 | |
|---|
| 63 | #ifdef __cplusplus |
|---|
| 64 | } |
|---|
| 65 | #endif |
|---|
| 66 | |
|---|
| 67 | |
|---|
| 68 | #endif |
|---|