diff options
author | omniscient <17525998+omnisci3nce@users.noreply.github.com> | 2024-10-26 21:55:23 +1100 |
---|---|---|
committer | omniscient <17525998+omnisci3nce@users.noreply.github.com> | 2024-10-26 21:55:23 +1100 |
commit | 43bee361397315c7105b7214316325b185135331 (patch) | |
tree | b339f728b4cd6f37b37912b62c8d0af75dc9551d /archive/src/maths/maths.c | |
parent | 24573518c3320673eb87d6d659522d77e05cb75c (diff) |
move archive into /src
Diffstat (limited to 'archive/src/maths/maths.c')
-rw-r--r-- | archive/src/maths/maths.c | 35 |
1 files changed, 0 insertions, 35 deletions
diff --git a/archive/src/maths/maths.c b/archive/src/maths/maths.c deleted file mode 100644 index 19052fe..0000000 --- a/archive/src/maths/maths.c +++ /dev/null @@ -1,35 +0,0 @@ -#include "maths.h" - -#define c_static_inline - -c_static_inline Vec3 vec3_create(f32 x, f32 y, f32 z) { return (Vec3){ x, y, z }; } -c_static_inline Vec3 vec3_add(Vec3 a, Vec3 b) { return (Vec3){ a.x + b.x, a.y + b.y, a.z + b.z }; } -c_static_inline Vec3 vec3_sub(Vec3 a, Vec3 b) { return (Vec3){ a.x - b.x, a.y - b.y, a.z - b.z }; } -c_static_inline Vec3 vec3_mult(Vec3 a, f32 s) { return (Vec3){ a.x * s, a.y * s, a.z * s }; } -c_static_inline Vec3 vec3_div(Vec3 a, f32 s) { return (Vec3){ a.x / s, a.y / s, a.z / s }; } - -c_static_inline f32 vec3_len_squared(Vec3 a) { return (a.x * a.x) + (a.y * a.y) + (a.z * a.z); } -c_static_inline f32 vec3_len(Vec3 a) { return sqrtf(vec3_len_squared(a)); } -c_static_inline Vec3 vec3_negate(Vec3 a) { return (Vec3){ -a.x, -a.y, -a.z }; } -PUB c_static_inline Vec3 vec3_normalise(Vec3 a) { - f32 length = vec3_len(a); - return vec3_div(a, length); -} - -c_static_inline f32 vec3_dot(Vec3 a, Vec3 b) { return a.x * b.x + a.y * b.y + a.z * b.z; } -c_static_inline Vec3 vec3_cross(Vec3 a, Vec3 b) { - return ( - Vec3){ .x = a.y * b.z - a.z * b.y, .y = a.z * b.x - a.x * b.z, .z = a.x * b.y - a.y * b.x }; -} - -Mat4 mat4_ident() { - return (Mat4){ .data = { 1.0, 0., 0., 0., 0., 1., 0., 0., 0., 0., 1., 0., 0., 0., 0., 1.0 } }; -} - -Mat4 transform_to_mat(Transform* tf) { - Mat4 scale = mat4_scale(tf->scale); - Mat4 rotation = mat4_rotation(tf->rotation); - Mat4 translation = mat4_translation(tf->position); - // return mat4_mult(translation, mat4_mult(rotation, scale)); - return mat4_mult(mat4_mult(scale, rotation), translation); -}
\ No newline at end of file |