diff options
Diffstat (limited to 'prb_math.h')
-rw-r--r-- | prb_math.h | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/prb_math.h b/prb_math.h new file mode 100644 index 0000000..efa0fab --- /dev/null +++ b/prb_math.h @@ -0,0 +1,64 @@ +#ifndef PRB_MATH_H +#define PRB_MATH_H + +/* NOTE(pryazha): Numeric */ +#define F32_PI 3.14159265359f + +#define DEG2RAD F32_PI/180.0f +#define RAD2DEG 182.0f/F32_PI + +F32 f32sin(F32 a); +F32 f32cos(F32 a); +F32 f32sqrt(F32 a); + +/* NOTE(pryazha): Vectors */ +V2 v2(F32 x, F32 y); +V2 v2a(F32 x); +V2 v2neg(V2 a); +V2 v2add(V2 a, V2 b); +V2 v2sub(V2 a, V2 b); +V2 v2scalef(V2 a, F32 s); +V2 v2scale(V2 a, V2 s); +F32 v2dot(V2 a, V2 b); +F32 v2len2(V2 a); +F32 v2len(V2 a); +void v2print(V2 a); + +V3 v3(F32 x, F32 y, F32 z); +V3 v3a(F32 x); +V3 v3neg(V3 a); +V3 v3add(V3 a, V3 b); +V3 v3sub(V3 a, V3 b); +V3 v3scalef(V3 a, F32 s); +V3 v3scale(V3 a, V3 s); +F32 v3dot(V3 a, V3 b); +V3 v3cross(V3 l, V3 r); +F32 v3len2(V3 a); +F32 v3len(V3 a); +void v3print(V3 a); + +V4 v4(F32 x, F32 y, F32 z, F32 w); +V4 v4a(F32 x); +V4 v4fromv3(V3 a); +V4 v4neg(V4 a); +V4 v4add(V4 a, V4 b); +V4 v4sub(V4 a, V4 b); +V4 v4scalef(V4 a, F32 s); +V4 v4scale(V4 a, V4 s); +F32 v4dot(V4 a, V4 b); +F32 v4len2(V4 a); +F32 v4len(V4 a); +void v4print(V4 a); + +/* NOTE(pryazha): Matrices */ +F32 mat4det(Mat4 m); +Mat4 mat4transpose(Mat4 m); +Mat4 mat4mul(Mat4 left, Mat4 right); +Mat4 mat4translate(Mat4 m, V3 v); +Mat4 mat4scale(Mat4 m, V3 v); +Mat4 mat4_change_basis(V3 x, V3 y, V3 z); +Mat4 mat4rotate(Mat4 m, V3 angles); /* NOTE(pryazha): Angles in degrees */ +V4 mat4v4mul(Mat4 m, V4 v); +void mat4print(Mat4 m); + +#endif /* PRB_MATH_H */ |