diff options
Diffstat (limited to 'src/math/math.h')
-rw-r--r-- | src/math/math.h | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/math/math.h b/src/math/math.h index 1db7df7..41b4607 100644 --- a/src/math/math.h +++ b/src/math/math.h @@ -27,11 +27,11 @@ extern char printbuffer[1024]; float rsqrt(float n); float lerp(float from, float to, float t); -typedef struct Vec2 { +typedef struct { float x, y; } Vec2; -typedef union Vec3 { +typedef union { struct { float x, y, z; }; @@ -41,7 +41,7 @@ typedef union Vec3 { Vec2 xy; } Vec3; -typedef union Vec4 { +typedef union { struct { float x, y, z, w; }; @@ -51,7 +51,7 @@ typedef union Vec4 { Vec3 xyz; } Vec4; -typedef union Euler { /*in degree, for visualize quaternion*/ +typedef union { /*in degree, for visualize quaternion*/ struct { float x, y, z; }; @@ -60,11 +60,11 @@ typedef union Euler { /*in degree, for visualize quaternion*/ }; } Euler; -typedef struct Quat { +typedef struct { float x, y, z, w; } Quat; -typedef union Mat4 { +typedef union { float l[16]; float m[4][4]; struct { @@ -95,7 +95,7 @@ typedef union Mat4 { Vec4 colums[4]; } Mat4; -typedef union Mat3 { +typedef union { struct { float e00, e10, e20, /*colum 0*/ @@ -104,7 +104,7 @@ typedef union Mat3 { }; } Mat3; -typedef union Mat23 { +typedef union { struct { float e00, e10, /*colum 0*/ @@ -113,7 +113,7 @@ typedef union Mat23 { }; } Mat23; -typedef union Mat43 { +typedef union { struct { float e00, e10, e20, e30, /*colum 0*/ @@ -184,6 +184,8 @@ void vec4_print(Vec4* v); void vec4_lerp(Vec4* a, Vec4* b, float t, Vec4* out); +void vec4_scale(Vec4* v, float t, Vec4* out); + /************************************************************************/ /* Matrix */ /************************************************************************/ @@ -234,6 +236,7 @@ void mat4_invertpos(Mat4* pos, Mat4* out); /* 对平移矩阵求逆 */ void mat4_decomposetrs(Mat4* src, Vec3* pos, Quat* quat, Vec3* scale); /*分解trs矩阵*/ void mat4_applytovec4(Mat4* m, Vec4* v, Vec4* out); +void mat4_applytovec3(Mat4* m, Vec3* v, Vec3* out); bool mat4_toeuler(Mat4* in, Euler* out); /* 计算YXZ旋转矩阵的欧拉角 */ void mat4_toquat(Mat4* in, Quat* out); /*in是正交矩阵*/ |