Add vector types and functions
This commit is contained in:
65
src/vector/vec.c
Normal file
65
src/vector/vec.c
Normal file
@@ -0,0 +1,65 @@
|
||||
#include "vector/vec.h"
|
||||
|
||||
vec2i_t vec_add_vec2i_t(vec2i_t v1, vec2i_t v2) {
|
||||
return (vec2i_t){.x = v1.x + v2.x, .y = v1.y + v2.y};
|
||||
}
|
||||
|
||||
vec2i_t vec_sub_vec2i_t(vec2i_t v1, vec2i_t v2) {
|
||||
return (vec2i_t){.x = v1.x - v2.x, .y = v1.y - v2.y};
|
||||
}
|
||||
|
||||
vec2i_t vec_mul_vec2i_t(vec2i_t v1, vec2i_t v2) {
|
||||
return (vec2i_t){.x = v1.x * v2.x, .y = v1.y * v2.y};
|
||||
}
|
||||
|
||||
i32 vec_dot_vec2i_t(vec2i_t v1, vec2i_t v2) {
|
||||
return v1.x * v2.x + v1.y * v2.y;
|
||||
}
|
||||
|
||||
vec2f_t vec_add_vec2f_t(vec2f_t v1, vec2f_t v2) {
|
||||
return (vec2f_t){.x = v1.x + v2.x, .y = v1.y + v2.y};
|
||||
}
|
||||
|
||||
vec2f_t vec_sub_vec2f_t(vec2f_t v1, vec2f_t v2) {
|
||||
return (vec2f_t){.x = v1.x - v2.x, .y = v1.y - v2.y};
|
||||
}
|
||||
|
||||
vec2f_t vec_mul_vec2f_t(vec2f_t v1, vec2f_t v2) {
|
||||
return (vec2f_t){.x = v1.x * v2.x, .y = v1.y * v2.y};
|
||||
}
|
||||
|
||||
f32 vec_dot_vec2f_t(vec2f_t v1, vec2f_t v2) {
|
||||
return v1.x * v2.x + v1.y * v2.y;
|
||||
}
|
||||
|
||||
vec3i_t vec_add_vec3i_t(vec3i_t v1, vec3i_t v2) {
|
||||
return (vec3i_t){.x = v1.x + v2.x, .y = v1.y + v2.y, .z = v1.z + v2.z};
|
||||
}
|
||||
|
||||
vec3i_t vec_sub_vec3i_t(vec3i_t v1, vec3i_t v2) {
|
||||
return (vec3i_t){.x = v1.x - v2.x, .y = v1.y - v2.y, .z = v1.z - v2.z};
|
||||
}
|
||||
|
||||
vec3i_t vec_mul_vec3i_t(vec3i_t v1, vec3i_t v2) {
|
||||
return (vec3i_t){.x = v1.x * v2.x, .y = v1.y * v2.y, .z = v1.z * v2.z};
|
||||
}
|
||||
|
||||
i32 vec_dot_vec3i_t(vec3i_t v1, vec3i_t v2) {
|
||||
return v1.x * v2.x + v1.y * v2.y + v1.z * v2.z;
|
||||
}
|
||||
|
||||
vec3f_t vec_add_vec3f_t(vec3f_t v1, vec3f_t v2) {
|
||||
return (vec3f_t){.x = v1.x + v2.x, .y = v1.y + v2.y, .z = v1.z + v2.z};
|
||||
}
|
||||
|
||||
vec3f_t vec_sub_vec3f_t(vec3f_t v1, vec3f_t v2) {
|
||||
return (vec3f_t){.x = v1.x - v2.x, .y = v1.y - v2.y, .z = v1.z - v2.z};
|
||||
}
|
||||
|
||||
vec3f_t vec_mul_vec3f_t(vec3f_t v1, vec3f_t v2) {
|
||||
return (vec3f_t){.x = v1.x * v2.x, .y = v1.y * v2.y, .z = v1.z * v2.z};
|
||||
}
|
||||
|
||||
f32 vec_dot_vec3f_t(vec3f_t v1, vec3f_t v2) {
|
||||
return v1.x * v2.x + v1.y * v2.y + v1.z * v2.z;
|
||||
}
|
||||
Reference in New Issue
Block a user