diff options
Diffstat (limited to 'src/math/structs.h')
-rw-r--r-- | src/math/structs.h | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/src/math/structs.h b/src/math/structs.h new file mode 100644 index 0000000..97af5bb --- /dev/null +++ b/src/math/structs.h @@ -0,0 +1,111 @@ +#ifndef SSR_STRUCTS_H +#define SSR_STRUCTS_H + +#include "../util/type.h" + + +typedef struct { + float x, y; +} Vec2; + +typedef union { + struct { + float x, y, z; + }; + struct { + float A, B, C; /*重心坐标*/ + }; + Vec2 xy; +} Vec3; + +typedef union { + struct { + float x, y, z, w; + }; + struct { + float r, g, b, a; + }; + Vec3 xyz; +} Vec4; + +typedef union { /*in degree, for visualize quaternion*/ + struct { + float x, y, z; + }; + struct { + float pitch, yaw, roll; + }; +} Euler; + +typedef struct { + float x, y, z, w; +} Quat; + +typedef union { + float l[16]; + float m[4][4]; + struct { + float + e00, e10, e20, e30, /*colum 0*/ + e01, e11, e21, e31, + e02, e12, e22, e32, + e03, e13, e23, e33; + }; + struct { + Vec4 x;/*colum 0*/ + Vec4 y; + Vec4 z; + Vec4 w; + } axis; /*轴*/ + struct { + Vec4 x;/*colum 0*/ + Vec4 y; + Vec4 z; + Vec4 w; + } basis; /*基向量*/ + struct { + Vec4 axisx; + Vec4 axisy; + Vec4 axisz; + Vec4 pos; + }; + Vec4 colums[4]; +} Mat4; + +typedef union { + struct { + Vec3 c1, c2, c3; + }; + float m[3][3]; + struct { + float + e00, e10, e20, /*colum 0*/ + e01, e11, e21, + e02, e12, e22; + }; +} Mat3; + +typedef union { + struct { + float + e00, e10, /*colum 0*/ + e01, e11, + e02, e12; + }; +} Mat23; + +typedef union { + struct { + float + e00, e10, e20, e30, /*colum 0*/ + e01, e11, e21, e31, + e02, e12, e22, e32; + }; + struct { /*三个齐次裁剪坐标*/ + Vec4 p1; + Vec4 p2; + Vec4 p3; + }; +} Mat43; + +#endif
\ No newline at end of file |