summaryrefslogtreecommitdiff
path: root/src/maths.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/maths.c')
-rw-r--r--src/maths.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/maths.c b/src/maths.c
index 72b6dd3..87e9afd 100644
--- a/src/maths.c
+++ b/src/maths.c
@@ -8,6 +8,8 @@
#include <celeritas.h>
+vec2 vec2_create(f32 x, f32 y) { return (vec2){ x,y};}
+
vec3 vec3_create(f32 x, f32 y, f32 z) { return (vec3){ x, y, z }; }
vec3 vec3_add(vec3 u, vec3 v) { return (vec3){ .x = u.x + v.x, .y = u.y + v.y, .z = u.z + v.z }; }
vec3 vec3_sub(vec3 a, vec3 b) { return (vec3){ a.x - b.x, a.y - b.y, a.z - b.z }; }
@@ -29,8 +31,10 @@ 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 };
}
+
vec4 vec4_create(f32 x, f32 y, f32 z, f32 w) { return (vec4){ x, y, z, w }; }
+
f32 quat_dot(quat a, quat b) { return a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w; }
quat quat_normalise(quat a) {
@@ -51,6 +55,7 @@ quat quat_from_axis_angle(vec3 axis, f32 angle, bool normalize) {
return q;
}
+
mat4 mat4_ident() {
return (mat4){
.x_axis = { 1, 0, 0, 0 },
@@ -115,6 +120,10 @@ mat4 mat4_mult(mat4 lhs, mat4 rhs) {
// return out_matrix;
}
+
+/*
+
+*/
mat4 mat4_perspective(f32 fov_radians, f32 aspect_ratio, f32 near_z, f32 far_z) {
TODO("impl mat4_perspective");
// f32 half_tan_fov = tanf(fov_radians * 0.5f);
@@ -158,3 +167,7 @@ mat4 mat4_look_at(vec3 position, vec3 target, vec3 up) {
// return out_matrix;
}
+
+transform transform_from_mat4(mat4 matrix) {
+ TODO("stuff")
+} \ No newline at end of file